[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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

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
  File "virt-manager/virtManager/details.py", line 2742, in
  File "virt-manager/virtManager/details.py", line 2638, in
    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 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)

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]