Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/qemu/qemu_command.c | 19 +++++++++++++++++++
.../qemuxml2argv-hugepages-shared.args | 16 ++++++++++++++++
tests/qemuxml2argvtest.c | 5 +++++
3 files changed, 40 insertions(+)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.args
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 1ca98fb..6e4b0e4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6545,6 +6545,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
for (i = 0; i < def->cpu->ncells; i++) {
int cellmem = VIR_DIV_UP(def->cpu->cells[i].mem, 1024);
def->cpu->cells[i].mem = cellmem * 1024;
+ virTristateSwitch memShared = def->cpu->cells[i].memShared;
VIR_FREE(cpumask);
VIR_FREE(nodemask);
@@ -6623,7 +6624,18 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
virBufferAsprintf(&buf,
"memory-backend-file,prealloc=yes,mem-path=%s",
mem_path);
+
+ if (memShared) {
+ virBufferAsprintf(&buf, ",share=%s",
+ virTristateSwitchTypeToString(memShared));
+ }
} else {
+ if (memShared) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Shared memory mapping is supported "
+ "only with hugepages"));
+ goto cleanup;
+ }
virBufferAddLit(&buf, "memory-backend-ram");
}
@@ -6654,6 +6666,13 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
virCommandAddArg(cmd, "-object");
virCommandAddArgBuffer(cmd, &buf);
+ } else {
+ if (memShared) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Shared memory mapping is not supported "
+ "with this QEMU"));
+ goto cleanup;
+ }
}
virCommandAddArg(cmd, "-numa");
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.args
b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.args
new file mode 100644
index 0000000..a7c7d92
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-shared.args
@@ -0,0 +1,16 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc -m 4096 -smp 4 \
+-object memory-backend-file,prealloc=yes,mem-path=/dev/hugepages1G/libvirt/qemu,\
+size=1024M,id=ram-node0,host-nodes=0-3,policy=bind \
+-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
+-object memory-backend-file,prealloc=yes,mem-path=/dev/hugepages2M/libvirt/qemu,\
+share=on,size=1024M,id=ram-node1,host-nodes=0-3,policy=bind \
+-numa node,nodeid=1,cpus=1,memdev=ram-node1 \
+-object memory-backend-file,prealloc=yes,mem-path=/dev/hugepages1G/libvirt/qemu,\
+share=off,size=1024M,id=ram-node2,host-nodes=0-3,policy=bind \
+-numa node,nodeid=2,cpus=2,memdev=ram-node2 \
+-object memory-backend-file,prealloc=yes,mem-path=/dev/hugepages1G/libvirt/qemu,\
+size=1024M,id=ram-node3,host-nodes=3,policy=bind \
+-numa node,nodeid=3,cpus=3,memdev=ram-node3 \
+-nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
+-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 3feb2fe..41dcd60 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -682,6 +682,8 @@ mymain(void)
QEMU_CAPS_OBJECT_MEMORY_FILE);
DO_TEST("hugepages-pages3", QEMU_CAPS_MEM_PATH,
QEMU_CAPS_OBJECT_MEMORY_RAM,
QEMU_CAPS_OBJECT_MEMORY_FILE);
+ DO_TEST("hugepages-shared", QEMU_CAPS_MEM_PATH,
QEMU_CAPS_OBJECT_MEMORY_RAM,
+ QEMU_CAPS_OBJECT_MEMORY_FILE);
DO_TEST("nosharepages", QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MEM_MERGE);
DO_TEST("disk-cdrom", NONE);
DO_TEST("disk-cdrom-network-http", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE,
@@ -1205,6 +1207,9 @@ mymain(void)
DO_TEST_PARSE_ERROR("cpu-numa3", NONE);
DO_TEST_FAILURE("cpu-numa-disjoint", NONE);
DO_TEST("cpu-numa-disjoint", QEMU_CAPS_NUMA);
+ DO_TEST_FAILURE("cpu-numa-memshared", QEMU_CAPS_SMP_TOPOLOGY,
+ QEMU_CAPS_OBJECT_MEMORY_RAM);
+ DO_TEST_FAILURE("cpu-numa-memshared", QEMU_CAPS_SMP_TOPOLOGY);
DO_TEST("cpu-host-model", NONE);
skipLegacyCPUs = true;
DO_TEST("cpu-host-model-fallback", NONE);
--
2.1.0