From: Zbigniew Jędrzejewski-Szmek Date: Fri, 27 Jun 2025 11:43:09 +0000 (+0200) Subject: shared/bus-unit-util: define helper for StartupAllowedMemoryNodes= and friends X-Git-Tag: v258-rc1~183^2~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca197282fb0c7340102a8718344b31603201db6d;p=thirdparty%2Fsystemd.git shared/bus-unit-util: define helper for StartupAllowedMemoryNodes= and friends --- diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index d08d1585a2a..a9c9a0138c9 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -283,6 +283,23 @@ static int bus_append_parse_permyriad(sd_bus_message *m, const char *field, cons return 1; } +static int bus_append_parse_cpu_set(sd_bus_message *m, const char *field, const char *eq) { + _cleanup_(cpu_set_done) CPUSet cpuset = {}; + _cleanup_free_ uint8_t *array = NULL; + size_t allocated; + int r; + + r = parse_cpu_set(eq, &cpuset); + if (r < 0) + return log_error_errno(r, "Failed to parse %s value: %s", field, eq); + + r = cpu_set_to_dbus(&cpuset, &array, &allocated); + if (r < 0) + return log_error_errno(r, "Failed to serialize %s: %m", field); + + return bus_append_byte_array(m, field, array, allocated); +} + static int bus_append_exec_command(sd_bus_message *m, const char *field, const char *eq) { bool explicit_path = false, done = false, ambient_hack = false; _cleanup_strv_free_ char **l = NULL, **ex_opts = NULL; @@ -619,22 +636,8 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons if (STR_IN_SET(field, "AllowedCPUs", "StartupAllowedCPUs", "AllowedMemoryNodes", - "StartupAllowedMemoryNodes")) { - - _cleanup_(cpu_set_done) CPUSet cpuset = {}; - _cleanup_free_ uint8_t *array = NULL; - size_t allocated; - - r = parse_cpu_set(eq, &cpuset); - if (r < 0) - return log_error_errno(r, "Failed to parse %s value: %s", field, eq); - - r = cpu_set_to_dbus(&cpuset, &array, &allocated); - if (r < 0) - return log_error_errno(r, "Failed to serialize CPUSet: %m"); - - return bus_append_byte_array(m, field, array, allocated); - } + "StartupAllowedMemoryNodes")) + return bus_append_parse_cpu_set(m, field, eq); if (streq(field, "DisableControllers")) return bus_append_strv(m, "DisableControllers", eq, /* separator= */ NULL, EXTRACT_UNQUOTE);