In 88957116c9 I've switched to -machine memory-backend=ID and
-object memory-backend-* because QEMU is obsoleting -mem-path
and -mem-prealloc. However, what I did not foresee was that using
-machine memory-backend in combination with -numa is not allowed
in QEMU. This was reported upstream and fortunately not released
yet.
The solution is to generate -machine memory-backend=ID iff there
are no guest NUMA nodes, and require use of -numa memdev= for new
enough QEMUs.
Reported-by: Masayoshi Mizuma <msys.mizuma(a)gmail.com>
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_command.c | 11 +++++++++--
.../hugepages-nvdimm.x86_64-latest.args | 6 +-----
.../memfd-memory-default-hugepage.x86_64-latest.args | 5 +----
.../memfd-memory-numa.x86_64-latest.args | 5 +----
.../memory-hotplug-nvdimm-access.x86_64-latest.args | 4 +---
.../memory-hotplug-nvdimm-align.x86_64-latest.args | 4 +---
.../memory-hotplug-nvdimm-label.x86_64-latest.args | 4 +---
.../memory-hotplug-nvdimm-pmem.x86_64-latest.args | 4 +---
.../memory-hotplug-nvdimm-readonly.x86_64-latest.args | 4 +---
.../memory-hotplug-nvdimm.x86_64-latest.args | 4 +---
.../qemuxml2argvdata/numatune-hmat.x86_64-latest.args | 4 +---
.../vhost-user-fs-fd-memory.x86_64-latest.args | 4 +---
.../vhost-user-fs-hugepages.x86_64-latest.args | 5 +----
.../vhost-user-gpu-secondary.x86_64-latest.args | 3 +--
.../vhost-user-vga.x86_64-latest.args | 3 +--
15 files changed, 23 insertions(+), 47 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 476cf6972e..def79d2f20 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7049,7 +7049,8 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
defaultRAMid = virQEMUCapsGetMachineDefaultRAMid(qemuCaps,
def->virtType,
def->os.machine);
- if (defaultRAMid)
+ if (defaultRAMid &&
+ !virDomainNumaGetNodeCount(def->numa))
virBufferAsprintf(&buf, ",memory-backend=%s", defaultRAMid);
virCommandAddArgBuffer(cmd, &buf);
@@ -7216,7 +7217,8 @@ qemuBuildMemCommandLine(virCommandPtr cmd,
def->os.machine);
if (defaultRAMid) {
- qemuBuildMemCommandLineMemoryDefaultBackend(cmd, def, priv, defaultRAMid);
+ if (!virDomainNumaGetNodeCount(def->numa))
+ qemuBuildMemCommandLineMemoryDefaultBackend(cmd, def, priv, defaultRAMid);
} else {
if (def->mem.allocation == VIR_DOMAIN_MEMORY_ALLOCATION_IMMEDIATE) {
virCommandAddArgList(cmd, "-mem-prealloc", NULL);
@@ -7428,6 +7430,11 @@ qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg,
hmat = true;
}
+ if (virQEMUCapsGetMachineDefaultRAMid(qemuCaps,
+ def->virtType,
+ def->os.machine))
+ needBackend = true;
+
nodeBackends = g_new0(virBuffer, ncells);
/* using of -numa memdev= cannot be combined with -numa mem=, thus we
diff --git a/tests/qemuxml2argvdata/hugepages-nvdimm.x86_64-latest.args
b/tests/qemuxml2argvdata/hugepages-nvdimm.x86_64-latest.args
index 192b033e9e..969bb713b5 100644
--- a/tests/qemuxml2argvdata/hugepages-nvdimm.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/hugepages-nvdimm.x86_64-latest.args
@@ -12,13 +12,9 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
--machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on,\
-memory-backend=pc.ram \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on \
-cpu qemu64 \
-m size=1048576k,slots=16,maxmem=1099511627776k \
--object memory-backend-file,id=pc.ram,\
-mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=yes,prealloc=yes,\
-size=1073741824 \
-overcommit mem-lock=off \
-smp 2,sockets=2,dies=1,cores=1,threads=1 \
-object memory-backend-file,id=ram-node0,\
diff --git a/tests/qemuxml2argvdata/memfd-memory-default-hugepage.x86_64-latest.args
b/tests/qemuxml2argvdata/memfd-memory-default-hugepage.x86_64-latest.args
index b43e7d9c3c..ef15e2e97e 100644
--- a/tests/qemuxml2argvdata/memfd-memory-default-hugepage.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/memfd-memory-default-hugepage.x86_64-latest.args
@@ -12,12 +12,9 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-instance-00000092/master-key.aes \
--machine pc-i440fx-2.3,accel=kvm,usb=off,dump-guest-core=off,\
-memory-backend=pc.ram \
+-machine pc-i440fx-2.3,accel=kvm,usb=off,dump-guest-core=off \
-cpu qemu64 \
-m 14336 \
--object memory-backend-memfd,id=pc.ram,hugetlb=yes,hugetlbsize=2097152,\
-share=yes,prealloc=yes,size=15032385536 \
-overcommit mem-lock=off \
-smp 8,sockets=1,dies=1,cores=8,threads=1 \
-object memory-backend-memfd,id=ram-node0,hugetlb=yes,hugetlbsize=2097152,\
diff --git a/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args
b/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args
index b43e7d9c3c..ef15e2e97e 100644
--- a/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args
@@ -12,12 +12,9 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-instance-00000092/master-key.aes \
--machine pc-i440fx-2.3,accel=kvm,usb=off,dump-guest-core=off,\
-memory-backend=pc.ram \
+-machine pc-i440fx-2.3,accel=kvm,usb=off,dump-guest-core=off \
-cpu qemu64 \
-m 14336 \
--object memory-backend-memfd,id=pc.ram,hugetlb=yes,hugetlbsize=2097152,\
-share=yes,prealloc=yes,size=15032385536 \
-overcommit mem-lock=off \
-smp 8,sockets=1,dies=1,cores=8,threads=1 \
-object memory-backend-memfd,id=ram-node0,hugetlb=yes,hugetlbsize=2097152,\
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-access.x86_64-latest.args
b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-access.x86_64-latest.args
index c5c5befdd5..8d3fa2e867 100644
--- a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-access.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-access.x86_64-latest.args
@@ -12,11 +12,9 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
--machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on,\
-memory-backend=pc.ram \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on \
-cpu qemu64 \
-m size=219136k,slots=16,maxmem=1099511627776k \
--object memory-backend-ram,id=pc.ram,size=224395264 \
-overcommit mem-lock=off \
-smp 2,sockets=2,dies=1,cores=1,threads=1 \
-object memory-backend-ram,id=ram-node0,size=224395264 \
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.x86_64-latest.args
b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.x86_64-latest.args
index 418bf1158d..4f22f78277 100644
--- a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-align.x86_64-latest.args
@@ -12,11 +12,9 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
--machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on,\
-memory-backend=pc.ram \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on \
-cpu qemu64 \
-m size=219136k,slots=16,maxmem=1099511627776k \
--object memory-backend-ram,id=pc.ram,size=224395264 \
-overcommit mem-lock=off \
-smp 2,sockets=2,dies=1,cores=1,threads=1 \
-object memory-backend-ram,id=ram-node0,size=224395264 \
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-label.x86_64-latest.args
b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-label.x86_64-latest.args
index 66477a2b09..53dda234a2 100644
--- a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-label.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-label.x86_64-latest.args
@@ -12,11 +12,9 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
--machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on,\
-memory-backend=pc.ram \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on \
-cpu qemu64 \
-m size=219136k,slots=16,maxmem=1099511627776k \
--object memory-backend-ram,id=pc.ram,size=224395264 \
-overcommit mem-lock=off \
-smp 2,sockets=2,dies=1,cores=1,threads=1 \
-object memory-backend-ram,id=ram-node0,size=224395264 \
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.x86_64-latest.args
b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.x86_64-latest.args
index 759d749c2e..cac02a6f6d 100644
--- a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-pmem.x86_64-latest.args
@@ -12,11 +12,9 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
--machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on,\
-memory-backend=pc.ram \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on \
-cpu qemu64 \
-m size=219136k,slots=16,maxmem=1099511627776k \
--object memory-backend-ram,id=pc.ram,size=224395264 \
-overcommit mem-lock=off \
-smp 2,sockets=2,dies=1,cores=1,threads=1 \
-object memory-backend-ram,id=ram-node0,size=224395264 \
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-readonly.x86_64-latest.args
b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-readonly.x86_64-latest.args
index b195b8625c..5e44496e39 100644
--- a/tests/qemuxml2argvdata/memory-hotplug-nvdimm-readonly.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm-readonly.x86_64-latest.args
@@ -12,11 +12,9 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
--machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on,\
-memory-backend=pc.ram \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on \
-cpu qemu64 \
-m size=219136k,slots=16,maxmem=1099511627776k \
--object memory-backend-ram,id=pc.ram,size=224395264 \
-overcommit mem-lock=off \
-smp 2,sockets=2,dies=1,cores=1,threads=1 \
-object memory-backend-ram,id=ram-node0,size=224395264 \
diff --git a/tests/qemuxml2argvdata/memory-hotplug-nvdimm.x86_64-latest.args
b/tests/qemuxml2argvdata/memory-hotplug-nvdimm.x86_64-latest.args
index ae416d7c7f..94f8444d95 100644
--- a/tests/qemuxml2argvdata/memory-hotplug-nvdimm.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/memory-hotplug-nvdimm.x86_64-latest.args
@@ -12,11 +12,9 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
--machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on,\
-memory-backend=pc.ram \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on \
-cpu qemu64 \
-m size=1048576k,slots=16,maxmem=1099511627776k \
--object memory-backend-ram,id=pc.ram,size=1073741824 \
-overcommit mem-lock=off \
-smp 2,sockets=2,dies=1,cores=1,threads=1 \
-object memory-backend-ram,id=ram-node0,size=1073741824 \
diff --git a/tests/qemuxml2argvdata/numatune-hmat.x86_64-latest.args
b/tests/qemuxml2argvdata/numatune-hmat.x86_64-latest.args
index be4a9ed871..c52015caa8 100644
--- a/tests/qemuxml2argvdata/numatune-hmat.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/numatune-hmat.x86_64-latest.args
@@ -12,11 +12,9 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest/master-key.aes \
--machine pc,accel=tcg,usb=off,dump-guest-core=off,hmat=on,\
-memory-backend=pc.ram \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off,hmat=on \
-cpu qemu64 \
-m 12288 \
--object memory-backend-ram,id=pc.ram,size=12884901888 \
-overcommit mem-lock=off \
-smp 12,sockets=12,cores=1,threads=1 \
-object memory-backend-ram,id=ram-node0,size=2147483648 \
diff --git a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args
b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args
index 13359c91fe..dd5f68abc5 100644
--- a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.x86_64-latest.args
@@ -12,11 +12,9 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-guest/master-key.aes \
--machine pc,accel=kvm,usb=off,dump-guest-core=off,memory-backend=pc.ram \
+-machine pc,accel=kvm,usb=off,dump-guest-core=off \
-cpu qemu64 \
-m 14336 \
--object memory-backend-file,id=pc.ram,\
-mem-path=/var/lib/libvirt/qemu/ram/-1-guest/pc.ram,share=yes,size=15032385536 \
-overcommit mem-lock=off \
-smp 2,sockets=2,cores=1,threads=1 \
-object memory-backend-file,id=ram-node0,\
diff --git a/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args
b/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args
index 59f45d466b..e4f5db7a63 100644
--- a/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/vhost-user-fs-hugepages.x86_64-latest.args
@@ -12,12 +12,9 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-guest/master-key.aes \
--machine q35,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \
+-machine q35,accel=tcg,usb=off,dump-guest-core=off \
-cpu qemu64 \
-m 2048 \
--object memory-backend-file,id=pc.ram,\
-mem-path=/dev/hugepages2M/libvirt/qemu/-1-guest,share=yes,prealloc=yes,\
-size=2147483648 \
-overcommit mem-lock=off \
-smp 2,sockets=2,cores=1,threads=1 \
-object memory-backend-file,id=ram-node0,\
diff --git a/tests/qemuxml2argvdata/vhost-user-gpu-secondary.x86_64-latest.args
b/tests/qemuxml2argvdata/vhost-user-gpu-secondary.x86_64-latest.args
index e7d3315b8f..e99a5342dc 100644
--- a/tests/qemuxml2argvdata/vhost-user-gpu-secondary.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/vhost-user-gpu-secondary.x86_64-latest.args
@@ -12,10 +12,9 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
--machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
-cpu qemu64 \
-m 214 \
--object memory-backend-memfd,id=pc.ram,share=yes,size=224395264 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
-object memory-backend-memfd,id=ram-node0,share=yes,size=224395264 \
diff --git a/tests/qemuxml2argvdata/vhost-user-vga.x86_64-latest.args
b/tests/qemuxml2argvdata/vhost-user-vga.x86_64-latest.args
index df5b1b481d..277bf8c646 100644
--- a/tests/qemuxml2argvdata/vhost-user-vga.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/vhost-user-vga.x86_64-latest.args
@@ -12,10 +12,9 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
--machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
-cpu qemu64 \
-m 214 \
--object memory-backend-memfd,id=pc.ram,share=yes,size=224395264 \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
-object memory-backend-memfd,id=ram-node0,share=yes,size=224395264 \
--
2.26.2