From 078d29057b30a197b0654e5534fe77ab5f9af46f Mon Sep 17 00:00:00 2001 From: ikarosYuuki Date: Wed, 10 Jul 2024 15:20:57 +0800 Subject: [PATCH] qemu: enable overcommit_memory while start cvm - qemu: enable overcommit_memory while start cvm Signed-off-by: ikarosYuuki (cherry picked from commit 2a6a3a03c09fcdb5fd3be3eff5e8b846b51a058c) --- libvirt.spec | 6 +++- ...le-overcommit_memory-while-start-cvm.patch | 36 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 qemu-enable-overcommit_memory-while-start-cvm.patch diff --git a/libvirt.spec b/libvirt.spec index ae416c2..c6e8d08 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -101,7 +101,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 6.2.0 -Release: 65 +Release: 66 License: LGPLv2+ URL: https://libvirt.org/ @@ -535,6 +535,7 @@ Patch0422: libvirt-add-get-tmm-memory-info-API-and-libvirtd-RPC.patch Patch0423: virsh-add-tmm-main-command-word.patch Patch0424: qemu-avoid-deadlock-in-qemuDomainObjStopWorker.patch Patch0425: remote-fix-double-free-of-migration-params-on-error.patch +Patch0426: qemu-enable-overcommit_memory-while-start-cvm.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2271,6 +2272,9 @@ exit 0 %changelog +* Thu July 1 2024 Jiabo Feng - 6.2.0-66 +- qemu: enable overcommit_memory while start cvm + * Thu Jun 13 2024 Jiabo Feng - 6.2.0-65 - remote: fix double free of migration params on error - qemu: avoid deadlock in qemuDomainObjStopWorker We are dropping the only reference here so that the event loop thread is going to be exited synchronously. In order to avoid deadlocks we need to unlock the VM so that any handler being called can finish execution and thus even loop thread be finished too. diff --git a/qemu-enable-overcommit_memory-while-start-cvm.patch b/qemu-enable-overcommit_memory-while-start-cvm.patch new file mode 100644 index 0000000..2c32a0a --- /dev/null +++ b/qemu-enable-overcommit_memory-while-start-cvm.patch @@ -0,0 +1,36 @@ +From 90b6a01fe7433e7d5ee3fc2e5eac334e2905fed9 Mon Sep 17 00:00:00 2001 +From: ikarosYuuki +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 +--- + 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 + -- Gitee