[Libguestfs] [PATCH 1/2] canonical_device_name: Don't rewrite /dev/mdX as /dev/sdX (RHBZ#1414682).

Richard W.M. Jones rjones at redhat.com
Thu Jan 19 09:46:36 UTC 2017


The guestfs_canonical_device_name API was rewriting /dev/mdX as
/dev/sdX.  This is wrong since (eg) /dev/sd0 is not a device name, so
if you pass the canonicalized name back to the API it will fail.
virt-v2v was one tool doing this.
---
 src/canonical-name.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/canonical-name.c b/src/canonical-name.c
index ae7b468..d72768f 100644
--- a/src/canonical-name.c
+++ b/src/canonical-name.c
@@ -35,6 +35,7 @@ guestfs_impl_canonical_device_name (guestfs_h *g, const char *device)
   /* /dev/hd etc. */
   if (STRPREFIX (device, "/dev/") &&
       strchr (device+5, '/') == NULL && /* not an LV name */
+      device[5] != 'm' && /* not /dev/md - RHBZ#1414682 */
       ((len = strcspn (device+5, "d")) > 0 && len <= 2)) {
     ret = safe_asprintf (g, "/dev/sd%s", &device[5+len+1]);
   }
-- 
2.9.3




More information about the Libguestfs mailing list