[virt-tools-list] [PATCH] details: fix exception when current vcpus is equal to max vcpus

Giuseppe Scrivano gscrivan at redhat.com
Sun Oct 27 18:07:23 UTC 2013


The "current" XML attribute of vcpu is optional and assumed to be
equal to the maximum number of vcpus when not specified.

It fixes this exception:

Traceback (most recent call last):
  File "virt-manager/virtManager/details.py", line 1180, in
  hw_selected
    self.refresh_config_cpu()
  File "virt-manager/virtManager/details.py", line 2742, in
  refresh_config_cpu
    self._refresh_cpu_count()
  File "virt-manager/virtManager/details.py", line 2638, in
  _refresh_cpu_count
    curvcpus = self.vm.vcpu_count()
  File "virt-manager/virtManager/domain.py", line 1039, in vcpu_count
    return int(self.get_xmlobj().curvcpus)
TypeError: int() argument must be a string or a number, not 'NoneType'

Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
---
 virtManager/domain.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virtManager/domain.py b/virtManager/domain.py
index 4ff156e..03cb310 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -1036,7 +1036,7 @@ class vmmDomain(vmmLibvirtObject):
         return int(self.get_xmlobj().maxmemory)
 
     def vcpu_count(self):
-        return int(self.get_xmlobj().curvcpus)
+        return int(self.get_xmlobj().curvcpus or self.get_xmlobj().vcpus)
     def vcpu_max_count(self):
         guest = self.get_xmlobj()
         has_xml_max = (guest.curvcpus != guest.vcpus)
-- 
1.8.3.1




More information about the virt-tools-list mailing list