[PATCH] qemu: Allow memAccess for hugepages again

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



https://bugzilla.redhat.com/show_bug.cgi?id=1458638

Historically, we've always supported memAccess for domains backed
by hugepages. However, somewhere along the way we've regressed
and stopped allowing such configuration. Fix it.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_command.c                            |  4 +-
 .../qemuxml2argv-hugepages-memaccess.args          | 38 ++++++++++++++++++
 .../qemuxml2argv-hugepages-memaccess.xml           | 45 ++++++++++++++++++++++
 tests/qemuxml2argvtest.c                           |  1 +
 4 files changed, 87 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.xml

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 015af1036..2a076301f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3361,7 +3361,9 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendProps,
         return -1;
 
     if (pagesize || mem->nvdimmPath ||
-        def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
+        def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE ||
+        (memAccess == VIR_DOMAIN_MEMORY_ACCESS_SHARED &&
+         def->mem.nhugepages)) {
         *backendType = "memory-backend-file";
 
         if (mem->nvdimmPath) {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.args b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.args
new file mode 100644
index 000000000..c3f2c5397
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.args
@@ -0,0 +1,38 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 4096 \
+-smp 4,sockets=4,cores=1,threads=1 \
+-object memory-backend-file,id=ram-node0,prealloc=yes,\
+mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,size=1073741824,\
+host-nodes=0-3,policy=bind \
+-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
+-object memory-backend-file,id=ram-node1,prealloc=yes,\
+mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=yes,size=1073741824,\
+host-nodes=0-3,policy=bind \
+-numa node,nodeid=1,cpus=1,memdev=ram-node1 \
+-object memory-backend-file,id=ram-node2,prealloc=yes,\
+mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,share=no,size=1073741824,\
+host-nodes=0-3,policy=bind \
+-numa node,nodeid=2,cpus=2,memdev=ram-node2 \
+-object memory-backend-file,id=ram-node3,prealloc=yes,\
+mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,size=1073741824,\
+host-nodes=3,policy=bind \
+-numa node,nodeid=3,cpus=3,memdev=ram-node3 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.xml b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.xml
new file mode 100644
index 000000000..55379dcab
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-memaccess.xml
@@ -0,0 +1,45 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>4194304</memory>
+  <currentMemory unit='KiB'>4194304</currentMemory>
+  <memoryBacking>
+    <hugepages>
+      <page size='2048' unit='KiB' nodeset='1'/>
+      <page size='1048576' unit='KiB' nodeset='0,2-3'/>
+    </hugepages>
+  </memoryBacking>
+  <vcpu placement='static'>4</vcpu>
+  <numatune>
+    <memory mode='strict' nodeset='0-3'/>
+    <memnode cellid='3' mode='strict' nodeset='3'/>
+  </numatune>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <cpu>
+    <numa>
+      <cell id='0' cpus='0' memory='1048576'/>
+      <cell id='1' cpus='1' memory='1048576' memAccess='shared'/>
+      <cell id='2' cpus='2' memory='1048576' memAccess='private'/>
+      <cell id='3' cpus='3' memory='1048576'/>
+    </numa>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-i686</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index b7d7cc2ab..836f413ce 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -819,6 +819,7 @@ mymain(void)
             QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
     DO_TEST("hugepages-pages5", QEMU_CAPS_MEM_PATH);
     DO_TEST("hugepages-pages6", NONE);
+    DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE);
     DO_TEST("nosharepages", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MEM_MERGE);
     DO_TEST("disk-cdrom", NONE);
     DO_TEST("disk-iscsi", NONE);
-- 
2.13.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux