From: Yu Watanabe Date: Mon, 7 Apr 2025 16:28:17 +0000 (+0900) Subject: nspawn/oci: also set CPUQuotaPeriodUSec DBus property X-Git-Tag: v258-rc1~874^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b7fb6ec34f947fb7cc7718b7987a7943f6f13633;p=thirdparty%2Fsystemd.git nspawn/oci: also set CPUQuotaPeriodUSec DBus property --- diff --git a/src/nspawn/nspawn-oci.c b/src/nspawn/nspawn-oci.c index 923e20b5c03..acd37255f03 100644 --- a/src/nspawn/nspawn-oci.c +++ b/src/nspawn/nspawn-oci.c @@ -1206,15 +1206,13 @@ static int oci_cgroup_cpu_shares(const char *name, sd_json_variant *v, sd_json_d } static int oci_cgroup_cpu_quota(const char *name, sd_json_variant *v, sd_json_dispatch_flags_t flags, void *userdata) { - uint64_t *u = ASSERT_PTR(userdata); - uint64_t k; + uint64_t k, *u = ASSERT_PTR(userdata); k = sd_json_variant_unsigned(v); if (k <= 0 || k >= UINT64_MAX) - return json_log(v, flags, SYNTHETIC_ERRNO(ERANGE), - "period/quota value out of range."); + return json_log(v, flags, SYNTHETIC_ERRNO(ERANGE), "period/quota value out of range."); - *u = (uint64_t) k; + *u = k; return 0; } @@ -1282,7 +1280,11 @@ static int oci_cgroup_cpu(const char *name, sd_json_variant *v, sd_json_dispatch if (r < 0) return r; - r = sd_bus_message_append(s->properties, "(sv)", "CPUQuotaPerSecUSec", "t", (uint64_t) (data.quota * USEC_PER_SEC / data.period)); + r = sd_bus_message_append(s->properties, "(sv)", "CPUQuotaPerSecUSec", "t", data.quota * USEC_PER_SEC / data.period); + if (r < 0) + return bus_log_create_error(r); + + r = sd_bus_message_append(s->properties, "(sv)", "CPUQuotaPeriodUSec", "t", data.period); if (r < 0) return bus_log_create_error(r);