mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-11 05:17:59 +03:00
xmlbuilder: Fix setting float value for is_int
This commit is contained in:
parent
63a3fb3066
commit
03bd6f024e
@ -412,7 +412,6 @@ 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 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
|
||||
vinst.add_invalid("cpuram", "--cpu host") # --cpu host, but no host CPU in caps
|
||||
vinst.add_invalid("cpuram", "--numatune 1-3,4,mode=strict") # Non-escaped numatune
|
||||
|
@ -161,7 +161,8 @@ class XMLParseTest(unittest.TestCase):
|
||||
check("vendor", "Intel", "qemuvendor")
|
||||
check("threads", 2, 1)
|
||||
check("cores", 5, 3)
|
||||
check("sockets", 4, 4)
|
||||
guest.cpu.sockets = 4.0
|
||||
check("sockets", 4)
|
||||
|
||||
check = self._make_checker(guest.cpu.features[0])
|
||||
check("name", "x2apic")
|
||||
|
@ -403,9 +403,13 @@ class XMLProperty(property):
|
||||
def _convert_set_value(self, xmlbuilder, val):
|
||||
if self._default_name and val == self._default_name:
|
||||
val = self._default_cb(xmlbuilder)
|
||||
elif self._is_yesno:
|
||||
if val is not None:
|
||||
val = bool(val) and "yes" or "no"
|
||||
elif self._is_yesno and val is not None:
|
||||
val = bool(val) and "yes" or "no"
|
||||
elif self._is_int and val is not None:
|
||||
intkwargs = {}
|
||||
if "0x" in str(val):
|
||||
intkwargs["base"] = 16
|
||||
val = int(val, **intkwargs)
|
||||
|
||||
if self._convert_value_for_setter_cb:
|
||||
val = self._convert_value_for_setter_cb(xmlbuilder, val)
|
||||
|
Loading…
Reference in New Issue
Block a user