1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-27 14:03:43 +03:00

systemctl: present CPUAffinity mask as a list of CPU index ranges

This commit is contained in:
Michal Sekletar 2019-05-22 17:14:21 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent 71b28519b5
commit a047f4f10e

View File

@ -31,6 +31,7 @@
#include "cgroup-show.h"
#include "cgroup-util.h"
#include "copy.h"
#include "cpu-set-util.h"
#include "dropin.h"
#include "efivars.h"
#include "env-util.h"
@ -5403,6 +5404,27 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m
if (all || !isempty(fields))
bus_print_property_value(name, expected_value, value, strempty(fields));
return 1;
} else if (contents[0] == SD_BUS_TYPE_BYTE && streq(name, "CPUAffinity")) {
_cleanup_free_ char *affinity = NULL;
_cleanup_(cpu_set_reset) CPUSet set = {};
const void *a;
size_t n;
r = sd_bus_message_read_array(m, 'y', &a, &n);
if (r < 0)
return bus_log_parse_error(r);
r = cpu_set_from_dbus(a, n, &set);
if (r < 0)
return log_error_errno(r, "Failed to deserialize CPUAffinity: %m");
affinity = cpu_set_to_range_string(&set);
if (!affinity)
return log_oom();
bus_print_property_value(name, expected_value, value, affinity);
return 1;
}