Mike Latimer
2013-Sep-25 19:40 UTC
[Libguestfs] [PATCH 0/1] virt-v2v: Track hd->sd block device remaps
During the conversion process, hd* block devices under Xen are mapped to sd* devices for use under guestfs. These sd devices are later remapped to vd* (or sd/hd) devices, for future use under kvm. The current code fails to track the original hd* device names. This causes subsequent remappings of the block devices (in such places as /etc/fstab, and /boot/grub/menu.lst), to skip the hd* devices, which leads to a later failure of the guest. This patch adds a hash to track the hd->sd remap, and later uses that hash to add hd->vd maps to the table. Mike Latimer (1): Track hd sd block device remaps lib/Sys/VirtConvert/Converter/RedHat.pm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) -- 1.8.1.4
Mike Latimer
2013-Sep-25 19:40 UTC
[Libguestfs] [PATCH 1/1] Track hd->sd block device remaps
--- lib/Sys/VirtConvert/Converter/RedHat.pm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Sys/VirtConvert/Converter/RedHat.pm b/lib/Sys/VirtConvert/Converter/RedHat.pm index 36345e7..fc4f5f0 100644 --- a/lib/Sys/VirtConvert/Converter/RedHat.pm +++ b/lib/Sys/VirtConvert/Converter/RedHat.pm @@ -2234,6 +2234,10 @@ sub _remap_block_devices # Fedora has used libata since FC7, which is long out of support. We assume # that all Fedora distributions in use use libata. + # Create a hash to track any hd->sd conversions, as any references to + # hd devices (in fstab, menu.lst, etc) will need to be converted later. + my %idemap; + if ($libata) { # If there are any IDE devices, the guest will have named these sdX # after any SCSI devices. i.e. If we have disks hda, hdb, sda and sdb, @@ -2246,10 +2250,15 @@ sub _remap_block_devices # this is a weird and somewhat unlikely situation I'm going with SCSI # first until we have a more comprehensive solution. + my $idedev; my @newdevices; my $suffix = 'a'; foreach my $device (@devices) { - $device = 'sd'.$suffix++ if ($device =~ /(?:h|s)d[a-z]+/); + if ($device =~ /(?:h|s)d[a-z]+/) { + $idedev = $device; + $device = 'sd'.$suffix++; + $idemap{$device} = $idedev if ($device ne $idedev); + } push(@newdevices, $device); } @devices = @newdevices; @@ -2285,6 +2294,13 @@ sub _remap_block_devices $map{'xvd'.$1} = $mapped; } $map{$device} = $mapped; + # Also add a mapping for previously saved hd->sd conversions + if (defined($idemap{$device})) { + my $idedevice; + $idedevice = $idemap{$device}; + $map{$idedevice} = $mapped; + } + $letter++; } -- 1.8.1.4
Apparently Analagous Threads
- [PATCH 1/1] Track hd->sd block device remaps
- [PATCH 0/4] Add SUSE guest converter to virt-v2v
- Re: [PATCH 3/4] Add SUSE converter
- Re: [PATCH] virt-v2v: Convert RedHat.pm to Linux.pm - for SUSE support
- [PATCH] virt-v2v: Convert RedHat.pm to Linux.pm - for SUSE support