Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- src/util/vircgroup.c | 13 ++----------- src/util/vircgroupbackend.h | 10 ++++++++++ src/util/vircgroupv1.c | 27 +++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 1e19813cb3..c37ada7c26 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1744,10 +1744,7 @@ virCgroupGetCpusetMems(virCgroupPtr group, char **mems) int virCgroupSetCpusetMemoryMigrate(virCgroupPtr group, bool migrate) { - return virCgroupSetValueStr(group, - VIR_CGROUP_CONTROLLER_CPUSET, - "cpuset.memory_migrate", - migrate ? "1" : "0"); + VIR_CGROUP_BACKEND_CALL(group, setCpusetMemoryMigrate, -1, migrate); } @@ -1762,13 +1759,7 @@ virCgroupSetCpusetMemoryMigrate(virCgroupPtr group, bool migrate) int virCgroupGetCpusetMemoryMigrate(virCgroupPtr group, bool *migrate) { - unsigned long long value = 0; - int ret = virCgroupGetValueU64(group, - VIR_CGROUP_CONTROLLER_CPUSET, - "cpuset.memory_migrate", - &value); - *migrate = !!value; - return ret; + VIR_CGROUP_BACKEND_CALL(group, getCpusetMemoryMigrate, -1, migrate); } diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h index 86fe8ce2db..887a508a15 100644 --- a/src/util/vircgroupbackend.h +++ b/src/util/vircgroupbackend.h @@ -324,6 +324,14 @@ typedef int (*virCgroupGetCpusetMemsCB)(virCgroupPtr group, char **mems); +typedef int +(*virCgroupSetCpusetMemoryMigrateCB)(virCgroupPtr group, + bool migrate); + +typedef int +(*virCgroupGetCpusetMemoryMigrateCB)(virCgroupPtr group, + bool *migrate); + struct _virCgroupBackend { virCgroupBackendType type; @@ -396,6 +404,8 @@ struct _virCgroupBackend { virCgroupSetCpusetMemsCB setCpusetMems; virCgroupGetCpusetMemsCB getCpusetMems; + virCgroupSetCpusetMemoryMigrateCB setCpusetMemoryMigrate; + virCgroupGetCpusetMemoryMigrateCB getCpusetMemoryMigrate; }; typedef struct _virCgroupBackend virCgroupBackend; typedef virCgroupBackend *virCgroupBackendPtr; diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index aff1706c5b..8070aede3e 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -1965,6 +1965,31 @@ virCgroupV1GetCpusetMems(virCgroupPtr group, } +static int +virCgroupV1SetCpusetMemoryMigrate(virCgroupPtr group, + bool migrate) +{ + return virCgroupSetValueStr(group, + VIR_CGROUP_CONTROLLER_CPUSET, + "cpuset.memory_migrate", + migrate ? "1" : "0"); +} + + +static int +virCgroupV1GetCpusetMemoryMigrate(virCgroupPtr group, + bool *migrate) +{ + unsigned long long value = 0; + int ret = virCgroupGetValueU64(group, + VIR_CGROUP_CONTROLLER_CPUSET, + "cpuset.memory_migrate", + &value); + *migrate = !!value; + return ret; +} + + virCgroupBackend virCgroupV1Backend = { .type = VIR_CGROUP_BACKEND_TYPE_V1, @@ -2035,6 +2060,8 @@ virCgroupBackend virCgroupV1Backend = { .setCpusetMems = virCgroupV1SetCpusetMems, .getCpusetMems = virCgroupV1GetCpusetMems, + .setCpusetMemoryMigrate = virCgroupV1SetCpusetMemoryMigrate, + .getCpusetMemoryMigrate = virCgroupV1GetCpusetMemoryMigrate, }; -- 2.17.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list