render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From 893ebcda06c14d25dd195f53a1467fb243b43838 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <893ebcda06c14d25dd195f53a1467fb243b43838@dist-git>
3e5111
From: Michal Privoznik <mprivozn@redhat.com>
3e5111
Date: Wed, 14 Jun 2017 16:58:13 +0200
3e5111
Subject: [PATCH] qemu: Don't try to use hugepages if not enabled
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1214369
3e5111
3e5111
My fix 671d18594f4 was incomplete. If domain doesn't have
3e5111
hugepages enabled, because of missing condition we would still be
3e5111
putting hugepages path onto qemu cmd line. Clean up the
3e5111
conditions so that it's more visible next time.
3e5111
3e5111
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
3e5111
(cherry picked from commit 1e8d6c6ef07a33ab338c2bf38fa017d4f2123335)
3e5111
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_command.c                            | 12 +++++-----
3e5111
 .../qemuxml2argv-cpu-numa-memshared.args           | 26 ++++++++++++++++++++++
3e5111
 tests/qemuxml2argvtest.c                           |  1 +
3e5111
 3 files changed, 33 insertions(+), 6 deletions(-)
3e5111
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
3e5111
3e5111
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
3e5111
index 5013d3149d..88223babeb 100644
3e5111
--- a/src/qemu/qemu_command.c
3e5111
+++ b/src/qemu/qemu_command.c
3e5111
@@ -3409,19 +3409,19 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
3e5111
         def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
3e5111
         *backendType = "memory-backend-file";
3e5111
 
3e5111
-        if (mem->nvdimmPath) {
3e5111
+        if (pagesize) {
3e5111
+            if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &memPath) < 0)
3e5111
+                goto cleanup;
3e5111
+            prealloc = true;
3e5111
+        } else if (mem->nvdimmPath) {
3e5111
             if (VIR_STRDUP(memPath, mem->nvdimmPath) < 0)
3e5111
                 goto cleanup;
3e5111
             prealloc = true;
3e5111
-        } else if (!pagesize && def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
3e5111
+        } else {
3e5111
             /* We can have both pagesize and mem source. If that's the case,
3e5111
              * prefer hugepages as those are more specific. */
3e5111
             if (VIR_STRDUP(memPath, cfg->memoryBackingDir) < 0)
3e5111
                 goto cleanup;
3e5111
-        } else {
3e5111
-            if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &memPath) < 0)
3e5111
-                goto cleanup;
3e5111
-            prealloc = true;
3e5111
         }
3e5111
 
3e5111
         if (virJSONValueObjectAdd(props,
3e5111
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
3e5111
new file mode 100644
3e5111
index 0000000000..677e17e7df
3e5111
--- /dev/null
3e5111
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-numa-memshared.args
3e5111
@@ -0,0 +1,26 @@
3e5111
+LC_ALL=C \
3e5111
+PATH=/bin \
3e5111
+HOME=/home/test \
3e5111
+USER=test \
3e5111
+LOGNAME=test \
3e5111
+QEMU_AUDIO_DRV=none \
3e5111
+/usr/bin/qemu \
3e5111
+-name QEMUGuest1 \
3e5111
+-S \
3e5111
+-M pc \
3e5111
+-m 214 \
3e5111
+-smp 16,sockets=2,cores=4,threads=2 \
3e5111
+-object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
3e5111
+share=yes,size=112197632 \
3e5111
+-numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
3e5111
+-object memory-backend-file,id=ram-node1,mem-path=/var/lib/libvirt/qemu/ram,\
3e5111
+share=no,size=112197632 \
3e5111
+-numa node,nodeid=1,cpus=8-15,memdev=ram-node1 \
3e5111
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
3e5111
+-nographic \
3e5111
+-nodefaults \
3e5111
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
3e5111
+-no-acpi \
3e5111
+-boot n \
3e5111
+-usb \
3e5111
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
3e5111
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
3e5111
index 98e70033ec..0745d3807a 100644
3e5111
--- a/tests/qemuxml2argvtest.c
3e5111
+++ b/tests/qemuxml2argvtest.c
3e5111
@@ -1549,6 +1549,7 @@ mymain(void)
3e5111
     DO_TEST("cpu-numa-disjoint", QEMU_CAPS_NUMA);
3e5111
     DO_TEST_FAILURE("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_RAM);
3e5111
     DO_TEST_FAILURE("cpu-numa-memshared", NONE);
3e5111
+    DO_TEST("cpu-numa-memshared", QEMU_CAPS_OBJECT_MEMORY_FILE);
3e5111
     DO_TEST("cpu-host-model", NONE);
3e5111
     DO_TEST("cpu-host-model-vendor", NONE);
3e5111
     skipLegacyCPUs = true;
3e5111
-- 
3e5111
2.13.1
3e5111