libvirt/qemu-enable-overcommit_memory-while-start-cvm.patch
ikarosYuuki dfed5f54d6 qemu: enable overcommit_memory while start cvm
- qemu: enable overcommit_memory while start cvm

Signed-off-by: ikarosYuuki <tujipei@huawei.com>
(cherry picked from commit 8e920e9de2c12be1b438cef31828997b17f63eda)
2024-08-22 16:15:10 +08:00

37 lines
1.3 KiB
Diff

From 90b6a01fe7433e7d5ee3fc2e5eac334e2905fed9 Mon Sep 17 00:00:00 2001
From: ikarosYuuki <tujipei@huawei.com>
Date: Tue, 9 Jul 2024 22:03:05 +0800
Subject: [PATCH] qemu: enable overcommit_memory while start cvm In case of
asymmetric memory numa, starting cvm with huge memory might be prevented by
host kernel because of non-secure memory smaller than secure memory in the
same numa. Ensuring the normal launch of cvm, libvirt need to enable
overcommit_memory feature by writing the 1 to overcommit_memory system file.
Signed-off-by: ikarosYuuki <tujipei@huawei.com>
---
src/qemu/qemu_driver.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1e3f63a39a..823ffbc673 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7424,6 +7424,14 @@ qemuDomainObjStart(virConnectPtr conn,
}
}
+ if (vm->def->cvm) {
+ if (virFileWriteStr("/proc/sys/vm/overcommit_memory", "1", 0)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to enable overcommit_memory"));
+ return -1;
+ }
+ }
+
ret = qemuProcessStart(conn, driver, vm, NULL, asyncJob,
NULL, -1, NULL, NULL,
VIR_NETDEV_VPORT_PROFILE_OP_CREATE, start_flags);
--
2.31.1.windows.1