chiark / gitweb /
core: add startup resource control option
[elogind.git] / src / core / dbus-cgroup.c
index e9bdabf93189293b510965718586855238e8d3ce..a7c8ca6c27d42ceb10e3a08aeef2bcc54d0bbf8d 100644 (file)
@@ -173,11 +173,13 @@ const sd_bus_vtable bus_cgroup_vtable[] = {
         SD_BUS_VTABLE_START(0),
         SD_BUS_PROPERTY("CPUAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, cpu_accounting), 0),
         SD_BUS_PROPERTY("CPUShares", "t", bus_property_get_ulong, offsetof(CGroupContext, cpu_shares), 0),
+        SD_BUS_PROPERTY("StartupCPUShares", "t", bus_property_get_ulong, offsetof(CGroupContext, startup_cpu_shares), 0),
         SD_BUS_PROPERTY("CPUQuotaPerSecUSec", "t", property_get_cpu_quota_per_sec_usec, 0, 0),
         SD_BUS_PROPERTY("CPUQuotaUSec", "t", property_get_cpu_quota_usec, 0, 0),
         SD_BUS_PROPERTY("CPUQuotaPeriodUSec", "t", bus_property_get_usec, offsetof(CGroupContext, cpu_quota_period_usec), 0),
         SD_BUS_PROPERTY("BlockIOAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, blockio_accounting), 0),
         SD_BUS_PROPERTY("BlockIOWeight", "t", bus_property_get_ulong, offsetof(CGroupContext, blockio_weight), 0),
+        SD_BUS_PROPERTY("StartupBlockIOWeight", "t", bus_property_get_ulong, offsetof(CGroupContext, startup_blockio_weight), 0),
         SD_BUS_PROPERTY("BlockIODeviceWeight", "a(st)", property_get_blockio_device_weight, 0, 0),
         SD_BUS_PROPERTY("BlockIOReadBandwidth", "a(st)", property_get_blockio_device_bandwidths, 0, 0),
         SD_BUS_PROPERTY("BlockIOWriteBandwidth", "a(st)", property_get_blockio_device_bandwidths, 0, 0),
@@ -238,6 +240,26 @@ int bus_cgroup_set_property(
 
                 return 1;
 
+        } else if (streq(name, "StartupCPUShares")) {
+                uint64_t u64;
+                unsigned long ul;
+
+                r = sd_bus_message_read(message, "t", &u64);
+                if (r < 0)
+                        return r;
+
+                ul = (unsigned long) u64;
+                if (ul <= 0 || (uint64_t) ul != u64)
+                        return sd_bus_error_set_errnof(error, EINVAL, "StartupCPUShares value out of range");
+
+                if (mode != UNIT_CHECK) {
+                        c->startup_cpu_shares = ul;
+                        c->startup_cpu_shares_set = true;
+                        unit_write_drop_in_private_format(u, mode, name, "StartupCPUShares=%lu", ul);
+                }
+
+                return 1;
+
         } else if (streq(name, "CPUQuotaPerSecUSec")) {
                 uint64_t u64;
 
@@ -330,6 +352,26 @@ int bus_cgroup_set_property(
 
                 return 1;
 
+        } else if (streq(name, "StartupBlockIOWeight")) {
+                uint64_t u64;
+                unsigned long ul;
+
+                r = sd_bus_message_read(message, "t", &u64);
+                if (r < 0)
+                        return r;
+
+                ul = (unsigned long) u64;
+                if (ul < 10 || ul > 1000)
+                        return sd_bus_error_set_errnof(error, EINVAL, "StartupBlockIOWeight value out of range");
+
+                if (mode != UNIT_CHECK) {
+                        c->startup_blockio_weight = ul;
+                        c->startup_blockio_weight_set = true;
+                        unit_write_drop_in_private_format(u, mode, name, "StartupBlockIOWeight=%lu", ul);
+                }
+
+                return 1;
+
         } else if (streq(name, "BlockIOReadBandwidth") || streq(name, "BlockIOWriteBandwidth")) {
                 const char *path;
                 bool read = true;