From d7550a6752be85f98408a86b7ae23a033e9b2983 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 1 Jul 2013 02:45:02 +0200 Subject: [PATCH] core: move ControlGroup and Slice properties out of the dbus "Unit" interface Slice/ControlGroup only really makes sense for unit types which actually have cgroups attached to them, hence move them out of the generic Unit interface and into the specific unit type interfaces. These fields will continue to be part of Unit though, simply because things are a log easier that way. However, regardless how this looks internally we should keep things clean and independent of the specific implementation of the inside. --- src/core/dbus-mount.c | 2 ++ src/core/dbus-scope.c | 2 ++ src/core/dbus-service.c | 2 ++ src/core/dbus-slice.c | 2 ++ src/core/dbus-socket.c | 6 ++++-- src/core/dbus-swap.c | 2 ++ src/core/dbus-unit.c | 7 +++++-- src/core/dbus-unit.h | 7 +++++-- 8 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/core/dbus-mount.c b/src/core/dbus-mount.c index ef55fcb17..72e187063 100644 --- a/src/core/dbus-mount.c +++ b/src/core/dbus-mount.c @@ -36,6 +36,7 @@ " \n" \ " \n" \ " \n" \ + BUS_UNIT_CGROUP_INTERFACE \ BUS_EXEC_COMMAND_INTERFACE("ExecMount") \ BUS_EXEC_COMMAND_INTERFACE("ExecUnmount") \ BUS_EXEC_COMMAND_INTERFACE("ExecRemount") \ @@ -158,6 +159,7 @@ DBusHandlerResult bus_mount_message_handler(Unit *u, DBusConnection *c, DBusMess const BusBoundProperties bps[] = { { "org.freedesktop.systemd1.Unit", bus_unit_properties, u }, + { "org.freedesktop.systemd1.Mount", bus_unit_cgroup_properties, u }, { "org.freedesktop.systemd1.Mount", bus_mount_properties, m }, { "org.freedesktop.systemd1.Mount", bus_exec_context_properties, &m->exec_context }, { "org.freedesktop.systemd1.Mount", bus_kill_context_properties, &m->kill_context }, diff --git a/src/core/dbus-scope.c b/src/core/dbus-scope.c index 604d14794..30b9c0033 100644 --- a/src/core/dbus-scope.c +++ b/src/core/dbus-scope.c @@ -30,6 +30,7 @@ #define BUS_SCOPE_INTERFACE \ " \n" \ + BUS_UNIT_CGROUP_INTERFACE \ " \n" \ BUS_KILL_CONTEXT_INTERFACE \ BUS_CGROUP_CONTEXT_INTERFACE \ @@ -65,6 +66,7 @@ DBusHandlerResult bus_scope_message_handler(Unit *u, DBusConnection *c, DBusMess const BusBoundProperties bps[] = { { "org.freedesktop.systemd1.Unit", bus_unit_properties, u }, + { "org.freedesktop.systemd1.Scope", bus_unit_cgroup_properties, u }, { "org.freedesktop.systemd1.Scope", bus_scope_properties, s }, { "org.freedesktop.systemd1.Scope", bus_cgroup_context_properties, &s->cgroup_context }, { "org.freedesktop.systemd1.Scope", bus_kill_context_properties, &s->kill_context }, diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c index 3bedda6c0..c2e02209b 100644 --- a/src/core/dbus-service.c +++ b/src/core/dbus-service.c @@ -46,6 +46,7 @@ " \n" \ " \n" \ " \n" \ + BUS_UNIT_CGROUP_INTERFACE \ BUS_EXEC_COMMAND_INTERFACE("ExecStartPre") \ BUS_EXEC_COMMAND_INTERFACE("ExecStart") \ BUS_EXEC_COMMAND_INTERFACE("ExecStartPost") \ @@ -152,6 +153,7 @@ DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *connectio const BusBoundProperties bps[] = { { "org.freedesktop.systemd1.Unit", bus_unit_properties, u }, + { "org.freedesktop.systemd1.Service", bus_unit_cgroup_properties, u }, { "org.freedesktop.systemd1.Service", bus_service_properties, s }, { "org.freedesktop.systemd1.Service", bus_exec_context_properties, &s->exec_context }, { "org.freedesktop.systemd1.Service", bus_kill_context_properties, &s->kill_context }, diff --git a/src/core/dbus-slice.c b/src/core/dbus-slice.c index 3b677792f..dac9fbdf5 100644 --- a/src/core/dbus-slice.c +++ b/src/core/dbus-slice.c @@ -29,6 +29,7 @@ #define BUS_SLICE_INTERFACE \ " \n" \ + BUS_UNIT_CGROUP_INTERFACE \ BUS_CGROUP_CONTEXT_INTERFACE \ " \n" @@ -53,6 +54,7 @@ DBusHandlerResult bus_slice_message_handler(Unit *u, DBusConnection *c, DBusMess const BusBoundProperties bps[] = { { "org.freedesktop.systemd1.Unit", bus_unit_properties, u }, + { "org.freedesktop.systemd1.Slice", bus_unit_cgroup_properties, u }, { "org.freedesktop.systemd1.Slice", bus_cgroup_context_properties, &s->cgroup_context }, {} }; diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c index a431fa192..da317edb8 100644 --- a/src/core/dbus-socket.c +++ b/src/core/dbus-socket.c @@ -34,6 +34,7 @@ " \n" \ " \n" \ " \n" \ + BUS_UNIT_CGROUP_INTERFACE \ BUS_EXEC_COMMAND_INTERFACE("ExecStartPre") \ BUS_EXEC_COMMAND_INTERFACE("ExecStartPost") \ BUS_EXEC_COMMAND_INTERFACE("ExecStopPre") \ @@ -196,18 +197,19 @@ static const BusProperty bus_socket_properties[] = { { "SmackLabel", bus_property_append_string, "s", offsetof(Socket, smack), true }, { "SmackLabelIPIn", bus_property_append_string, "s", offsetof(Socket, smack_ip_in), true }, { "SmackLabelIPOut",bus_property_append_string, "s", offsetof(Socket, smack_ip_out), true }, - { NULL, } + {} }; DBusHandlerResult bus_socket_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) { Socket *s = SOCKET(u); const BusBoundProperties bps[] = { { "org.freedesktop.systemd1.Unit", bus_unit_properties, u }, + { "org.freedesktop.systemd1.Socket", bus_unit_cgroup_properties, u }, { "org.freedesktop.systemd1.Socket", bus_socket_properties, s }, { "org.freedesktop.systemd1.Socket", bus_exec_context_properties, &s->exec_context }, { "org.freedesktop.systemd1.Socket", bus_kill_context_properties, &s->kill_context }, { "org.freedesktop.systemd1.Socket", bus_cgroup_context_properties, &s->cgroup_context }, - { NULL, } + {} }; SELINUX_UNIT_ACCESS_CHECK(u, c, message, "status"); diff --git a/src/core/dbus-swap.c b/src/core/dbus-swap.c index d854e0fb5..86fcf16ea 100644 --- a/src/core/dbus-swap.c +++ b/src/core/dbus-swap.c @@ -35,6 +35,7 @@ " \n" \ " \n" \ " \n" \ + BUS_UNIT_CGROUP_INTERFACE \ BUS_EXEC_COMMAND_INTERFACE("ExecActivate") \ BUS_EXEC_COMMAND_INTERFACE("ExecDeactivate") \ BUS_EXEC_CONTEXT_INTERFACE \ @@ -105,6 +106,7 @@ DBusHandlerResult bus_swap_message_handler(Unit *u, DBusConnection *c, DBusMessa Swap *s = SWAP(u); const BusBoundProperties bps[] = { { "org.freedesktop.systemd1.Unit", bus_unit_properties, u }, + { "org.freedesktop.systemd1.Swap", bus_unit_cgroup_properties, u }, { "org.freedesktop.systemd1.Swap", bus_swap_properties, s }, { "org.freedesktop.systemd1.Swap", bus_exec_context_properties, &s->exec_context }, { "org.freedesktop.systemd1.Swap", bus_kill_context_properties, &s->kill_context }, diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 36c3abdb9..6273e4627 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -878,7 +878,6 @@ const BusProperty bus_unit_properties[] = { { "Id", bus_property_append_string, "s", offsetof(Unit, id), true }, { "Names", bus_unit_append_names, "as", 0 }, { "Following", bus_unit_append_following, "s", 0 }, - { "Slice", bus_unit_append_slice, "s", 0 }, { "Requires", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_REQUIRES]), true }, { "RequiresOverridable", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_REQUIRES_OVERRIDABLE]), true }, { "Requisite", bus_unit_append_dependencies, "as", offsetof(Unit, dependencies[UNIT_REQUISITE]), true }, @@ -937,7 +936,11 @@ const BusProperty bus_unit_properties[] = { { "ConditionTimestampMonotonic", bus_property_append_usec, "t", offsetof(Unit, condition_timestamp.monotonic) }, { "ConditionResult", bus_property_append_bool, "b", offsetof(Unit, condition_result) }, { "LoadError", bus_unit_append_load_error, "(ss)", 0 }, - { "ControlGroup", bus_property_append_string, "s", offsetof(Unit, cgroup_path), true }, { "Transient", bus_property_append_bool, "b", offsetof(Unit, transient) }, { NULL, } }; + +const BusProperty bus_unit_cgroup_properties[] = { + { "Slice", bus_unit_append_slice, "s", 0 }, + { "ControlGroup", bus_property_append_string, "s", offsetof(Unit, cgroup_path), true }, +}; diff --git a/src/core/dbus-unit.h b/src/core/dbus-unit.h index 18f7c4f08..d3f7ec621 100644 --- a/src/core/dbus-unit.h +++ b/src/core/dbus-unit.h @@ -68,7 +68,6 @@ " \n" \ " \n" \ " \n" \ - " \n" \ " \n" \ " \n" \ " \n" \ @@ -127,15 +126,19 @@ " \n" \ " \n" \ " \n" \ - " \n" \ " \n" \ " \n" +#define BUS_UNIT_CGROUP_INTERFACE \ + " \n" \ + " \n" + #define BUS_UNIT_INTERFACES_LIST \ BUS_GENERIC_INTERFACES_LIST \ "org.freedesktop.systemd1.Unit\0" extern const BusProperty bus_unit_properties[]; +extern const BusProperty bus_unit_cgroup_properties[]; void bus_unit_send_change_signal(Unit *u); void bus_unit_send_removed_signal(Unit *u); -- 2.30.2