From e1c8866163a2861f79a08ce4e1487fc84b7d1ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Fri, 29 Oct 2021 12:45:48 +0100 Subject: virtinst: validate that the CPU topology is sane MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é --- virtinst/domain/cpu.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'virtinst/domain') 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): -- cgit v1.2.1