[libvirt] [PATCH 1/3] qemu: introduce qemuBuildOvercommitCommandLine()

Menno Lageman menno.lageman at oracle.com
Mon Aug 19 08:32:24 UTC 2019


In preparation for adding support for '-overcommit cpu-pm=[on|off]',
add qemuBuildOvercommitCommandLine() to generate the '-overcommit'
commandline. Move the existing '-overcommit mem-lock=[on|off]'
generation code from qemuBuildMemCommandline() to this function.

Signed-off-by: Menno Lageman <menno.lageman at oracle.com>
---
 src/qemu/qemu_command.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f096e8f27e58..922456ec679e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7832,10 +7832,11 @@ qemuBuildMemCommandLine(virCommandPtr cmd,
         qemuBuildMemPathStr(cfg, def, cmd, priv) < 0)
         return -1;
 
-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OVERCOMMIT)) {
-        virCommandAddArg(cmd, "-overcommit");
-        virCommandAddArgFormat(cmd, "mem-lock=%s", def->mem.locked ? "on" : "off");
-    } else {
+    /*
+     * '-overcommit mem-lock=on|off' is handled with other
+     *  overcommit options later on.
+     */
+    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OVERCOMMIT)) {
         virCommandAddArg(cmd, "-realtime");
         virCommandAddArgFormat(cmd, "mlock=%s",
                                def->mem.locked ? "on" : "off");
@@ -7845,6 +7846,19 @@ qemuBuildMemCommandLine(virCommandPtr cmd,
 }
 
 
+static int
+qemuBuildOvercommitCommandLine(virCommandPtr cmd,
+                               const virDomainDef *def,
+                               virQEMUCapsPtr qemuCaps)
+{
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OVERCOMMIT)) {
+        virCommandAddArg(cmd, "-overcommit");
+        virCommandAddArgFormat(cmd, "mem-lock=%s", def->mem.locked ? "on" : "off");
+    }
+    return 0;
+}
+
+
 static int
 qemuBuildIOThreadCommandLine(virCommandPtr cmd,
                              const virDomainDef *def)
@@ -10657,6 +10671,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
     if (qemuBuildMemCommandLine(cmd, cfg, def, qemuCaps, priv) < 0)
         goto error;
 
+    if (qemuBuildOvercommitCommandLine(cmd, def, qemuCaps) < 0)
+        goto error;
+
     if (qemuBuildSmpCommandLine(cmd, def) < 0)
         goto error;
 
-- 
2.21.0




More information about the libvir-list mailing list