Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- src/util/vircgroupv2.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index d48e9db559..32d20f2ff6 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -1017,6 +1017,33 @@ virCgroupV2GetBlkioDeviceWriteBps(virCgroupPtr group, } +static int +virCgroupV2SetMemory(virCgroupPtr group, + unsigned long long kb) +{ + unsigned long long maxkb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED; + + if (kb > maxkb) { + virReportError(VIR_ERR_INVALID_ARG, + _("Memory '%llu' must be less than %llu"), + kb, maxkb); + return -1; + } + + if (kb == maxkb) { + return virCgroupSetValueStr(group, + VIR_CGROUP_CONTROLLER_MEMORY, + "memory.max", + "max"); + } else { + return virCgroupSetValueU64(group, + VIR_CGROUP_CONTROLLER_MEMORY, + "memory.max", + kb << 10); + } +} + + virCgroupBackend virCgroupV2Backend = { .type = VIR_CGROUP_BACKEND_TYPE_V2, @@ -1053,6 +1080,8 @@ virCgroupBackend virCgroupV2Backend = { .getBlkioDeviceReadBps = virCgroupV2GetBlkioDeviceReadBps, .setBlkioDeviceWriteBps = virCgroupV2SetBlkioDeviceWriteBps, .getBlkioDeviceWriteBps = virCgroupV2GetBlkioDeviceWriteBps, + + .setMemory = virCgroupV2SetMemory, }; -- 2.17.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list