On Tue, Oct 12, 2010 at 02:05:25PM +0100, Matthew Booth wrote:
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
The problem isn't that you used map(), it is that your map code block
has side effects. You should be able to avoid the side effect thus:
my @newdevices = map { $map{$_} } @$devices;
+ 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;
}
Regards,
Daniel
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://deltacloud.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|