mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
virtinst: allow to force create topology from scratch
When setting CPU defaults we want to force create the topology even if the user has not specified anything. In particular this allows for overriding the QEMU defaults, to expose vCPUs as cores instead of sockets which is a much saner default for Windows. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
9a578e1ac5
commit
883419c214
@ -30,6 +30,10 @@ def test_misc_cpu_topology():
|
||||
cpu.set_topology_defaults(6)
|
||||
assert cpu.topology.sockets is None
|
||||
|
||||
cpu = virtinst.DomainCpu(conn)
|
||||
cpu.set_topology_defaults(6, create=True)
|
||||
assert get_top(cpu) == [1, 1, 6, 1]
|
||||
|
||||
cpu = virtinst.DomainCpu(conn)
|
||||
cpu.topology.sockets = "2"
|
||||
cpu.set_topology_defaults(6)
|
||||
|
@ -401,13 +401,14 @@ class DomainCpu(XMLBuilder):
|
||||
"""
|
||||
return bool(self.topology.get_xml())
|
||||
|
||||
def set_topology_defaults(self, vcpus):
|
||||
def set_topology_defaults(self, vcpus, create=False):
|
||||
"""
|
||||
Fill in unset topology values, using the passed vcpus count.
|
||||
Will not set topology from scratch, this just fills in missing
|
||||
topology values.
|
||||
If @create is False, this will not set topology from scratch,
|
||||
just fill in missing topology values.
|
||||
If @create is True, this will create topology from scratch.
|
||||
"""
|
||||
if not self.has_topology():
|
||||
if not self.has_topology() and not create:
|
||||
return
|
||||
self.topology.set_defaults_from_vcpus(vcpus)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user