Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit e1fe04e

Browse files
committed
Pass type to util.get_max_vcpus. Gives accurate value if ex. installing kvm guest on qemu connection.
1 parent 0692907 commit e1fe04e

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

virtinst/Guest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ def set_uuid(self, val):
602602
def get_vcpus(self):
603603
return self._vcpus
604604
def set_vcpus(self, val):
605-
maxvcpus = util.get_max_vcpus(self.conn)
605+
maxvcpus = util.get_max_vcpus(self.conn, self.type)
606606
if val < 1 or val > maxvcpus:
607607
raise ValueError, \
608608
_("Number of vcpus must be in the range of 1-%d") % (maxvcpus,)

virtinst/util.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,12 @@ def get_host_network_devices():
192192
device.append(words)
193193
return device
194194

195-
def get_max_vcpus(conn):
196-
"""@conn libvirt connection to poll for max possible vcpus"""
195+
def get_max_vcpus(conn, type=None):
196+
"""@conn libvirt connection to poll for max possible vcpus
197+
@type optional guest type (kvm, etc.)"""
197198
try:
198-
max = conn.getMaxVcpus(conn.getType().lower())
199-
except Exception, e:
199+
max = conn.getMaxVcpus(type.lower())
200+
except libvirt.libvirtError:
200201
max = 32
201202
return max
202203

0 commit comments

Comments
 (0)