virtinst: set dies in topology to 1

It is always permitted to set dies==1 regardless of architecture or
machine type. The only constraint is around setting values > 1, for
archs/machines that don't support the dies concept.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2021-10-29 12:58:03 +01:00 committed by Cole Robinson
parent 7b68fe1a5e
commit c1491ae142
4 changed files with 10 additions and 7 deletions

View File

@ -25,7 +25,7 @@
<vmport state="off"/>
</features>
<cpu>
<topology sockets="4" cores="1" threads="1"/>
<topology sockets="4" dies="1" cores="1" threads="1"/>
</cpu>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>

View File

@ -23,7 +23,7 @@
</hyperv>
</features>
<cpu>
<topology sockets="1" cores="4" threads="1"/>
<topology sockets="1" dies="1" cores="4" threads="1"/>
</cpu>
<clock offset="localtime"/>
<on_reboot>destroy</on_reboot>
@ -74,7 +74,7 @@
</hyperv>
</features>
<cpu>
<topology sockets="1" cores="4" threads="1"/>
<topology sockets="1" dies="1" cores="4" threads="1"/>
</cpu>
<clock offset="localtime"/>
<pm>

View File

@ -29,18 +29,18 @@ def test_misc_cpu_topology():
cpu.topology.sockets = "2"
cpu.set_topology_defaults(6)
def get_top(_c):
return [_c.topology.sockets, _c.topology.cores, _c.topology.threads]
assert get_top(cpu) == [2, 3, 1]
return [_c.topology.sockets, _c.topology.dies, _c.topology.cores, _c.topology.threads]
assert get_top(cpu) == [2, 1, 3, 1]
cpu = virtinst.DomainCpu(conn)
cpu.topology.cores = "4"
cpu.set_topology_defaults(9)
assert get_top(cpu) == [2, 4, 1]
assert get_top(cpu) == [2, 1, 4, 1]
cpu = virtinst.DomainCpu(conn)
cpu.topology.threads = "3"
cpu.set_topology_defaults(14)
assert get_top(cpu) == [4, 1, 3]
assert get_top(cpu) == [4, 1, 1, 3]
cpu = virtinst.DomainCpu(conn)
cpu.topology.sockets = 5

View File

@ -35,6 +35,9 @@ class _CPUTopology(XMLBuilder):
else:
self.sockets = vcpus // self.cores
if not self.dies:
self.dies = 1
if not self.cores:
if not self.threads:
self.cores = vcpus // self.sockets