[NEW PATCH] Related to BZ#701671 - Return ENODEV if device does not exist. (via gerrit-bot)

Dan Kenigsberg danken at redhat.com
Mon Aug 8 12:46:03 UTC 2011


New patch submitted by Dan Kenigsberg (danken at redhat.com)

You can review this change at: http://gerrit.usersys.redhat.com/760

commit 0c9c4b5c86d4fd1a1a27d1ecd71517d29baed0d3
Author: Eduardo Warszawski <ewarszaw at redhat.com>
Date:   Thu Jul 28 16:22:30 2011 +0300

    Related to BZ#701671 - Return ENODEV if device does not exist.
    
    Change-Id: Ibcf14a4d6f3492697d6ba2b9c37de2722de4c6b0

diff --git a/vdsm/storage/devicemapper.py b/vdsm/storage/devicemapper.py
index 78e44a0..29dbcd3 100644
--- a/vdsm/storage/devicemapper.py
+++ b/vdsm/storage/devicemapper.py
@@ -70,7 +70,7 @@ def resolveDevName(devName):
     try:
         return getDmId(devName)
     except Exception:
-        raise OSError(errno.ENOENT, "No such block device `%s`" % devName)
+        raise OSError(errno.ENODEV, "No such block device `%s`" % devName)
 
 def isVirtualDevice(devName):
     devName = resolveDevName(devName)
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index d46f678..d2707a2 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -13,6 +13,7 @@ Generic LVM interface wrapper
 
 Incapsulates the actual LVM mechanics.
 """
+import errno
 
 import os
 import pwd
@@ -705,7 +706,13 @@ def _initpv(device, withmetadata=False):
         if isPvPartOfVg(device):
             raise se.PhysDevInitializationError(device)
 
-        devicemapper.removeMappingsHoldingDevice(os.path.basename(device))
+        try:
+            devicemapper.removeMappingsHoldingDevice(os.path.basename(device))
+        except OSError, e:
+            if e.errno == errno.ENODEV:
+                raise se.PhysDevInitializationError("%s: %s" % (device, str(e)))
+            else:
+                raise
         rc, out, err = _lvminfo.cmd(cmd)
         if rc != 0:
             raise se.PhysDevInitializationError(device)




More information about the vdsm-patches mailing list