summaryrefslogtreecommitdiffstats
path: root/src/machine/machined-dbus.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-05-17 22:33:48 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-05-19 18:03:14 +0200
commitc6aeb9b596749b263145346c7fa2c6bf7fbd3867 (patch)
treea8040ce29074c461b5a54e1b7a46d45ec7ed03e3 /src/machine/machined-dbus.c
parentmachine: split out manager_acquire_image() from image_object_find() (diff)
downloadsystemd-c6aeb9b596749b263145346c7fa2c6bf7fbd3867.tar.xz
systemd-c6aeb9b596749b263145346c7fa2c6bf7fbd3867.zip
machine: also acquire Image object from cache when a dbus method in the main interface is called
Previously, Image objects were only cached when reading properties or methods in the org.freedesktop.machine1.Image interface are called. This makes that, when a method in the main interface (org.freedesktop.machine1) for an image is called, also acquire the Image object from the cache, and if not cached, create Image object and put into the cache, like we do for org.freedesktop.machine1.Image. Otherwise, if some properties of an image are updated by methods in the main interface, e.g. MarkImageReadOnly(), the changes do not applied to the cached Image object, and subsequent read of proerties through the interface for the image, e.g. ReadOnly property, may provide outdated values. Follow-up for 1ddb263d21099ae42195c2bc382bdf72a7f24f82. Fixes #32888.
Diffstat (limited to 'src/machine/machined-dbus.c')
-rw-r--r--src/machine/machined-dbus.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index dbb03f3d67..944b52efd4 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -550,8 +550,8 @@ static int method_get_machine_uid_shift(sd_bus_message *message, void *userdata,
}
static int redirect_method_to_image(sd_bus_message *message, Manager *m, sd_bus_error *error, sd_bus_message_handler_t method) {
- _cleanup_(image_unrefp) Image* i = NULL;
const char *name;
+ Image *i;
int r;
assert(message);
@@ -565,13 +565,12 @@ static int redirect_method_to_image(sd_bus_message *message, Manager *m, sd_bus_
if (!image_name_is_valid(name))
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Image name '%s' is invalid.", name);
- r = image_find(IMAGE_MACHINE, name, NULL, &i);
+ r = manager_acquire_image(m, name, &i);
if (r == -ENOENT)
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_IMAGE, "No image '%s' known", name);
if (r < 0)
return r;
- i->userdata = m;
return method(message, i, error);
}