[virt-manager PATCH 1/6] inspection: remove extra try/catch block

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

 



This block only catches failures in g.inspect_get_mountpoints(), as the
g.mount_ro() calls are already within own try/catch blocks.  Considering
that:
- g.inspect_get_mountpoints() is a simple API to query one of the
  results of the inspection, it is very unlikely that it fails
- the whole _inspect_vm function (that contains the inspection code) is
  already run within an own try/catch block, so even a failure in
  g.inspect_get_mountpoints() will not crash virt-manager
then just remove this extra try/catch block.
---
 virtManager/inspection.py | 50 ++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 27 deletions(-)

diff --git a/virtManager/inspection.py b/virtManager/inspection.py
index 9923dde2..084571bb 100644
--- a/virtManager/inspection.py
+++ b/virtManager/inspection.py
@@ -235,33 +235,29 @@ class vmmInspection(vmmGObject):
         # don't fail if this is not possible (I'm looking at you,
         # FreeBSD).
         filesystems_mounted = False
-        try:
-            # Mount up the disks, like guestfish --ro -i.
-
-            # Sort keys by length, shortest first, so that we end up
-            # mounting the filesystems in the correct order.
-            mps = list(g.inspect_get_mountpoints(root))
-            def compare(a, b):
-                if len(a[0]) > len(b[0]):
-                    return 1
-                elif len(a[0]) == len(b[0]):
-                    return 0
-                else:
-                    return -1
-
-            mps.sort(key=functools.cmp_to_key(compare))
-            for mp_dev in mps:
-                try:
-                    g.mount_ro(mp_dev[1], mp_dev[0])
-                except Exception:
-                    logging.exception("%s: exception mounting %s on %s "
-                                      "(ignored)",
-                                      prettyvm, mp_dev[1], mp_dev[0])
-
-            filesystems_mounted = True
-        except Exception:
-            logging.exception("%s: exception while mounting disks (ignored)",
-                              prettyvm)
+        # Mount up the disks, like guestfish --ro -i.
+
+        # Sort keys by length, shortest first, so that we end up
+        # mounting the filesystems in the correct order.
+        mps = list(g.inspect_get_mountpoints(root))
+        def compare(a, b):
+            if len(a[0]) > len(b[0]):
+                return 1
+            elif len(a[0]) == len(b[0]):
+                return 0
+            else:
+                return -1
+
+        mps.sort(key=functools.cmp_to_key(compare))
+        for mp_dev in mps:
+            try:
+                g.mount_ro(mp_dev[1], mp_dev[0])
+            except Exception:
+                logging.exception("%s: exception mounting %s on %s "
+                                  "(ignored)",
+                                  prettyvm, mp_dev[1], mp_dev[0])
+
+        filesystems_mounted = True
 
         icon = None
         apps = None
-- 
2.20.1

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list



[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux