X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fmachine%2Fmachined-dbus.c;h=ac19695c92c0ed627df7c96dd3f68dbfcd622ca9;hb=0a6f50c0afdfc434b492493bd9efab20cbee8623;hp=18b772d42d651a6335769b6bf8167e6a13e39c63;hpb=ebd93cb684806ac0f352139e69ac8f53eb49f5e4;p=elogind.git diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 18b772d42..ac19695c9 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -354,8 +354,6 @@ static int method_register_machine_internal(sd_bus *bus, sd_bus_message *message goto fail; } - m->registered = true; - r = machine_start(m, NULL, error); if (r < 0) goto fail; @@ -489,7 +487,7 @@ static int method_list_images(sd_bus *bus, sd_bus_message *message, void *userda if (r < 0) return r; - r = sd_bus_message_open_container(reply, 'a', "(ssbtto)"); + r = sd_bus_message_open_container(reply, 'a', "(ssbttto)"); if (r < 0) return r; @@ -500,12 +498,13 @@ static int method_list_images(sd_bus *bus, sd_bus_message *message, void *userda if (!p) return -ENOMEM; - r = sd_bus_message_append(reply, "(ssbtto)", + r = sd_bus_message_append(reply, "(ssbttto)", image->name, image_type_to_string(image->type), image->read_only, image->crtime, image->mtime, + image->usage, p); if (r < 0) return r; @@ -581,29 +580,23 @@ static int method_remove_image(sd_bus *bus, sd_bus_message *message, void *userd if (r == 0) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", name); - r = image_remove(i); - if (r < 0) - return r; - - return sd_bus_reply_method_return(message, NULL); + return bus_image_method_remove(bus, message, i, error); } static int method_rename_image(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(image_unrefp) Image* i = NULL; - const char *old_name, *new_name; + const char *old_name; int r; assert(bus); assert(message); - r = sd_bus_message_read(message, "ss", &old_name, &new_name); + r = sd_bus_message_read(message, "s", &old_name); if (r < 0) return r; if (!image_name_is_valid(old_name)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Image name '%s' is invalid.", old_name); - if (!image_name_is_valid(new_name)) - return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Image name '%s' is invalid.", new_name); r = image_find(old_name, &i); if (r < 0) @@ -611,27 +604,21 @@ static int method_rename_image(sd_bus *bus, sd_bus_message *message, void *userd if (r == 0) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", old_name); - r = image_rename(i, new_name); - if (r < 0) - return r; - - return sd_bus_reply_method_return(message, NULL); + return bus_image_method_rename(bus, message, i, error); } static int method_clone_image(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(image_unrefp) Image *i = NULL; - const char *old_name, *new_name; - int read_only, r; + const char *old_name; + int r; assert(bus); - r = sd_bus_message_read(message, "ssb", &old_name, &new_name, &read_only); + r = sd_bus_message_read(message, "s", &old_name); if (r < 0) return r; if (!image_name_is_valid(old_name)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Image name '%s' is invalid.", old_name); - if (!image_name_is_valid(new_name)) - return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Image name '%s' is invalid.", new_name); r = image_find(old_name, &i); if (r < 0) @@ -639,20 +626,16 @@ static int method_clone_image(sd_bus *bus, sd_bus_message *message, void *userda if (r == 0) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", old_name); - r = image_clone(i, new_name, read_only); - if (r < 0) - return r; - - return sd_bus_reply_method_return(message, NULL); + return bus_image_method_clone(bus, message, i, error); } static int method_mark_image_read_only(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_(image_unrefp) Image *i = NULL; const char *name; - int read_only, r; + int r; assert(bus); - r = sd_bus_message_read(message, "sb", &name, &read_only); + r = sd_bus_message_read(message, "s", &name); if (r < 0) return r; @@ -665,11 +648,7 @@ static int method_mark_image_read_only(sd_bus *bus, sd_bus_message *message, voi if (r == 0) return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", name); - r = image_read_only(i, read_only); - if (r < 0) - return r; - - return sd_bus_reply_method_return(message, NULL); + return bus_image_method_mark_read_only(bus, message, i, error); } const sd_bus_vtable manager_vtable[] = { @@ -678,7 +657,7 @@ const sd_bus_vtable manager_vtable[] = { SD_BUS_METHOD("GetImage", "s", "o", method_get_image, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("GetMachineByPID", "u", "o", method_get_machine_by_pid, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("ListMachines", NULL, "a(ssso)", method_list_machines, SD_BUS_VTABLE_UNPRIVILEGED), - SD_BUS_METHOD("ListImages", NULL, "a(ssbtto)", method_list_images, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_METHOD("ListImages", NULL, "a(ssbttto)", method_list_images, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("CreateMachine", "sayssusa(sv)", "o", method_create_machine, 0), SD_BUS_METHOD("CreateMachineWithNetwork", "sayssusaia(sv)", "o", method_create_machine_with_network, 0), SD_BUS_METHOD("RegisterMachine", "sayssus", "o", method_register_machine, 0), @@ -757,6 +736,8 @@ int match_properties_changed(sd_bus *bus, sd_bus_message *message, void *userdat return 0; r = unit_name_from_dbus_path(path, &unit); + if (r == -EINVAL) /* not for a unit */ + return 0; if (r < 0) return r;