Historically we've used QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS as witness
that the topology must cover the maximum number ov vcpus. qemu started
to enforce this in qemu-2.5, thus we can now always do the check.
This change also requires aligning the topology in certain test files.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_validate.c | 42 ++++++++-----------
.../fd-memory-numa-topology2.args | 2 +-
.../fd-memory-numa-topology2.xml | 2 +-
.../fd-memory-numa-topology3.args | 2 +-
.../fd-memory-numa-topology3.xml | 2 +-
5 files changed, 22 insertions(+), 28 deletions(-)
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index c8937cad05..de3aebb439 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -759,6 +759,8 @@ qemuValidateDomainVCpuTopology(const virDomainDef *def, virQEMUCaps
*qemuCaps)
{
unsigned int maxCpus = virQEMUCapsGetMachineMaxCpus(qemuCaps, def->virtType,
def->os.machine);
+ unsigned int topologycpus;
+ unsigned int granularity;
if (virDomainDefGetVcpus(def) == 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -773,34 +775,26 @@ qemuValidateDomainVCpuTopology(const virDomainDef *def, virQEMUCaps
*qemuCaps)
return -1;
}
- /* QEMU 2.7 (detected via the availability of query-hotpluggable-cpus)
- * enforces stricter rules than previous versions when it comes to guest
- * CPU topology. Verify known constraints are respected */
- if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS)) {
- unsigned int topologycpus;
- unsigned int granularity;
-
- /* Starting from QEMU 2.5, max vCPU count and overall vCPU topology
- * must agree. We only actually enforce this with QEMU 2.7+, due
- * to the capability check above */
- if (virDomainDefGetVcpusTopology(def, &topologycpus) == 0) {
- if (topologycpus != virDomainDefGetVcpusMax(def)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("CPU topology doesn't match maximum vcpu
count"));
- return -1;
- }
- }
-
- /* vCPU hotplug granularity must be respected */
- granularity = qemuValidateDefGetVcpuHotplugGranularity(def);
- if ((virDomainDefGetVcpus(def) % granularity) != 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("vCPUs count must be a multiple of the vCPU hotplug
granularity (%1$u)"),
- granularity);
+ /* Starting from QEMU 2.5, max vCPU count and overall vCPU topology
+ * must agree. We only actually enforce this with QEMU 2.7+, due
+ * to the capability check above */
+ if (virDomainDefGetVcpusTopology(def, &topologycpus) == 0) {
+ if (topologycpus != virDomainDefGetVcpusMax(def)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("CPU topology doesn't match maximum vcpu
count"));
return -1;
}
}
+ /* vCPU hotplug granularity must be respected */
+ granularity = qemuValidateDefGetVcpuHotplugGranularity(def);
+ if ((virDomainDefGetVcpus(def) % granularity) != 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("vCPUs count must be a multiple of the vCPU hotplug
granularity (%1$u)"),
+ granularity);
+ return -1;
+ }
+
if (ARCH_IS_X86(def->os.arch) &&
virDomainDefGetVcpusMax(def) > QEMU_MAX_VCPUS_WITHOUT_EIM) {
if (!qemuDomainIsQ35(def)) {
diff --git a/tests/qemuxml2argvdata/fd-memory-numa-topology2.args
b/tests/qemuxml2argvdata/fd-memory-numa-topology2.args
index eb88b27e16..7313dabf78 100644
--- a/tests/qemuxml2argvdata/fd-memory-numa-topology2.args
+++ b/tests/qemuxml2argvdata/fd-memory-numa-topology2.args
@@ -14,7 +14,7 @@
XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-instance-00000092/.config \
-accel kvm \
-m size=29360128k \
-overcommit mem-lock=off \
--smp 20,sockets=1,cores=8,threads=1 \
+-smp 20,sockets=1,cores=20,threads=1 \
-object
memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node0,share=off,prealloc=on,size=15032385536
\
-numa node,nodeid=0,cpus=0-7,cpus=16-19,memdev=ram-node0 \
-object
memory-backend-file,id=ram-node1,mem-path=/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node1,share=on,prealloc=on,size=15032385536
\
diff --git a/tests/qemuxml2argvdata/fd-memory-numa-topology2.xml
b/tests/qemuxml2argvdata/fd-memory-numa-topology2.xml
index 5b84a49796..1572010ad8 100644
--- a/tests/qemuxml2argvdata/fd-memory-numa-topology2.xml
+++ b/tests/qemuxml2argvdata/fd-memory-numa-topology2.xml
@@ -14,7 +14,7 @@
<boot dev='hd'/>
</os>
<cpu>
- <topology sockets='1' dies='1' cores='8'
threads='1'/>
+ <topology sockets='1' dies='1' cores='20'
threads='1'/>
<numa>
<cell id='0' cpus='0-7,16-19' memory='14680064'
unit='KiB'/>
<cell id='1' cpus='8-15' memory='14680064'
unit='KiB' memAccess='shared'/>
diff --git a/tests/qemuxml2argvdata/fd-memory-numa-topology3.args
b/tests/qemuxml2argvdata/fd-memory-numa-topology3.args
index c10140a55d..f5d2aaf91b 100644
--- a/tests/qemuxml2argvdata/fd-memory-numa-topology3.args
+++ b/tests/qemuxml2argvdata/fd-memory-numa-topology3.args
@@ -14,7 +14,7 @@
XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-instance-00000092/.config \
-accel kvm \
-m size=44040192k \
-overcommit mem-lock=off \
--smp 32,sockets=1,cores=24,threads=1 \
+-smp 32,sockets=1,cores=32,threads=1 \
-object
memory-backend-file,id=ram-node0,mem-path=/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node0,share=on,prealloc=on,size=15032385536
\
-numa node,nodeid=0,cpus=0-1,cpus=6-31,memdev=ram-node0 \
-object
memory-backend-file,id=ram-node1,mem-path=/var/lib/libvirt/qemu/ram/-1-instance-00000092/ram-node1,share=on,prealloc=on,size=15032385536
\
diff --git a/tests/qemuxml2argvdata/fd-memory-numa-topology3.xml
b/tests/qemuxml2argvdata/fd-memory-numa-topology3.xml
index 1b8fd7dfee..36a6b5c155 100644
--- a/tests/qemuxml2argvdata/fd-memory-numa-topology3.xml
+++ b/tests/qemuxml2argvdata/fd-memory-numa-topology3.xml
@@ -14,7 +14,7 @@
<boot dev='hd'/>
</os>
<cpu>
- <topology sockets='1' dies='1' cores='24'
threads='1'/>
+ <topology sockets='1' dies='1' cores='32'
threads='1'/>
<numa>
<cell id='0' cpus='0-1,6-31' memory='14680064'
unit='KiB'/>
<cell id='1' cpus='2-3' memory='14680064'
unit='KiB' memAccess='shared'/>
--
2.41.0