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

[virt-tools-list] [PATCH virt-manager 1/2] inspection: report guest inspection errors



Add an `error' flag to the inspection data for a guest and set it when
the inspection failed.

Signed-off-by: Giuseppe Scrivano <gscrivan redhat com>
---
 virtManager/domain.py     |  1 +
 virtManager/inspection.py | 26 ++++++++++++++++++++------
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/virtManager/domain.py b/virtManager/domain.py
index b8324d5..2fc869a 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -142,6 +142,7 @@ class vmmInspectionData(object):
         self.product_variant = None
         self.icon = None
         self.applications = None
+        self.error = False
 
 
 class vmmDomainSnapshot(vmmLibvirtObject):
diff --git a/virtManager/inspection.py b/virtManager/inspection.py
index 8b49bbe..3fefe6b 100644
--- a/virtManager/inspection.py
+++ b/virtManager/inspection.py
@@ -122,6 +122,11 @@ class vmmInspection(vmmGObject):
                 if not conn.is_active():
                     break
 
+                def set_inspection_error(vm):
+                    data = vmmInspectionData()
+                    data.error = True
+                    self._set_vm_inspection_data(vm, data)
+
                 prettyvm = vmuuid
                 try:
                     vm = conn.get_vm(vmuuid)
@@ -139,7 +144,15 @@ class vmmInspection(vmmGObject):
 
                     # Whether success or failure, we've "seen" this VM now.
                     self._vmseen[vmuuid] = True
-                    self._process(conn, vm, vmuuid)
+                    try:
+                        data = self._process(conn, vm, vmuuid)
+                        if data:
+                            self._set_vm_inspection_data(vm, data)
+                        else:
+                            set_inspection_error(vm)
+                    except:
+                        set_inspection_error(vm)
+                        raise
                 except:
                     logging.exception("%s: exception while processing",
                                       prettyvm)
@@ -148,7 +161,7 @@ class vmmInspection(vmmGObject):
         if re.search(r"^guestfs-", vm.get_name()):
             logging.debug("ignore libvirt/guestfs temporary VM %s",
                           vm.get_name())
-            return
+            return None
 
         g = GuestFS()
         prettyvm = conn.get_uri() + ":" + vm.get_name()
@@ -163,7 +176,7 @@ class vmmInspection(vmmGObject):
 
         if not disks:
             logging.debug("%s: nothing to inspect", prettyvm)
-            return
+            return None
 
         # Add the disks.  Note they *must* be added with readonly flag set.
         for disk in disks:
@@ -173,7 +186,7 @@ class vmmInspection(vmmGObject):
             if not (os.path.exists(path) and os.access(path, os.R_OK)):
                 logging.debug("%s: cannot access '%s', skipping inspection",
                               prettyvm, path)
-                return
+                return None
 
             g.add_drive_opts(path, readonly=1, format=driver_type)
 
@@ -183,7 +196,7 @@ class vmmInspection(vmmGObject):
         roots = g.inspect_os()
         if len(roots) == 0:
             logging.debug("%s: no operating systems found", prettyvm)
-            return
+            return None
 
         # Arbitrarily pick the first root device.
         root = roots[0]
@@ -264,8 +277,9 @@ class vmmInspection(vmmGObject):
         data.product_variant = str(product_variant)
         data.icon = icon
         data.applications = list(apps)
+        data.error = False
 
-        self._set_vm_inspection_data(vm, data)
+        return data
 
     def _set_vm_inspection_data(self, vm, data):
         vm.inspection = data
-- 
1.8.3.1


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