mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
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>
This commit is contained in:
parent
552759bef4
commit
e1c8866163
@ -37,7 +37,7 @@
|
|||||||
<cpu mode="custom" match="exact">
|
<cpu mode="custom" match="exact">
|
||||||
<model fallback="forbid">Broadwell</model>
|
<model fallback="forbid">Broadwell</model>
|
||||||
<vendor>Intel</vendor>
|
<vendor>Intel</vendor>
|
||||||
<topology sockets="2" dies="1" cores="2" threads="2"/>
|
<topology sockets="2" dies="1" cores="2" threads="1"/>
|
||||||
<feature policy="require" name="vme"/>
|
<feature policy="require" name="vme"/>
|
||||||
<feature policy="require" name="ss"/>
|
<feature policy="require" name="ss"/>
|
||||||
<feature policy="require" name="f16c"/>
|
<feature policy="require" name="f16c"/>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<access mode="shared"/>
|
<access mode="shared"/>
|
||||||
<source type="anonymous"/>
|
<source type="anonymous"/>
|
||||||
</memoryBacking>
|
</memoryBacking>
|
||||||
<vcpu current="3" placement="auto">4</vcpu>
|
<vcpu current="3" placement="auto">6</vcpu>
|
||||||
<sysinfo type="smbios">
|
<sysinfo type="smbios">
|
||||||
<bios>
|
<bios>
|
||||||
<entry name="vendor">Acme LLC</entry>
|
<entry name="vendor">Acme LLC</entry>
|
||||||
|
@ -467,7 +467,7 @@ c = vinst.add_category("xml-comparsion", "--connect %(URI-KVM)s --noautoconsole
|
|||||||
c.add_compare("""
|
c.add_compare("""
|
||||||
--memory 1024
|
--memory 1024
|
||||||
--uuid 12345678-12F4-1234-1234-123456789AFA
|
--uuid 12345678-12F4-1234-1234-123456789AFA
|
||||||
--vcpus 4,cores=2,threads=2,dies=1,sockets=2 --cpuset=1,3-5
|
--vcpus 4,cores=2,threads=1,dies=1,sockets=2 --cpuset=1,3-5
|
||||||
--cpu host-copy
|
--cpu host-copy
|
||||||
--description \"foobar & baz\"
|
--description \"foobar & baz\"
|
||||||
--boot uefi,smbios_mode=emulate,boot1.dev=hd,boot.dev=network,initarg1=bar=baz,initarg=foo
|
--boot uefi,smbios_mode=emulate,boot1.dev=hd,boot.dev=network,initarg1=bar=baz,initarg=foo
|
||||||
@ -573,7 +573,7 @@ memnode0.cellid=1,memnode0.mode=strict,memnode0.nodeset=2
|
|||||||
|
|
||||||
# Test the implied defaults for gl=yes setting virgl=on
|
# Test the implied defaults for gl=yes setting virgl=on
|
||||||
c.add_compare("""
|
c.add_compare("""
|
||||||
--vcpus vcpu.current=3,maxvcpus=4,vcpu.placement=auto
|
--vcpus vcpu.current=3,maxvcpus=6,vcpu.placement=auto
|
||||||
--memory hotplugmemorymax=2048,hotplugmemoryslots=2
|
--memory hotplugmemorymax=2048,hotplugmemoryslots=2
|
||||||
--disk none
|
--disk none
|
||||||
--features apic.eoi=off,hap=on,hyperv.synic.state=on,hyperv.reset.state=off,hyperv.spinlocks.state=on,hyperv.spinlocks.retries=5678,pae=on,pmu.state=on,pvspinlock.state=off,smm.state=off,viridian=on,vmcoreinfo.state=on,vmport.state=off,kvm.hidden.state=on,hyperv.vapic.state=off,hyperv.relaxed.state=off,gic.version=host,kvm.hint-dedicated.state=on,kvm.poll-control.state=on,ioapic.driver=qemu
|
--features apic.eoi=off,hap=on,hyperv.synic.state=on,hyperv.reset.state=off,hyperv.spinlocks.state=on,hyperv.spinlocks.retries=5678,pae=on,pmu.state=on,pvspinlock.state=off,smm.state=off,viridian=on,vmcoreinfo.state=on,vmport.state=off,kvm.hidden.state=on,hyperv.vapic.state=off,hyperv.relaxed.state=off,gic.version=host,kvm.hint-dedicated.state=on,kvm.poll-control.state=on,ioapic.driver=qemu
|
||||||
|
@ -42,14 +42,22 @@ def test_misc_cpu_topology():
|
|||||||
|
|
||||||
cpu = virtinst.DomainCpu(conn)
|
cpu = virtinst.DomainCpu(conn)
|
||||||
cpu.topology.cores = "4"
|
cpu.topology.cores = "4"
|
||||||
cpu.set_topology_defaults(9)
|
cpu.set_topology_defaults(8)
|
||||||
assert get_top(cpu) == [2, 1, 4, 1]
|
assert get_top(cpu) == [2, 1, 4, 1]
|
||||||
|
|
||||||
cpu = virtinst.DomainCpu(conn)
|
cpu = virtinst.DomainCpu(conn)
|
||||||
cpu.topology.threads = "3"
|
cpu.topology.threads = "3"
|
||||||
cpu.set_topology_defaults(14)
|
cpu.set_topology_defaults(12)
|
||||||
assert get_top(cpu) == [4, 1, 1, 3]
|
assert get_top(cpu) == [4, 1, 1, 3]
|
||||||
|
|
||||||
|
cpu = virtinst.DomainCpu(conn)
|
||||||
|
cpu.topology.threads = "3"
|
||||||
|
try:
|
||||||
|
cpu.set_topology_defaults(14)
|
||||||
|
assert False, "Topology unexpectedly validated"
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
cpu = virtinst.DomainCpu(conn)
|
cpu = virtinst.DomainCpu(conn)
|
||||||
cpu.topology.sockets = 5
|
cpu.topology.sockets = 5
|
||||||
cpu.topology.cores = 2
|
cpu.topology.cores = 2
|
||||||
|
@ -41,6 +41,18 @@ class _CPUTopology(XMLBuilder):
|
|||||||
if not self.threads:
|
if not self.threads:
|
||||||
self.threads = vcpus // self.total_vcpus()
|
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
|
return
|
||||||
|
|
||||||
def total_vcpus(self):
|
def total_vcpus(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user