Change in vdsm[master]: qemuimg: Handle new output format

alitke at redhat.com alitke at redhat.com
Sat May 10 12:36:03 UTC 2014


Adam Litke has uploaded a new change for review.

Change subject: qemuimg: Handle new output format
......................................................................

qemuimg: Handle new output format

The current qemu-img info parsing logic assumes that if the output is
long enough, the backing image will appear on line 6.  In newer qemu
versions, some additional information has been added to the output.  In
the case of no backing file, the additional lines will fail to parse.
Handle this by trying to parse line 6 as a backing file and ignoring
regex parse errors for this line only.

Change-Id: Ic229198ab7c2bb9743bdf8629416131186115431
Signed-off-by: Adam Litke <alitke at redhat.com>
---
M lib/vdsm/qemuimg.py
1 file changed, 13 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/52/27552/1

diff --git a/lib/vdsm/qemuimg.py b/lib/vdsm/qemuimg.py
index 69912d9..2dfbc4d 100644
--- a/lib/vdsm/qemuimg.py
+++ b/lib/vdsm/qemuimg.py
@@ -43,8 +43,15 @@
 }
 
 
+class _RegexSearchError(Exception):
+    pass
+
+
 def __iregexSearch(pattern, text):
-    return __iregex[pattern].search(text).group("value")
+    m = __iregex[pattern].search(text)
+    if m is None:
+        raise _RegexSearchError()
+    return m.group("value")
 
 
 class QImgError(Exception):
@@ -81,8 +88,11 @@
             info['clustersize'] = int(__iregexSearch("clustersize", out[4]))
 
         if len(out) > 5:
-            info['backingfile'] = __iregexSearch("backingfile", out[5])
-    except:
+            try:
+                info['backingfile'] = __iregexSearch("backingfile", out[5])
+            except _RegexSearchError:
+                pass
+    except _RegexSearchError:
         raise QImgError(rc, out, err, "unable to parse qemu-img info output")
 
     return info


-- 
To view, visit http://gerrit.ovirt.org/27552
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic229198ab7c2bb9743bdf8629416131186115431
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke at redhat.com>


More information about the vdsm-patches mailing list