mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
vircgroup: Introduce virCgroupControllerAvailable
This new internal API checks if given CGroup controller is available. It is going to be needed later when we need to make a decision whether pin domain memory onto NUMA nodes using cpuset CGroup controller or using numa_set_membind(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
@@ -586,6 +586,34 @@ static int testCgroupAvailable(const void *args)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int testCgroupControllerAvailable(const void *args ATTRIBUTE_UNUSED)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
# define CHECK_CONTROLLER(c, present) \
|
||||
if ((present && !virCgroupControllerAvailable(c)) || \
|
||||
(!present && virCgroupControllerAvailable(c))) { \
|
||||
fprintf(stderr, present ? \
|
||||
"Expected controller %s not available\n" : \
|
||||
"Unexpected controller %s available\n", #c); \
|
||||
ret = -1; \
|
||||
}
|
||||
|
||||
CHECK_CONTROLLER(VIR_CGROUP_CONTROLLER_CPU, true)
|
||||
CHECK_CONTROLLER(VIR_CGROUP_CONTROLLER_CPUACCT, true)
|
||||
CHECK_CONTROLLER(VIR_CGROUP_CONTROLLER_CPUSET, true)
|
||||
CHECK_CONTROLLER(VIR_CGROUP_CONTROLLER_MEMORY, true)
|
||||
CHECK_CONTROLLER(VIR_CGROUP_CONTROLLER_DEVICES, false)
|
||||
CHECK_CONTROLLER(VIR_CGROUP_CONTROLLER_FREEZER, true)
|
||||
CHECK_CONTROLLER(VIR_CGROUP_CONTROLLER_BLKIO, true)
|
||||
CHECK_CONTROLLER(VIR_CGROUP_CONTROLLER_NET_CLS, false)
|
||||
CHECK_CONTROLLER(VIR_CGROUP_CONTROLLER_PERF_EVENT, false)
|
||||
CHECK_CONTROLLER(VIR_CGROUP_CONTROLLER_SYSTEMD, true)
|
||||
|
||||
# undef CHECK_CONTROLLER
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int testCgroupGetPercpuStats(const void *args ATTRIBUTE_UNUSED)
|
||||
{
|
||||
virCgroupPtr cgroup = NULL;
|
||||
@@ -886,6 +914,9 @@ mymain(void)
|
||||
if (virtTestRun("Cgroup available", testCgroupAvailable, (void*)0x1) < 0)
|
||||
ret = -1;
|
||||
|
||||
if (virtTestRun("Cgroup controller available", testCgroupControllerAvailable, NULL) < 0)
|
||||
ret = -1;
|
||||
|
||||
if (virtTestRun("virCgroupGetBlkioIoServiced works", testCgroupGetBlkioIoServiced, NULL) < 0)
|
||||
ret = -1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user