[Libguestfs] [PATCH] Fix device name mapping for libata guests

Matthew Booth mbooth at redhat.com
Tue Oct 12 13:05:25 UTC 2010


remap_block_devices was modifying the global device list while remapping device
names for libata guests (which includes RHEL 6). This caused a failure later
when the renamed devices were not present in the original XML.

Fixes RHBZ#641869
---
 lib/Sys/VirtV2V/GuestOS/RedHat.pm |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/lib/Sys/VirtV2V/GuestOS/RedHat.pm b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
index a322a5d..cc95fd8 100644
--- a/lib/Sys/VirtV2V/GuestOS/RedHat.pm
+++ b/lib/Sys/VirtV2V/GuestOS/RedHat.pm
@@ -1567,7 +1567,19 @@ sub remap_block_devices
                 $letter++;
             }
 
-            map { $_ = $map{$_} } @$devices;
+            # N.B. Don't use map() here because we mustn't modify the original
+            # devices list
+            my @newdevices;
+            foreach my $device (@$devices) {
+                my $map = $map{$device};
+
+                unless (defined($map)) {
+                    warn ("No mapping for device $device");
+                    next;
+                }
+                push(@newdevices, $map);
+            }
+            $devices = \@newdevices;
         }
     }
 
-- 
1.7.2.3




More information about the Libguestfs mailing list