This patch add support for file memory backing on numa topology.
The specified access mode in memoryBacking can be overriden
by specifying token memAccess in numa cell.
---
src/qemu/qemu_command.c | 45 ++++++++++++++++------
.../qemuxml2argv-fd-memory-no-numa-topology.args | 21 ++++++++++
.../qemuxml2argv-fd-memory-no-numa-topology.xml | 27 +++++++++++++
.../qemuxml2argv-fd-memory-numa-topology.args | 24 ++++++++++++
.../qemuxml2argv-fd-memory-numa-topology.xml | 30 +++++++++++++++
.../qemuxml2argv-fd-memory-numa-topology2.args | 27 +++++++++++++
.../qemuxml2argv-fd-memory-numa-topology2.xml | 31 +++++++++++++++
.../qemuxml2argv-fd-memory-numa-topology3.args | 30 +++++++++++++++
.../qemuxml2argv-fd-memory-numa-topology3.xml | 32 +++++++++++++++
tests/qemuxml2argvtest.c | 13 +++++++
10 files changed, 268 insertions(+), 12 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fd-memory-no-numa-topology.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fd-memory-no-numa-topology.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology3.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology3.xml
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 601f11b..5fa735e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3314,17 +3314,26 @@ qemuBuildMemoryBackendStr(unsigned long long size,
if (!(props = virJSONValueNewObject()))
return -1;
- if (pagesize) {
- if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &mem_path) < 0)
- goto cleanup;
-
+ if (pagesize || def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
*backendType = "memory-backend-file";
- if (virJSONValueObjectAdd(props,
- "b:prealloc", true,
- "s:mem-path", mem_path,
- NULL) < 0)
- goto cleanup;
+ if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
+ /* we can have both pagesize and mem source, then check mem source first */
+ force = true;
+ if (virJSONValueObjectAdd(props,
+ "s:mem-path", cfg->memoryBackingDir,
+ NULL) < 0)
+ goto cleanup;
+ } else {
+ if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &mem_path) < 0)
+ goto cleanup;
+
+ if (virJSONValueObjectAdd(props,
+ "b:prealloc", true,
+ "s:mem-path", mem_path,
+ NULL) < 0)
+ goto cleanup;
+ }
switch (memAccess) {
case VIR_DOMAIN_MEMORY_ACCESS_SHARED:
@@ -3338,6 +3347,12 @@ qemuBuildMemoryBackendStr(unsigned long long size,
break;
case VIR_DOMAIN_MEMORY_ACCESS_DEFAULT:
+ if (def->mem.access == VIR_DOMAIN_MEMORY_ACCESS_SHARED) {
+ if (virJSONValueObjectAdd(props, "b:share", true, NULL) <
0)
+ goto cleanup;
+ }
+ break;
+
case VIR_DOMAIN_MEMORY_ACCESS_LAST:
break;
}
@@ -7302,7 +7317,10 @@ qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg,
if (qemuGetDomainHupageMemPath(def, cfg, def->mem.hugepages[0].size,
&mem_path) < 0)
return -1;
- virCommandAddArgList(cmd, "-mem-prealloc", "-mem-path", mem_path,
NULL);
+ if (def->mem.allocation != VIR_DOMAIN_MEMORY_ALLOCATION_IMMEDIATE)
+ virCommandAddArgList(cmd, "-mem-prealloc", NULL);
+
+ virCommandAddArgList(cmd, "-mem-path", mem_path, NULL);
VIR_FREE(mem_path);
return 0;
@@ -7332,9 +7350,12 @@ qemuBuildMemCommandLine(virCommandPtr cmd,
virDomainDefGetMemoryInitial(def) / 1024);
}
+ if (def->mem.allocation == VIR_DOMAIN_MEMORY_ALLOCATION_IMMEDIATE)
+ virCommandAddArgList(cmd, "-mem-prealloc", NULL);
+
/*
- * Add '-mem-path' (and '-mem-prealloc') parameter here only if
- * there is no numa node specified.
+ * Add '-mem-path' (and '-mem-prealloc') parameter here if
+ * the hugepages and no numa node is specified.
*/
if (!virDomainNumaGetNodeCount(def->numa) &&
qemuBuildMemPathStr(cfg, def, qemuCaps, cmd) < 0)
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-no-numa-topology.args
b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-no-numa-topology.args
new file mode 100644
index 0000000..951a7cb
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-no-numa-topology.args
@@ -0,0 +1,21 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name instance-00000092 \
+-S \
+-M pc-i440fx-wily \
+-m 14336 \
+-mem-prealloc \
+-smp 8,sockets=8,cores=1,threads=1 \
+-uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-instance-00000092/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-no-numa-topology.xml
b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-no-numa-topology.xml
new file mode 100644
index 0000000..243b65d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-no-numa-topology.xml
@@ -0,0 +1,27 @@
+<domain type='kvm' id='56'>
+ <name>instance-00000092</name>
+ <uuid>126f2720-6f8e-45ab-a886-ec9277079a67</uuid>
+ <memory unit='KiB'>14680064</memory>
+ <currentMemory unit='KiB'>14680064</currentMemory>
+ <memoryBacking>
+ <source type='file'/>
+ <access mode='shared'/>
+ <allocation mode='immediate'/>
+ </memoryBacking>
+ <vcpu placement='static'>8</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc-i440fx-wily'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <cpu>
+ <topology sockets='8' cores='1' threads='1'/>
+ </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-x86_64</emulator>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology.args
b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology.args
new file mode 100644
index 0000000..bef8136
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology.args
@@ -0,0 +1,24 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name instance-00000092 \
+-S \
+-M pc-i440fx-wily \
+-m 14336 \
+-mem-prealloc \
+-smp 8,sockets=1,cores=8,threads=1 \
+-object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
+share=yes,size=15032385536 \
+-numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
+-uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-instance-00000092/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology.xml
b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology.xml
new file mode 100644
index 0000000..ca5402d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology.xml
@@ -0,0 +1,30 @@
+<domain type='kvm'>
+ <name>instance-00000092</name>
+ <uuid>126f2720-6f8e-45ab-a886-ec9277079a67</uuid>
+ <memory unit='KiB'>14680064</memory>
+ <currentMemory unit='KiB'>14680064</currentMemory>
+ <memoryBacking>
+ <source type='file'/>
+ <access mode='shared'/>
+ <allocation mode='immediate'/>
+ </memoryBacking>
+ <vcpu placement='static'>8</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc-i440fx-wily'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <cpu>
+ <topology sockets='1' cores='8' threads='1'/>
+ <numa>
+ <cell id='0' cpus='0-7' memory='14680064'
unit='KiB'/>
+ </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-x86_64</emulator>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.args
b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.args
new file mode 100644
index 0000000..4420b9a
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.args
@@ -0,0 +1,27 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name instance-00000092 \
+-S \
+-M pc-i440fx-wily \
+-m 28672 \
+-mem-prealloc \
+-smp 20,sockets=1,cores=8,threads=1 \
+-object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
+size=15032385536 \
+-numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
+-object memory-backend-file,id=ram-node1,mem-path=/var/lib/libvirt/qemu/ram,\
+share=yes,size=15032385536 \
+-numa node,nodeid=1,cpus=8-15,memdev=ram-node1 \
+-uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-instance-00000092/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.xml
b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.xml
new file mode 100644
index 0000000..49beff1
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology2.xml
@@ -0,0 +1,31 @@
+ <domain type='kvm' id='56'>
+ <name>instance-00000092</name>
+ <uuid>126f2720-6f8e-45ab-a886-ec9277079a67</uuid>
+ <memory unit='KiB'>14680064</memory>
+ <currentMemory unit='KiB'>14680064</currentMemory>
+ <memoryBacking>
+ <source type='file'/>
+ <access mode='private'/>
+ <allocation mode='immediate'/>
+ </memoryBacking>
+ <vcpu placement='static'>20</vcpu>
+ <os>
+ <type arch='x86_64'
machine='pc-i440fx-wily'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <cpu>
+ <topology sockets='1' cores='8' threads='1'/>
+ <numa>
+ <cell id='0' cpus='0-7' memory='14680064'
unit='KiB'/>
+ <cell id='1' cpus='8-15' memory='14680064'
unit='KiB' memAccess='shared'/>
+ </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-x86_64</emulator>
+ <memballoon model='virtio'/>
+ </devices>
+ </domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology3.args
b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology3.args
new file mode 100644
index 0000000..4d98aa0
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology3.args
@@ -0,0 +1,30 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name instance-00000092 \
+-S \
+-M pc-i440fx-wily \
+-m 43008 \
+-mem-prealloc \
+-smp 32,sockets=1,cores=24,threads=1 \
+-object memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram,\
+share=yes,size=15032385536 \
+-numa node,nodeid=0,cpus=0-1,memdev=ram-node0 \
+-object memory-backend-file,id=ram-node1,mem-path=/var/lib/libvirt/qemu/ram,\
+share=yes,size=15032385536 \
+-numa node,nodeid=1,cpus=2-3,memdev=ram-node1 \
+-object memory-backend-file,id=ram-node2,mem-path=/var/lib/libvirt/qemu/ram,\
+share=no,size=15032385536 \
+-numa node,nodeid=2,cpus=4-5,memdev=ram-node2 \
+-uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-instance-00000092/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology3.xml
b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology3.xml
new file mode 100644
index 0000000..7933507
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-fd-memory-numa-topology3.xml
@@ -0,0 +1,32 @@
+ <domain type='kvm' id='56'>
+ <name>instance-00000092</name>
+ <uuid>126f2720-6f8e-45ab-a886-ec9277079a67</uuid>
+ <memory unit='KiB'>14680064</memory>
+ <currentMemory unit='KiB'>14680064</currentMemory>
+ <memoryBacking>
+ <source type='file'/>
+ <access mode='shared'/>
+ <allocation mode='immediate'/>
+ </memoryBacking>
+ <vcpu placement='static'>32</vcpu>
+ <os>
+ <type arch='x86_64'
machine='pc-i440fx-wily'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <cpu>
+ <topology sockets='1' cores='24' threads='1'/>
+ <numa>
+ <cell id='0' cpus='0-1' memory='14680064'
unit='KiB'/>
+ <cell id='1' cpus='2-3' memory='14680064'
unit='KiB' memAccess='shared'/>
+ <cell id='2' cpus='4-5' memory='14680064'
unit='KiB' memAccess='private'/>
+ </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-x86_64</emulator>
+ <memballoon model='virtio'/>
+ </devices>
+ </domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d0b0cec..c244ad5 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -594,6 +594,9 @@ mymain(void)
driver.config->spiceTLS = 1;
if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0)
return EXIT_FAILURE;
+ VIR_FREE(driver.config->memoryBackingDir);
+ if (VIR_STRDUP_QUIET(driver.config->memoryBackingDir,
"/var/lib/libvirt/qemu/ram") < 0)
+ return EXIT_FAILURE;
# define DO_TEST_FULL(name, migrateFrom, migrateFd, flags, \
parseFlags, gic, ...) \
@@ -2465,6 +2468,16 @@ mymain(void)
DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
+ DO_TEST("fd-memory-numa-topology", QEMU_CAPS_MEM_PATH,
QEMU_CAPS_OBJECT_MEMORY_FILE,
+ QEMU_CAPS_KVM);
+ DO_TEST("fd-memory-numa-topology2", QEMU_CAPS_MEM_PATH,
QEMU_CAPS_OBJECT_MEMORY_FILE,
+ QEMU_CAPS_KVM);
+ DO_TEST("fd-memory-numa-topology3", QEMU_CAPS_MEM_PATH,
QEMU_CAPS_OBJECT_MEMORY_FILE,
+ QEMU_CAPS_KVM);
+
+ DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_MEM_PATH,
QEMU_CAPS_OBJECT_MEMORY_FILE,
+ QEMU_CAPS_KVM);
+
qemuTestDriverFree(&driver);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
--
2.7.4
--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263
This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.