[virt-tools-list] [virt-manager PATCH] storagebrowser: ignore unparseable volumes

Guido Günther agx at sigxcpu.org
Tue Jan 10 18:56:23 UTC 2012


This e.g. happens when the volume was moved away but the pool didn't get
refereshed:

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/create.py", line 1229, in browse_import
    self._browse_file(set_path, is_media=False)
  File "/usr/share/virt-manager/virtManager/create.py", line 2118, in _browse_file
    self.storage_browser.show(self.topwin, self.conn)
  File "/usr/share/virt-manager/virtManager/storagebrowse.py", line 74, in show
    self.reset_state(conn)
  File "/usr/share/virt-manager/virtManager/storagebrowse.py", line 183, in reset_state
    self.pool_selected()
  File "/usr/share/virt-manager/virtManager/storagebrowse.py", line 257, in pool_selected
    self.populate_storage_volumes()
  File "/usr/share/virt-manager/virtManager/storagebrowse.py", line 322, in populate_storage_volumes
    path = vol.get_target_path()
  File "/usr/share/virt-manager/virtManager/storagevol.py", line 49, in get_target_path
    return util.xpath(self.get_xml(), "/volume/target/path")
  File "/usr/share/virt-manager/virtManager/libvirtobject.py", line 93, in get_xml
    self.refresh_xml()
  File "/usr/share/virt-manager/virtManager/libvirtobject.py", line 105, in refresh_xml
    self._xml = self._XMLDesc(self._active_xml_flags)
  File "/usr/share/virt-manager/virtManager/storagevol.py", line 35, in _XMLDesc
    return self.vol.XMLDesc(flags)
  File "/usr/lib/python2.7/dist-packages/libvirt.py", line 2002, in XMLDesc
    if ret is None: raise libvirtError ('virStorageVolGetXMLDesc() failed', vol=self)
libvirt.libvirtError: cannot stat file '/var/scratch/vms/squeeze-template.img': No such file or directory

Instead of failing the whole pool simply ignore the one failing volume.
Without this patch selecting "Browse..." when creating a new vm from an
existing disk image won't show the volume dialog if the default pool has
a missing volume.
---
 src/virtManager/storagebrowse.py |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/virtManager/storagebrowse.py b/src/virtManager/storagebrowse.py
index b6d8dad..c470320 100644
--- a/src/virtManager/storagebrowse.py
+++ b/src/virtManager/storagebrowse.py
@@ -320,8 +320,13 @@ class vmmStorageBrowser(vmmGObjectUI):
         for key in vols.keys():
             vol = vols[key]
             sensitive = True
-            path = vol.get_target_path()
-            fmt = vol.get_format() or ""
+            try:
+                path = vol.get_target_path()
+                fmt = vol.get_format() or ""
+            except Exception:
+                logging.exception("Failed to determine volume parameters, "
+                                  "skipping volume %s" % key)
+		continue
             namestr = None
 
             try:
-- 
1.7.7.3




More information about the virt-tools-list mailing list