diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index e89fc2ce41349c76560fae2307a79fadda85ef93..e58e32fd99aa52ac8830f52fd52e948e9ccda1c6 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1738,10 +1738,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); } @@ -1756,13 +1753,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 35221e90df09ccf50e714c423d64a50eb9359b15..d4e4c4a6cc1a9b3ec60dc2a1e785202712683445 100644 --- a/src/util/vircgroupbackend.h +++ b/src/util/vircgroupbackend.h @@ -332,6 +332,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; @@ -404,6 +412,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 eb644d6bb2384c77221ffb8d0fbc5c3785974a7f..d33e9501b8f89463c558bdeda6d2e48ae7eb98ca 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -1970,6 +1970,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, @@ -2040,6 +2065,8 @@ virCgroupBackend virCgroupV1Backend = { .setCpusetMems = virCgroupV1SetCpusetMems, .getCpusetMems = virCgroupV1GetCpusetMems, + .setCpusetMemoryMigrate = virCgroupV1SetCpusetMemoryMigrate, + .getCpusetMemoryMigrate = virCgroupV1GetCpusetMemoryMigrate, };