Blame SOURCES/libvirt-qemu-Prefer-nvdimmPath-over-hugepages-for-memory-backend-file.patch

99cbc7
From 52c101b96262131e4ed94aacff24f826db7302c4 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <52c101b96262131e4ed94aacff24f826db7302c4@dist-git>
99cbc7
From: Michal Privoznik <mprivozn@redhat.com>
99cbc7
Date: Fri, 28 Jun 2019 17:12:41 +0200
99cbc7
Subject: [PATCH] qemu: Prefer nvdimmPath over hugepages for
99cbc7
 memory-backend-file
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
If a domain has hugepages configured and we're currently building
99cbc7
memory-backend-file for a nvdimm device that domain has we will
99cbc7
put hugepages path onto the command line. It should have been
99cbc7
nvdimm path configured in the XML.
99cbc7
99cbc7
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
99cbc7
(cherry picked from commit 9eae8398edde9446ecc99f4f393bea94652fb6a2)
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1724980
99cbc7
99cbc7
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
99cbc7
Message-Id: <349f7180359c4b9e447602a760f639b7030d9c57.1561734747.git.mprivozn@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_command.c                       |  8 ++--
99cbc7
 .../hugepages-nvdimm.x86_64-latest.args       | 35 ++++++++++++++
99cbc7
 tests/qemuxml2argvdata/hugepages-nvdimm.xml   | 48 +++++++++++++++++++
99cbc7
 tests/qemuxml2argvtest.c                      |  1 +
99cbc7
 tests/qemuxml2xmloutdata/hugepages-nvdimm.xml |  1 +
99cbc7
 tests/qemuxml2xmltest.c                       |  1 +
99cbc7
 6 files changed, 90 insertions(+), 4 deletions(-)
99cbc7
 create mode 100644 tests/qemuxml2argvdata/hugepages-nvdimm.x86_64-latest.args
99cbc7
 create mode 100644 tests/qemuxml2argvdata/hugepages-nvdimm.xml
99cbc7
 create mode 120000 tests/qemuxml2xmloutdata/hugepages-nvdimm.xml
99cbc7
99cbc7
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
99cbc7
index 929f549a69..08660abbe4 100644
99cbc7
--- a/src/qemu/qemu_command.c
99cbc7
+++ b/src/qemu/qemu_command.c
99cbc7
@@ -3113,12 +3113,12 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
99cbc7
     if (useHugepage || mem->nvdimmPath || memAccess ||
99cbc7
         def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
99cbc7
 
99cbc7
-        if (useHugepage) {
99cbc7
-            if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &memPath) < 0)
99cbc7
+        if (mem->nvdimmPath) {
99cbc7
+            if (VIR_STRDUP(memPath, mem->nvdimmPath) < 0)
99cbc7
                 goto cleanup;
99cbc7
             prealloc = true;
99cbc7
-        } else if (mem->nvdimmPath) {
99cbc7
-            if (VIR_STRDUP(memPath, mem->nvdimmPath) < 0)
99cbc7
+        } else if (useHugepage) {
99cbc7
+            if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &memPath) < 0)
99cbc7
                 goto cleanup;
99cbc7
             prealloc = true;
99cbc7
         } else {
99cbc7
diff --git a/tests/qemuxml2argvdata/hugepages-nvdimm.x86_64-latest.args b/tests/qemuxml2argvdata/hugepages-nvdimm.x86_64-latest.args
99cbc7
new file mode 100644
99cbc7
index 0000000000..bc3e64948a
99cbc7
--- /dev/null
99cbc7
+++ b/tests/qemuxml2argvdata/hugepages-nvdimm.x86_64-latest.args
99cbc7
@@ -0,0 +1,35 @@
99cbc7
+LC_ALL=C \
99cbc7
+PATH=/bin \
99cbc7
+HOME=/home/test \
99cbc7
+USER=test \
99cbc7
+LOGNAME=test \
99cbc7
+QEMU_AUDIO_DRV=none \
99cbc7
+/usr/bin/qemu-system-i686 \
99cbc7
+-name guest=QEMUGuest1,debug-threads=on \
99cbc7
+-S \
99cbc7
+-object secret,id=masterKey0,format=raw,\
99cbc7
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
99cbc7
+-machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on \
99cbc7
+-m size=1048576k,slots=16,maxmem=1099511627776k \
99cbc7
+-realtime mlock=off \
99cbc7
+-smp 2,sockets=2,cores=1,threads=1 \
99cbc7
+-object memory-backend-file,id=ram-node0,prealloc=yes,\
99cbc7
+mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=yes,size=1073741824 \
99cbc7
+-numa node,nodeid=0,cpus=0-1,memdev=ram-node0 \
99cbc7
+-object memory-backend-file,id=memnvdimm0,prealloc=yes,mem-path=/tmp/nvdimm,\
99cbc7
+share=yes,size=536870912 \
99cbc7
+-device nvdimm,node=0,memdev=memnvdimm0,id=nvdimm0,slot=0 \
99cbc7
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
99cbc7
+-display none \
99cbc7
+-no-user-config \
99cbc7
+-nodefaults \
99cbc7
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
99cbc7
+-mon chardev=charmonitor,id=monitor,mode=control \
99cbc7
+-rtc base=utc \
99cbc7
+-no-shutdown \
99cbc7
+-no-acpi \
99cbc7
+-boot strict=on \
99cbc7
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
99cbc7
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
99cbc7
+resourcecontrol=deny \
99cbc7
+-msg timestamp=on
99cbc7
diff --git a/tests/qemuxml2argvdata/hugepages-nvdimm.xml b/tests/qemuxml2argvdata/hugepages-nvdimm.xml
99cbc7
new file mode 100644
99cbc7
index 0000000000..babb3a6179
99cbc7
--- /dev/null
99cbc7
+++ b/tests/qemuxml2argvdata/hugepages-nvdimm.xml
99cbc7
@@ -0,0 +1,48 @@
99cbc7
+<domain type='qemu'>
99cbc7
+  <name>QEMUGuest1</name>
99cbc7
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
99cbc7
+  <maxMemory slots='16' unit='KiB'>1099511627776</maxMemory>
99cbc7
+  <memory unit='KiB'>1267710</memory>
99cbc7
+  <currentMemory unit='KiB'>1267710</currentMemory>
99cbc7
+  <memoryBacking>
99cbc7
+    <hugepages>
99cbc7
+      <page size='2048' unit='KiB'/>
99cbc7
+    </hugepages>
99cbc7
+    <access mode='shared'/>
99cbc7
+  </memoryBacking>
99cbc7
+  <vcpu placement='static' cpuset='0-1'>2</vcpu>
99cbc7
+  <os>
99cbc7
+    <type arch='i686' machine='pc'>hvm</type>
99cbc7
+    <boot dev='hd'/>
99cbc7
+  </os>
99cbc7
+  <cpu>
99cbc7
+    <topology sockets='2' cores='1' threads='1'/>
99cbc7
+    <numa>
99cbc7
+      <cell id='0' cpus='0-1' memory='1048576' unit='KiB'/>
99cbc7
+    </numa>
99cbc7
+  </cpu>
99cbc7
+  <clock offset='utc'/>
99cbc7
+  <on_poweroff>destroy</on_poweroff>
99cbc7
+  <on_reboot>restart</on_reboot>
99cbc7
+  <on_crash>destroy</on_crash>
99cbc7
+  <devices>
99cbc7
+    <emulator>/usr/bin/qemu-system-i686</emulator>
99cbc7
+    <controller type='usb' index='0'>
99cbc7
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
99cbc7
+    </controller>
99cbc7
+    <controller type='pci' index='0' model='pci-root'/>
99cbc7
+    <input type='mouse' bus='ps2'/>
99cbc7
+    <input type='keyboard' bus='ps2'/>
99cbc7
+    <memballoon model='none'/>
99cbc7
+    <memory model='nvdimm'>
99cbc7
+      <source>
99cbc7
+        <path>/tmp/nvdimm</path>
99cbc7
+      </source>
99cbc7
+      <target>
99cbc7
+        <size unit='KiB'>523264</size>
99cbc7
+        <node>0</node>
99cbc7
+      </target>
99cbc7
+      <address type='dimm' slot='0'/>
99cbc7
+    </memory>
99cbc7
+  </devices>
99cbc7
+</domain>
99cbc7
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
99cbc7
index 9933e4bde1..6c09c6bb4a 100644
99cbc7
--- a/tests/qemuxml2argvtest.c
99cbc7
+++ b/tests/qemuxml2argvtest.c
99cbc7
@@ -994,6 +994,7 @@ mymain(void)
99cbc7
     DO_TEST_FAILURE("hugepages-memaccess3",
99cbc7
             QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE,
99cbc7
             QEMU_CAPS_VIRTIO_SCSI);
99cbc7
+    DO_TEST_CAPS_LATEST("hugepages-nvdimm");
99cbc7
     DO_TEST("nosharepages", QEMU_CAPS_MEM_MERGE);
99cbc7
     DO_TEST("disk-cdrom", NONE);
99cbc7
     DO_TEST("disk-iscsi", NONE);
99cbc7
diff --git a/tests/qemuxml2xmloutdata/hugepages-nvdimm.xml b/tests/qemuxml2xmloutdata/hugepages-nvdimm.xml
99cbc7
new file mode 120000
99cbc7
index 0000000000..8288d3c58f
99cbc7
--- /dev/null
99cbc7
+++ b/tests/qemuxml2xmloutdata/hugepages-nvdimm.xml
99cbc7
@@ -0,0 +1 @@
99cbc7
+../qemuxml2argvdata/hugepages-nvdimm.xml
99cbc7
\ No newline at end of file
99cbc7
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
99cbc7
index 1f67d74797..341b7cbcc6 100644
99cbc7
--- a/tests/qemuxml2xmltest.c
99cbc7
+++ b/tests/qemuxml2xmltest.c
99cbc7
@@ -344,6 +344,7 @@ mymain(void)
99cbc7
     DO_TEST("hugepages-shared", NONE);
99cbc7
     DO_TEST("hugepages-memaccess", NONE);
99cbc7
     DO_TEST("hugepages-memaccess2", NONE);
99cbc7
+    DO_TEST("hugepages-nvdimm", NONE);
99cbc7
     DO_TEST("nosharepages", NONE);
99cbc7
     DO_TEST("restore-v2", NONE);
99cbc7
     DO_TEST("migrate", NONE);
99cbc7
-- 
99cbc7
2.22.1
99cbc7