summaryrefslogtreecommitdiff
path: root/src/machine
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-02-01 14:30:57 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-02-01 20:31:50 -0500
commitbc06be753346784e19151814b5b9c01c624317f2 (patch)
tree233cc31ce5b3fc827c08a2c01fb87ea9868005dc /src/machine
parentd3e8277d5004163c725a895778c3a9dce9ca091e (diff)
shared/cgroup-show: extract funtion to query unit cgroup path
…and use it where possible.
Diffstat (limited to 'src/machine')
-rw-r--r--src/machine/machinectl.c24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 31a40d47c3..4f5f659c7c 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -477,35 +477,17 @@ static int list_images(int argc, char *argv[], void *userdata) {
}
static int show_unit_cgroup(sd_bus *bus, const char *unit, pid_t leader) {
+ _cleanup_free_ char *cgroup = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
- _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
- _cleanup_free_ char *path = NULL;
- const char *cgroup;
int r;
unsigned c;
assert(bus);
assert(unit);
- path = unit_dbus_path_from_name(unit);
- if (!path)
- return log_oom();
-
- r = sd_bus_get_property(
- bus,
- "org.freedesktop.systemd1",
- path,
- unit_dbus_interface_from_name(unit),
- "ControlGroup",
- &error,
- &reply,
- "s");
- if (r < 0)
- return log_error_errno(r, "Failed to query ControlGroup: %s", bus_error_message(&error, r));
-
- r = sd_bus_message_read(reply, "s", &cgroup);
+ r = show_cgroup_get_unit_path_and_warn(bus, unit, &cgroup);
if (r < 0)
- return bus_log_parse_error(r);
+ return r;
if (isempty(cgroup))
return 0;