chiark / gitweb /
core: move ControlGroup and Slice properties out of the dbus "Unit" interface
authorLennart Poettering <lennart@poettering.net>
Mon, 1 Jul 2013 00:45:02 +0000 (02:45 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 1 Jul 2013 00:45:02 +0000 (02:45 +0200)
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
src/core/dbus-scope.c
src/core/dbus-service.c
src/core/dbus-slice.c
src/core/dbus-socket.c
src/core/dbus-swap.c
src/core/dbus-unit.c
src/core/dbus-unit.h

index ef55fcb173d27bf12589ed9c4ec78ffbb95609af..72e187063c51b31326be7304f60abb6cee275d36 100644 (file)
@@ -36,6 +36,7 @@
         "  <property name=\"Options\" type=\"s\" access=\"read\"/>\n"   \
         "  <property name=\"Type\" type=\"s\" access=\"read\"/>\n"      \
         "  <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"Options\" type=\"s\" access=\"read\"/>\n"   \
         "  <property name=\"Type\" type=\"s\" access=\"read\"/>\n"      \
         "  <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
+        BUS_UNIT_CGROUP_INTERFACE                                       \
         BUS_EXEC_COMMAND_INTERFACE("ExecMount")                         \
         BUS_EXEC_COMMAND_INTERFACE("ExecUnmount")                       \
         BUS_EXEC_COMMAND_INTERFACE("ExecRemount")                       \
         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 },
 
         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 },
                 { "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 },
index 604d1479457e535c995d9ed5d6cc3c5eb2dd6955..30b9c00335bb740ed1f29a7102008473c110ab99 100644 (file)
@@ -30,6 +30,7 @@
 
 #define BUS_SCOPE_INTERFACE                                             \
         " <interface name=\"org.freedesktop.systemd1.Scope\">\n"        \
 
 #define BUS_SCOPE_INTERFACE                                             \
         " <interface name=\"org.freedesktop.systemd1.Scope\">\n"        \
+        BUS_UNIT_CGROUP_INTERFACE                                       \
         "  <property name=\"TimeoutStopUSec\" type=\"t\" access=\"read\"/>\n" \
         BUS_KILL_CONTEXT_INTERFACE                                      \
         BUS_CGROUP_CONTEXT_INTERFACE                                    \
         "  <property name=\"TimeoutStopUSec\" type=\"t\" access=\"read\"/>\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 },
 
         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   },
                 { "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   },
index 3bedda6c014fb394bd9d7935ce27bf2c1433c3d9..c2e02209beb28cfa00e174dbfdeb30a9f1415510 100644 (file)
@@ -46,6 +46,7 @@
         "  <property name=\"StartLimitInterval\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"StartLimitBurst\" type=\"u\" access=\"read\"/>\n" \
         "  <property name=\"StartLimitAction\" type=\"s\" access=\"readwrite\"/>\n" \
         "  <property name=\"StartLimitInterval\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"StartLimitBurst\" type=\"u\" access=\"read\"/>\n" \
         "  <property name=\"StartLimitAction\" type=\"s\" access=\"readwrite\"/>\n" \
+        BUS_UNIT_CGROUP_INTERFACE                                       \
         BUS_EXEC_COMMAND_INTERFACE("ExecStartPre")                      \
         BUS_EXEC_COMMAND_INTERFACE("ExecStart")                         \
         BUS_EXEC_COMMAND_INTERFACE("ExecStartPost")                     \
         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 },
 
         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 },
                 { "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 },
index 3b677792fd7644fa477d83f109628f9133117c66..dac9fbdf5f5d020acb8a58537dfd6294d5740a06 100644 (file)
@@ -29,6 +29,7 @@
 
 #define BUS_SLICE_INTERFACE                                             \
         " <interface name=\"org.freedesktop.systemd1.Slice\">\n"        \
 
 #define BUS_SLICE_INTERFACE                                             \
         " <interface name=\"org.freedesktop.systemd1.Slice\">\n"        \
+        BUS_UNIT_CGROUP_INTERFACE                                       \
         BUS_CGROUP_CONTEXT_INTERFACE                                    \
         " </interface>\n"
 
         BUS_CGROUP_CONTEXT_INTERFACE                                    \
         " </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 },
 
         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 },
                 {}
         };
                 { "org.freedesktop.systemd1.Slice", bus_cgroup_context_properties, &s->cgroup_context },
                 {}
         };
index a431fa1921b29b5725e76f80e85b5ba9cbd6a1ee..da317edb86d38c3c640ce922d0e5847813562e24 100644 (file)
@@ -34,6 +34,7 @@
         "  <property name=\"BindIPv6Only\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"Backlog\" type=\"u\" access=\"read\"/>\n"   \
         "  <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"BindIPv6Only\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"Backlog\" type=\"u\" access=\"read\"/>\n"   \
         "  <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
+        BUS_UNIT_CGROUP_INTERFACE                                       \
         BUS_EXEC_COMMAND_INTERFACE("ExecStartPre")                      \
         BUS_EXEC_COMMAND_INTERFACE("ExecStartPost")                     \
         BUS_EXEC_COMMAND_INTERFACE("ExecStopPre")                       \
         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 },
         { "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 },
 };
 
 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 },
                 { "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");
         };
 
         SELINUX_UNIT_ACCESS_CHECK(u, c, message, "status");
index d854e0fb5efd1e2ddc4c2b3d8b0420431f602b29..86fcf16eaf35e85ce4d08e2fe753928c2ef70874 100644 (file)
@@ -35,6 +35,7 @@
         "  <property name=\"What\" type=\"s\" access=\"read\"/>\n"      \
         "  <property name=\"Priority\" type=\"i\" access=\"read\"/>\n"  \
         "  <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"What\" type=\"s\" access=\"read\"/>\n"      \
         "  <property name=\"Priority\" type=\"i\" access=\"read\"/>\n"  \
         "  <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
+        BUS_UNIT_CGROUP_INTERFACE                                       \
         BUS_EXEC_COMMAND_INTERFACE("ExecActivate")                      \
         BUS_EXEC_COMMAND_INTERFACE("ExecDeactivate")                    \
         BUS_EXEC_CONTEXT_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 },
         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 },
                 { "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 },
index 36c3abdb97d0bc30042cf90adfba8147821f4cba..6273e4627432e4d8cdba832583de3c4736b2c04b 100644 (file)
@@ -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 },
         { "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 },
         { "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 },
         { "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, }
 };
         { "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 },
+};
index 18f7c4f088f67fa49015211d1e7d15e584e14830..d3f7ec621e1d97ffe3220573b14861b1cf80739b 100644 (file)
@@ -68,7 +68,6 @@
         "  <property name=\"Id\" type=\"s\" access=\"read\"/>\n"        \
         "  <property name=\"Names\" type=\"as\" access=\"read\"/>\n"    \
         "  <property name=\"Following\" type=\"s\" access=\"read\"/>\n" \
         "  <property name=\"Id\" type=\"s\" access=\"read\"/>\n"        \
         "  <property name=\"Names\" type=\"as\" access=\"read\"/>\n"    \
         "  <property name=\"Following\" type=\"s\" access=\"read\"/>\n" \
-        "  <property name=\"Slice\" type=\"s\" access=\"read\"/>\n"     \
         "  <property name=\"Requires\" type=\"as\" access=\"read\"/>\n" \
         "  <property name=\"RequiresOverridable\" type=\"as\" access=\"read\"/>\n" \
         "  <property name=\"Requisite\" type=\"as\" access=\"read\"/>\n" \
         "  <property name=\"Requires\" type=\"as\" access=\"read\"/>\n" \
         "  <property name=\"RequiresOverridable\" type=\"as\" access=\"read\"/>\n" \
         "  <property name=\"Requisite\" type=\"as\" access=\"read\"/>\n" \
         "  <property name=\"ConditionTimestampMonotonic\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"ConditionResult\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"LoadError\" type=\"(ss)\" access=\"read\"/>\n" \
         "  <property name=\"ConditionTimestampMonotonic\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"ConditionResult\" type=\"b\" access=\"read\"/>\n" \
         "  <property name=\"LoadError\" type=\"(ss)\" access=\"read\"/>\n" \
-        "  <property name=\"ControlGroup\" type=\"s\" access=\"read\"/>\n" \
         "  <property name=\"Transient\" type=\"b\" access=\"read\"/>\n" \
         " </interface>\n"
 
         "  <property name=\"Transient\" type=\"b\" access=\"read\"/>\n" \
         " </interface>\n"
 
+#define BUS_UNIT_CGROUP_INTERFACE                                       \
+        "  <property name=\"Slice\" type=\"s\" access=\"read\"/>\n"     \
+        "  <property name=\"ControlGroup\" type=\"s\" access=\"read\"/>\n"
+
 #define BUS_UNIT_INTERFACES_LIST                \
         BUS_GENERIC_INTERFACES_LIST             \
         "org.freedesktop.systemd1.Unit\0"
 
 extern const BusProperty bus_unit_properties[];
 #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);
 
 void bus_unit_send_change_signal(Unit *u);
 void bus_unit_send_removed_signal(Unit *u);