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

[libvirt] [PATCH v2 20/20] qemu: ensure that memory 'discard' is used if specified in XML



Signed-off-by: Pavel Hrdina <phrdina redhat com>
---
 src/qemu/qemu_command.c                        |  4 +++-
 .../pages-discard-hugepages.args               | 11 +++++++----
 tests/qemuxml2argvdata/pages-discard.args      | 18 ++++++++++++++----
 3 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index dbeb3a54f6..a7859feae6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3147,6 +3147,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
         return -1;
 
     if (useHugepage || mem->nvdimmPath || memAccess ||
+        discard == VIR_TRISTATE_BOOL_YES ||
         def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
 
         if (useHugepage) {
@@ -3228,7 +3229,8 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
     if (!needHugepage && !mem->sourceNodes && !nodeSpecified &&
         !mem->nvdimmPath &&
         memAccess == VIR_DOMAIN_MEMORY_ACCESS_DEFAULT &&
-        def->mem.source != VIR_DOMAIN_MEMORY_SOURCE_FILE && !force) {
+        def->mem.source != VIR_DOMAIN_MEMORY_SOURCE_FILE && !force &&
+        discard != VIR_TRISTATE_BOOL_YES) {
         /* report back that using the new backend is not necessary
          * to achieve the desired configuration */
         ret = 1;
diff --git a/tests/qemuxml2argvdata/pages-discard-hugepages.args b/tests/qemuxml2argvdata/pages-discard-hugepages.args
index 2dfacefe4a..d859480c26 100644
--- a/tests/qemuxml2argvdata/pages-discard-hugepages.args
+++ b/tests/qemuxml2argvdata/pages-discard-hugepages.args
@@ -10,10 +10,13 @@ QEMU_AUDIO_DRV=none \
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
 -m 1024 \
 -smp 2,sockets=2,cores=1,threads=1 \
--mem-prealloc \
--mem-path /dev/hugepages2M/libvirt/qemu/-1-SomeDummyHugepagesGu \
--numa node,nodeid=0,cpus=0,mem=256 \
--numa node,nodeid=1,cpus=1,mem=768 \
+-object memory-backend-file,id=ram-node0,prealloc=yes,\
+mem-path=/dev/hugepages2M/libvirt/qemu/-1-SomeDummyHugepagesGu,size=268435456 \
+-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-SomeDummyHugepagesGu,\
+discard-data=yes,size=805306368 \
+-numa node,nodeid=1,cpus=1,memdev=ram-node1 \
 -uuid ef1bdff4-27f3-4e85-a807-5fb4d58463cc \
 -display none \
 -no-user-config \
diff --git a/tests/qemuxml2argvdata/pages-discard.args b/tests/qemuxml2argvdata/pages-discard.args
index 9db8c72a22..4ae20f531f 100644
--- a/tests/qemuxml2argvdata/pages-discard.args
+++ b/tests/qemuxml2argvdata/pages-discard.args
@@ -10,10 +10,20 @@ QEMU_AUDIO_DRV=none \
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
 -m 4096 \
 -smp 4,sockets=4,cores=1,threads=1 \
--numa node,nodeid=0,cpus=0,mem=1024 \
--numa node,nodeid=1,cpus=1,mem=1024 \
--numa node,nodeid=2,cpus=2,mem=1024 \
--numa node,nodeid=3,cpus=3,mem=1024 \
+-object memory-backend-file,id=ram-node0,\
+mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node0,\
+discard-data=yes,size=1073741824 \
+-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
+-object memory-backend-ram,id=ram-node1,size=1073741824 \
+-numa node,nodeid=1,cpus=1,memdev=ram-node1 \
+-object memory-backend-file,id=ram-node2,\
+mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node2,\
+discard-data=yes,size=1073741824 \
+-numa node,nodeid=2,cpus=2,memdev=ram-node2 \
+-object memory-backend-file,id=ram-node3,\
+mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node3,\
+discard-data=yes,size=1073741824 \
+-numa node,nodeid=3,cpus=3,memdev=ram-node3 \
 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
 -display none \
 -no-user-config \
-- 
2.17.1


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