diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2021-10-29 12:45:48 +0100 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2022-01-20 14:16:38 -0500 |
commit | e1c8866163a2861f79a08ce4e1487fc84b7d1ec1 (patch) | |
tree | 92877ef49e273aa74f65e8f1bdf66ed179e0da26 /virtinst/domain | |
parent | 552759bef49a27d49e6d981d51600cd7da34062e (diff) | |
download | virt-manager-e1c8866163a2861f79a08ce4e1487fc84b7d1ec1.tar.gz |
virtinst: validate that the CPU topology is sane
The product of sockets * dies * cores * threads must be equal to the
vCPU count. While libvirt and QEMU will report this error scenario,
it makes sense to catch it in virt-install, so we can test our local
logic for setting defaults for topology.
This exposes some inconsistent configurations in the test suite.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'virtinst/domain')
-rw-r--r-- | virtinst/domain/cpu.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/virtinst/domain/cpu.py b/virtinst/domain/cpu.py index 16f7a588..f2d0c79f 100644 --- a/virtinst/domain/cpu.py +++ b/virtinst/domain/cpu.py @@ -41,6 +41,18 @@ class _CPUTopology(XMLBuilder): if not self.threads: self.threads = vcpus // self.total_vcpus() + if self.total_vcpus() != vcpus: + raise ValueError(_("Total CPUs implied by topology " + "(sockets=%(sockets)d * dies=%(dies)d * cores=%(cores)d * threads=%(threads)d == %(total)d) " + "does not match vCPU count %(vcpus)d") % { + "sockets": self.sockets, + "dies": self.dies, + "cores": self.cores, + "threads": self.threads, + "total": self.total_vcpus(), + "vcpus": vcpus, + }) + return def total_vcpus(self): |