[PATCH 01/13] Apparently necessary kpartx changes (#867593)

David Lehman dlehman at redhat.com
Thu Nov 1 22:55:04 UTC 2012


Don't always force kpartx to use a delimiter. The problem is that there
are all these places that could be triggering creation of the partitions
and they need to all use the same rules for when to use a delimiter
between disk and partition number. Otherwise, how can parted know when
to use a delimiter when adding a partition to a dm disk? You'd think the
answer would be "always use a delimiter" or "never use a delimiter" but
that's not how the world works.

Also, pass -s to kpartx to wait for devices to be created before
returning since udev should be doing all the work nowadays.
---
 pyanaconda/storage/devices.py |    4 ++--
 pyanaconda/storage/udev.py    |   17 +++--------------
 2 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index 1246177..1c56f95 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -1752,7 +1752,7 @@ class DMDevice(StorageDevice):
     def setupPartitions(self):
         log_method_call(self, name=self.name, kids=self.kids)
         rc = iutil.execWithRedirect("kpartx",
-                                ["-a", "-p", "p", self.path],
+                                ["-a", "-s", self.path],
                                 stdout = "/dev/tty5",
                                 stderr = "/dev/tty5")
         if rc:
@@ -1762,7 +1762,7 @@ class DMDevice(StorageDevice):
     def teardownPartitions(self):
         log_method_call(self, name=self.name, kids=self.kids)
         rc = iutil.execWithRedirect("kpartx",
-                                ["-d", "-p", "p", self.path],
+                                ["-d", "-s", self.path],
                                 stdout = "/dev/tty5",
                                 stderr = "/dev/tty5")
         if rc:
diff --git a/pyanaconda/storage/udev.py b/pyanaconda/storage/udev.py
index 7fda83b..4076203 100644
--- a/pyanaconda/storage/udev.py
+++ b/pyanaconda/storage/udev.py
@@ -463,22 +463,11 @@ def udev_device_is_biosraid_member(info):
     return False
 
 def udev_device_get_dm_partition_disk(info):
-    try:
-        p_index = info["DM_NAME"].rindex("p")
-    except (KeyError, AttributeError, ValueError):
-        return None
-
-    if not info["DM_NAME"][p_index+1:].isdigit():
-        return None
-
-    return info["DM_NAME"][:p_index]
+    return re.sub(r'\d*$', '', udev_device_get_name(info))
 
 def udev_device_is_dm_partition(info):
-    if not udev_device_is_dm(info):
-        return False
-
-    diskname = udev_device_get_dm_partition_disk(info)
-    return diskname not in ("", None)
+    return (udev_device_is_dm(info) and
+            info.get("DM_UUID", "").split("-")[0].startswith("part"))
 
 def udev_device_is_multipath_member(info):
     """ Return True if the device is part of a multipath. """
-- 
1.7.7.6



More information about the anaconda-patches mailing list