Drop conn_max_vcpus validation
Let's just let libvirt throw an error in the rare occasion that we exceed max vcpus.
This commit is contained in:
parent
492a039f7d
commit
ba3aa9ecca
|
@ -411,7 +411,6 @@ vinst.add_valid("cpuram", "--cpu foobar,+x2apic,+x2apicagain,-distest,forbid=foo
|
|||
vinst.add_valid("cpuram", "--numatune 1,2,3,5-7,^6") # Simple --numatune
|
||||
vinst.add_invalid("cpuram", "--vcpus 32 --cpuset=969-1000") # Bogus cpuset
|
||||
vinst.add_invalid("cpuram", "--vcpus 32 --cpuset=autofoo") # Bogus cpuset
|
||||
vinst.add_invalid("cpuram", "--vcpus 10000") # Over max vcpus
|
||||
vinst.add_invalid("cpuram", "--vcpus 20 --check-cpu") # Over host vcpus w/ --check-cpu
|
||||
vinst.add_invalid("cpuram", "--vcpus 5,maxvcpus=1") # maxvcpus less than cpus
|
||||
vinst.add_invalid("cpuram", "--vcpus foo=bar") # vcpus unknown option
|
||||
|
|
|
@ -80,7 +80,7 @@ args = {
|
|||
'valid' : ['12345678123456781234567812345678',
|
||||
'12345678-1234-1234-ABCD-ABCDEF123456']},
|
||||
'vcpus' : {
|
||||
'invalid' : [-1, 0, 1000, ''],
|
||||
'invalid' : [-1, 0, ''],
|
||||
'valid' : [1, 32]},
|
||||
'type' : {
|
||||
'invalid' : [],
|
||||
|
|
|
@ -205,9 +205,6 @@ class vmmConnection(vmmGObject):
|
|||
self._check_caps()
|
||||
return self._caps
|
||||
|
||||
def get_max_vcpus(self, _type):
|
||||
return virtinst.util.get_max_vcpus(self._backend, _type)
|
||||
|
||||
def get_host_info(self):
|
||||
return self.hostinfo
|
||||
|
||||
|
|
|
@ -560,19 +560,8 @@ class vmmCreate(vmmGObjectUI):
|
|||
self.widget("phys-mem-label").set_markup(mem_label)
|
||||
|
||||
# CPU
|
||||
phys_cpus = self.conn.host_active_processor_count()
|
||||
|
||||
max_v = self.conn.get_max_vcpus(self.capsdomain.hypervisor_type)
|
||||
phys_cpus = int(self.conn.host_active_processor_count())
|
||||
cmax = phys_cpus
|
||||
if int(max_v) < int(phys_cpus):
|
||||
cmax = max_v
|
||||
cpu_tooltip = (_("Hypervisor only supports %d virtual CPUs.") %
|
||||
max_v)
|
||||
else:
|
||||
cpu_tooltip = None
|
||||
self.widget("config-cpus").set_tooltip_text(cpu_tooltip or "")
|
||||
|
||||
cmax = int(cmax)
|
||||
if cmax <= 0:
|
||||
cmax = 1
|
||||
cpu_label = (_("Up to %(numcpus)d available") %
|
||||
|
|
|
@ -346,13 +346,9 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
|
|||
xpath="./uuid")
|
||||
|
||||
def __validate_cpus(self, val):
|
||||
maxvcpus = util.get_max_vcpus(self.conn, self.type)
|
||||
val = int(val)
|
||||
if val < 1:
|
||||
raise ValueError(_("Number of vcpus must be a positive integer."))
|
||||
if val > maxvcpus:
|
||||
raise ValueError(_("Number of vcpus must be no greater than %d "
|
||||
"for this vm type.") % maxvcpus)
|
||||
return val
|
||||
|
||||
# number of vcpus for the guest
|
||||
|
|
|
@ -446,18 +446,6 @@ def randomUUID(conn):
|
|||
"%02x" * 6]) % tuple(u)
|
||||
|
||||
|
||||
def get_max_vcpus(conn, typ):
|
||||
"""@param conn: libvirt connection to poll for max possible vcpus
|
||||
@type type: optional guest type (kvm, etc.)"""
|
||||
if typ is None:
|
||||
typ = conn.getType()
|
||||
try:
|
||||
m = conn.getMaxVcpus(typ.lower())
|
||||
except libvirt.libvirtError:
|
||||
m = 32
|
||||
return m
|
||||
|
||||
|
||||
def xml_escape(xml):
|
||||
"""
|
||||
Replaces chars ' " < > & with xml safe counterparts
|
||||
|
|
Loading…
Reference in New Issue