diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-06-27 21:14:56 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-06-27 21:14:56 +0200 |
commit | 8e2af478402414f060bbc16e1b4bbe7de1779c13 (patch) | |
tree | 2548caac0cda5efadd459e3a4e3744449d57a181 /src/core/dbus-cgroup.c | |
parent | aae72d6fa0910891aa446ec43c548512987d453a (diff) |
dbus: add infrastructure for changing multiple properties at once on units and hook some cgroup attributes up to it
This introduces two bus calls to make runtime changes to selected bus
properties, optionally with persistence.
This currently hooks this up only for three cgroup atributes, but this
brings the infrastructure to add more changable attributes.
This allows setting multiple attributes at once, and takes an array
rather than a dictionary of properties, in order to implement simple
resetting of lists using the same approach as when they are sourced from
unit files. This means, that list properties are appended to by this
call, unless they are first reset via assigning the empty list.
Diffstat (limited to 'src/core/dbus-cgroup.c')
-rw-r--r-- | src/core/dbus-cgroup.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index 08ee9c8db4..f7d1dd12ad 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -137,3 +137,65 @@ const BusProperty bus_cgroup_context_properties[] = { { "DeviceAllow", bus_cgroup_append_device_allow, "a(ss)", 0 }, {} }; + +int bus_cgroup_set_property( + Unit *u, + CGroupContext *c, + const char *name, + DBusMessageIter *i, + UnitSetPropertiesMode mode, + DBusError *error) { + + assert(name); + assert(u); + assert(c); + assert(i); + + if (streq(name, "CPUAccounting")) { + dbus_bool_t b; + + if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_BOOLEAN) + return -EINVAL; + + if (mode != UNIT_CHECK) { + dbus_message_iter_get_basic(i, &b); + + c->cpu_accounting = b; + unit_write_drop_in(u, mode, "cpu-accounting", b ? "CPUAccounting=yes" : "CPUAccounting=no"); + } + + return 1; + + } else if (streq(name, "BlockIOAccounting")) { + dbus_bool_t b; + + if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_BOOLEAN) + return -EINVAL; + + if (mode != UNIT_CHECK) { + dbus_message_iter_get_basic(i, &b); + + c->blockio_accounting = b; + unit_write_drop_in(u, mode, "block-io-accounting", b ? "BlockIOAccounting=yes" : "BlockIOAccounting=no"); + } + + return 1; + } else if (streq(name, "MemoryAccounting")) { + dbus_bool_t b; + + if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_BOOLEAN) + return -EINVAL; + + if (mode != UNIT_CHECK) { + dbus_message_iter_get_basic(i, &b); + + c->blockio_accounting = b; + unit_write_drop_in(u, mode, "memory-accounting", b ? "MemoryAccounting=yes" : "MemoryAccounting=no"); + } + + return 1; + } + + + return 0; +} |