|
|
9119d9 |
From f3bb37db51fda463f584b989ad5faca570949fa2 Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <f3bb37db51fda463f584b989ad5faca570949fa2@dist-git>
|
|
|
9119d9 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
9119d9 |
Date: Fri, 19 Dec 2014 08:21:42 +0100
|
|
|
9119d9 |
Subject: [PATCH] qemu: Create memory-backend-{ram, file} iff needed
|
|
|
9119d9 |
|
|
|
9119d9 |
Libvirt BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1175397
|
|
|
9119d9 |
QEMU BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1170093
|
|
|
9119d9 |
|
|
|
9119d9 |
In qemu there are two interesting arguments:
|
|
|
9119d9 |
|
|
|
9119d9 |
1) -numa to create a guest NUMA node
|
|
|
9119d9 |
2) -object memory-backend-{ram,file} to tell qemu which memory
|
|
|
9119d9 |
region on which host's NUMA node it should allocate the guest
|
|
|
9119d9 |
memory from.
|
|
|
9119d9 |
|
|
|
9119d9 |
Combining these two together we can instruct qemu to create a
|
|
|
9119d9 |
guest NUMA node that is tied to a host NUMA node. And it works
|
|
|
9119d9 |
just fine. However, depending on machine type used, there might
|
|
|
9119d9 |
be some issued during migration when OVMF is enabled (see QEMU
|
|
|
9119d9 |
BZ). While this truly is a QEMU bug, we can help avoiding it. The
|
|
|
9119d9 |
problem lies within the memory backend objects somewhere. Having
|
|
|
9119d9 |
said that, fix on our side consists on putting those objects on
|
|
|
9119d9 |
the command line if and only if needed. For instance, while
|
|
|
9119d9 |
previously we would construct this (in all ways correct) command
|
|
|
9119d9 |
line:
|
|
|
9119d9 |
|
|
|
9119d9 |
-object memory-backend-ram,size=256M,id=ram-node0 \
|
|
|
9119d9 |
-numa node,nodeid=0,cpus=0,memdev=ram-node0
|
|
|
9119d9 |
|
|
|
9119d9 |
now we create just:
|
|
|
9119d9 |
|
|
|
9119d9 |
-numa node,nodeid=0,cpus=0,mem=256
|
|
|
9119d9 |
|
|
|
9119d9 |
because the backend object is obviously not tied to any specific
|
|
|
9119d9 |
host NUMA node.
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
9119d9 |
(cherry picked from commit f309db1f4d51009bad0d32e12efc75530b66836b)
|
|
|
9119d9 |
|
|
|
9119d9 |
Conflicts:
|
|
|
9119d9 |
src/qemu/qemu_command.c: Some context
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/qemu/qemu_command.c | 16 +++++++++-------
|
|
|
9119d9 |
.../qemuxml2argvdata/qemuxml2argv-hugepages-pages3.args | 3 +--
|
|
|
9119d9 |
.../qemuxml2argv-numatune-memnode-no-memory.args | 3 +--
|
|
|
9119d9 |
3 files changed, 11 insertions(+), 11 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
9119d9 |
index ed66cea..d3eb43b 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_command.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_command.c
|
|
|
9119d9 |
@@ -6583,6 +6583,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
for (i = 0; i < def->cpu->ncells; i++) {
|
|
|
9119d9 |
+ virDomainHugePagePtr hugepage = NULL;
|
|
|
9119d9 |
int cellmem = VIR_DIV_UP(def->cpu->cells[i].mem, 1024);
|
|
|
9119d9 |
def->cpu->cells[i].mem = cellmem * 1024;
|
|
|
9119d9 |
virTristateSwitch memAccess = def->cpu->cells[i].memAccess;
|
|
|
9119d9 |
@@ -6604,7 +6605,6 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
|
|
|
9119d9 |
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) ||
|
|
|
9119d9 |
virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
|
|
|
9119d9 |
virDomainNumatuneMemMode mode;
|
|
|
9119d9 |
- virDomainHugePagePtr hugepage = NULL;
|
|
|
9119d9 |
const char *policy = NULL;
|
|
|
9119d9 |
|
|
|
9119d9 |
mode = virDomainNumatuneGetMode(def->numatune, i);
|
|
|
9119d9 |
@@ -6714,8 +6714,12 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
|
|
|
9119d9 |
virBufferAsprintf(&buf, ",policy=%s", policy);
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
- virCommandAddArg(cmd, "-object");
|
|
|
9119d9 |
- virCommandAddArgBuffer(cmd, &buf;;
|
|
|
9119d9 |
+ if (hugepage || nodemask) {
|
|
|
9119d9 |
+ virCommandAddArg(cmd, "-object");
|
|
|
9119d9 |
+ virCommandAddArgBuffer(cmd, &buf;;
|
|
|
9119d9 |
+ } else {
|
|
|
9119d9 |
+ virBufferFreeAndReset(&buf;;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
} else {
|
|
|
9119d9 |
if (memAccess) {
|
|
|
9119d9 |
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
9119d9 |
@@ -6735,12 +6739,10 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
|
|
|
9119d9 |
virBufferAdd(&buf, tmpmask, -1);
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
- if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) ||
|
|
|
9119d9 |
- virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
|
|
|
9119d9 |
+ if (hugepage || nodemask)
|
|
|
9119d9 |
virBufferAsprintf(&buf, ",memdev=ram-node%zu", i);
|
|
|
9119d9 |
- } else {
|
|
|
9119d9 |
+ else
|
|
|
9119d9 |
virBufferAsprintf(&buf, ",mem=%d", cellmem);
|
|
|
9119d9 |
- }
|
|
|
9119d9 |
|
|
|
9119d9 |
virCommandAddArgBuffer(cmd, &buf;;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages3.args b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages3.args
|
|
|
9119d9 |
index 27b3f8e..f81947e 100644
|
|
|
9119d9 |
--- a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages3.args
|
|
|
9119d9 |
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-pages3.args
|
|
|
9119d9 |
@@ -1,7 +1,6 @@
|
|
|
9119d9 |
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
|
|
9119d9 |
/usr/bin/qemu -S -M pc -m 1024 -smp 2 \
|
|
|
9119d9 |
--object memory-backend-ram,size=256M,id=ram-node0 \
|
|
|
9119d9 |
--numa node,nodeid=0,cpus=0,memdev=ram-node0 \
|
|
|
9119d9 |
+-numa node,nodeid=0,cpus=0,mem=256 \
|
|
|
9119d9 |
-object memory-backend-file,prealloc=yes,\
|
|
|
9119d9 |
mem-path=/dev/hugepages1G/libvirt/qemu,size=768M,id=ram-node1 \
|
|
|
9119d9 |
-numa node,nodeid=1,cpus=1,memdev=ram-node1 \
|
|
|
9119d9 |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode-no-memory.args b/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode-no-memory.args
|
|
|
9119d9 |
index b0e274c..2addf97 100644
|
|
|
9119d9 |
--- a/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode-no-memory.args
|
|
|
9119d9 |
+++ b/tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode-no-memory.args
|
|
|
9119d9 |
@@ -2,7 +2,6 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
|
|
9119d9 |
/usr/bin/kvm -S -M pc -m 64 -smp 2 \
|
|
|
9119d9 |
-object memory-backend-ram,size=32M,id=ram-node0,host-nodes=3,policy=preferred \
|
|
|
9119d9 |
-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
|
|
|
9119d9 |
--object memory-backend-ram,size=32M,id=ram-node1 \
|
|
|
9119d9 |
--numa node,nodeid=1,cpus=1,memdev=ram-node1 \
|
|
|
9119d9 |
+-numa node,nodeid=1,cpus=1,mem=32 \
|
|
|
9119d9 |
-nographic -monitor unix:/tmp/test-monitor,server,nowait \
|
|
|
9119d9 |
-no-acpi -boot c -usb -net none -serial none -parallel none
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.2.1
|
|
|
9119d9 |
|