When generating memory for guest NUMA memory-backend-* might be
used. This means, we may need to generate thread-context objects
too.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_command.c | 10 ++++++++++
.../hugepages-memaccess.x86_64-latest.args | 12 ++++++++----
.../hugepages-memaccess2.x86_64-latest.args | 12 ++++++++----
.../hugepages-shared.x86_64-latest.args | 12 ++++++++----
.../memfd-memory-default-hugepage.x86_64-latest.args | 3 ++-
.../memfd-memory-numa.x86_64-latest.args | 3 ++-
.../numatune-memnode.x86_64-latest.args | 9 ++++++---
7 files changed, 44 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 90bc537b33..a0f2644ba1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7325,6 +7325,16 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg,
ssize_t initiator = virDomainNumaGetNodeInitiator(def->numa, i);
if (needBackend) {
+ g_autoptr(virJSONValue) tcProps = NULL;
+
+ if (qemuBuildThreadContextProps(&tcProps, &nodeBackends[i], priv)
< 0)
+ goto cleanup;
+
+ if (tcProps &&
+ qemuBuildObjectCommandlineFromJSON(cmd, tcProps,
+ priv->qemuCaps) < 0)
+ goto cleanup;
+
if (qemuBuildObjectCommandlineFromJSON(cmd, nodeBackends[i],
priv->qemuCaps) < 0)
goto cleanup;
diff --git a/tests/qemuxml2argvdata/hugepages-memaccess.x86_64-latest.args
b/tests/qemuxml2argvdata/hugepages-memaccess.x86_64-latest.args
index 55a8d899b7..9db085fd1d 100644
--- a/tests/qemuxml2argvdata/hugepages-memaccess.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/hugepages-memaccess.x86_64-latest.args
@@ -16,13 +16,17 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
-m size=4194304k,slots=16,maxmem=8388608k \
-overcommit mem-lock=off \
-smp 4,sockets=4,cores=1,threads=1 \
--object
'{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":[0,1,2,3]}'
\
+-object
'{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-ram-node0"}'
\
-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
--object
'{"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node1","node-affinity":[0,1,2,3]}'
\
+-object
'{"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-ram-node1"}'
\
-numa node,nodeid=1,cpus=1,memdev=ram-node1 \
--object
'{"qom-type":"memory-backend-file","id":"ram-node2","mem-path":"/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node2","node-affinity":[0,1,2,3]}'
\
+-object
'{"qom-type":"memory-backend-file","id":"ram-node2","mem-path":"/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-ram-node2"}'
\
-numa node,nodeid=2,cpus=2,memdev=ram-node2 \
--object
'{"qom-type":"memory-backend-file","id":"ram-node3","mem-path":"/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"size":1073741824,"host-nodes":[3],"policy":"bind"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node3","node-affinity":[3]}'
\
+-object
'{"qom-type":"memory-backend-file","id":"ram-node3","mem-path":"/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"size":1073741824,"host-nodes":[3],"policy":"bind","prealloc-context":"tc-ram-node3"}'
\
-numa node,nodeid=3,cpus=3,memdev=ram-node3 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-display none \
diff --git a/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args
b/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args
index 187c0ab214..37f6dfabe9 100644
--- a/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/hugepages-memaccess2.x86_64-latest.args
@@ -16,13 +16,17 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
-m size=4194304k,slots=16,maxmem=8388608k \
-overcommit mem-lock=off \
-smp 4,sockets=4,cores=1,threads=1 \
--object
'{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node0","share":false,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":[0,1,2,3]}'
\
+-object
'{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node0","share":false,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-ram-node0"}'
\
-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
--object
'{"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node1","node-affinity":[0,1,2,3]}'
\
+-object
'{"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-ram-node1"}'
\
-numa node,nodeid=1,cpus=1,memdev=ram-node1 \
--object
'{"qom-type":"memory-backend-file","id":"ram-node2","mem-path":"/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node2","share":false,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node2","node-affinity":[0,1,2,3]}'
\
+-object
'{"qom-type":"memory-backend-file","id":"ram-node2","mem-path":"/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node2","share":false,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-ram-node2"}'
\
-numa node,nodeid=2,cpus=2,memdev=ram-node2 \
--object
'{"qom-type":"memory-backend-file","id":"ram-node3","mem-path":"/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node3","share":false,"size":1073741824,"host-nodes":[3],"policy":"bind"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node3","node-affinity":[3]}'
\
+-object
'{"qom-type":"memory-backend-file","id":"ram-node3","mem-path":"/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/ram-node3","share":false,"size":1073741824,"host-nodes":[3],"policy":"bind","prealloc-context":"tc-ram-node3"}'
\
-numa node,nodeid=3,cpus=3,memdev=ram-node3 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-display none \
diff --git a/tests/qemuxml2argvdata/hugepages-shared.x86_64-latest.args
b/tests/qemuxml2argvdata/hugepages-shared.x86_64-latest.args
index f4fea870fc..4e7ffb50a5 100644
--- a/tests/qemuxml2argvdata/hugepages-shared.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/hugepages-shared.x86_64-latest.args
@@ -16,13 +16,17 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
-m 4096 \
-overcommit mem-lock=off \
-smp 4,sockets=4,cores=1,threads=1 \
--object
'{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","prealloc":true,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":[0,1,2,3]}'
\
+-object
'{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","prealloc":true,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-ram-node0"}'
\
-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
--object
'{"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node1","node-affinity":[0,1,2,3]}'
\
+-object
'{"qom-type":"memory-backend-file","id":"ram-node1","mem-path":"/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1","share":true,"prealloc":true,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-ram-node1"}'
\
-numa node,nodeid=1,cpus=1,memdev=ram-node1 \
--object
'{"qom-type":"memory-backend-file","id":"ram-node2","mem-path":"/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node2","node-affinity":[0,1,2,3]}'
\
+-object
'{"qom-type":"memory-backend-file","id":"ram-node2","mem-path":"/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","share":false,"prealloc":true,"size":1073741824,"host-nodes":[0,1,2,3],"policy":"bind","prealloc-context":"tc-ram-node2"}'
\
-numa node,nodeid=2,cpus=2,memdev=ram-node2 \
--object
'{"qom-type":"memory-backend-file","id":"ram-node3","mem-path":"/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","prealloc":true,"size":1073741824,"host-nodes":[3],"policy":"bind"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node3","node-affinity":[3]}'
\
+-object
'{"qom-type":"memory-backend-file","id":"ram-node3","mem-path":"/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1","prealloc":true,"size":1073741824,"host-nodes":[3],"policy":"bind","prealloc-context":"tc-ram-node3"}'
\
-numa node,nodeid=3,cpus=3,memdev=ram-node3 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-display none \
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 383635c8cd..f516c02bea 100644
--- a/tests/qemuxml2argvdata/memfd-memory-default-hugepage.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/memfd-memory-default-hugepage.x86_64-latest.args
@@ -16,7 +16,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-instance-00000092/.config \
-m 14336 \
-overcommit mem-lock=off \
-smp 8,sockets=1,dies=1,cores=8,threads=1 \
--object
'{"qom-type":"memory-backend-memfd","id":"ram-node0","hugetlb":true,"hugetlbsize":2097152,"share":true,"prealloc":true,"size":15032385536,"host-nodes":[3],"policy":"preferred"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":[3]}'
\
+-object
'{"qom-type":"memory-backend-memfd","id":"ram-node0","hugetlb":true,"hugetlbsize":2097152,"share":true,"prealloc":true,"size":15032385536,"host-nodes":[3],"policy":"preferred","prealloc-context":"tc-ram-node0"}'
\
-numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
-uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \
-display none \
diff --git a/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args
b/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args
index 68bbd73551..c51bb6f828 100644
--- a/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/memfd-memory-numa.x86_64-latest.args
@@ -16,7 +16,8 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-instance-00000092/.config \
-m size=14680064k,slots=16,maxmem=1099511627776k \
-overcommit mem-lock=off \
-smp 8,sockets=1,dies=1,cores=8,threads=1 \
--object
'{"qom-type":"memory-backend-memfd","id":"ram-node0","hugetlb":true,"hugetlbsize":2097152,"share":true,"prealloc":true,"prealloc-threads":8,"size":15032385536,"host-nodes":[3],"policy":"preferred"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":[3]}'
\
+-object
'{"qom-type":"memory-backend-memfd","id":"ram-node0","hugetlb":true,"hugetlbsize":2097152,"share":true,"prealloc":true,"prealloc-threads":8,"size":15032385536,"host-nodes":[3],"policy":"preferred","prealloc-context":"tc-ram-node0"}'
\
-numa node,nodeid=0,cpus=0-7,memdev=ram-node0 \
-uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \
-display none \
diff --git a/tests/qemuxml2argvdata/numatune-memnode.x86_64-latest.args
b/tests/qemuxml2argvdata/numatune-memnode.x86_64-latest.args
index 7cb7e659a4..f4ef91006f 100644
--- a/tests/qemuxml2argvdata/numatune-memnode.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/numatune-memnode.x86_64-latest.args
@@ -16,11 +16,14 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest/.config \
-m 24105 \
-overcommit mem-lock=off \
-smp 32,sockets=32,cores=1,threads=1 \
--object
'{"qom-type":"memory-backend-ram","id":"ram-node0","size":20971520,"host-nodes":[3],"policy":"preferred"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node0","node-affinity":[3]}'
\
+-object
'{"qom-type":"memory-backend-ram","id":"ram-node0","size":20971520,"host-nodes":[3],"policy":"preferred","prealloc-context":"tc-ram-node0"}'
\
-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
--object
'{"qom-type":"memory-backend-ram","id":"ram-node1","size":676331520,"host-nodes":[0,1,2,3,4,5,6,7],"policy":"bind"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node1","node-affinity":[0,1,2,3,4,5,6,7]}'
\
+-object
'{"qom-type":"memory-backend-ram","id":"ram-node1","size":676331520,"host-nodes":[0,1,2,3,4,5,6,7],"policy":"bind","prealloc-context":"tc-ram-node1"}'
\
-numa node,nodeid=1,cpus=1-27,cpus=29,memdev=ram-node1 \
--object
'{"qom-type":"memory-backend-ram","id":"ram-node2","size":24578621440,"host-nodes":[1,2,5,7],"policy":"bind"}'
\
+-object
'{"qom-type":"thread-context","id":"tc-ram-node2","node-affinity":[1,2,5,7]}'
\
+-object
'{"qom-type":"memory-backend-ram","id":"ram-node2","size":24578621440,"host-nodes":[1,2,5,7],"policy":"bind","prealloc-context":"tc-ram-node2"}'
\
-numa node,nodeid=2,cpus=28,cpus=30-31,memdev=ram-node2 \
-uuid 9f4b6512-e73a-4a25-93e8-5307802821ce \
-display none \
--
2.37.4