Matthew Booth
2010-Jun-30 10:55 UTC
[Libguestfs] [PATCH 1/2] Add new augeas directory with grub device.map lens
Add a directory to contain required augeas lenses which aren't yet upstream. Include a new lens for grub's device.map. --- augeas/README.txt | 4 ++++ augeas/device_map.aug | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 0 deletions(-) create mode 100644 augeas/README.txt create mode 100644 augeas/device_map.aug diff --git a/augeas/README.txt b/augeas/README.txt new file mode 100644 index 0000000..709be7c --- /dev/null +++ b/augeas/README.txt @@ -0,0 +1,4 @@ +This directory contains augeas lenses required by virt-v2v. + +device_map.aug posted upstream: +http://www.redhat.com/archives/augeas-devel/2010-June/msg00027.html diff --git a/augeas/device_map.aug b/augeas/device_map.aug new file mode 100644 index 0000000..090edd5 --- /dev/null +++ b/augeas/device_map.aug @@ -0,0 +1,28 @@ +(* Parsing grub's device.map *) + +module Device_map + autoload xfm + + let sep_tab = Sep.tab + let eol = Util.eol + let fspath = Rx.fspath + let del_str = Util.del_str + + let comment = Util.comment + let empty = Util.empty + + let dev_name = /(h|f|c)d[0-9]+(,[0-9a-zA-Z]+){0,2}/ + let dev_hex = /0x[0-9a-fA-F]+/ + let dev_dec = /[0-9]+/ + + let device = del_str "(" . key ( dev_name | dev_hex | dev_dec ) . del_str ")" + + let map = [ device . sep_tab . store fspath . eol ] + + let lns = ( empty | comment | map ) * + + let xfm = transform lns (incl "/boot/grub/device.map") + +(* Local Variables: *) +(* mode: caml *) +(* End: *) -- 1.7.1
This patch updates device paths in grub's device.map. Fixes RHBZ#609448 --- lib/Sys/VirtV2V/GuestOS/RedHat.pm | 43 ++++++++++++++++++++++++++++++++---- 1 files changed, 38 insertions(+), 5 deletions(-) diff --git a/lib/Sys/VirtV2V/GuestOS/RedHat.pm b/lib/Sys/VirtV2V/GuestOS/RedHat.pm index f881612..8898576 100644 --- a/lib/Sys/VirtV2V/GuestOS/RedHat.pm +++ b/lib/Sys/VirtV2V/GuestOS/RedHat.pm @@ -1540,13 +1540,29 @@ sub remap_block_devices # that all Fedora distributions in use use libata. if ($libata) { - # Look for IDE and SCSI devices in fstab for the guest + # Look for IDE and SCSI devices in guest config files my %guestif; eval { + my @guestdevs; + foreach my $spec ($g->aug_match('/files/etc/fstab/*/spec')) { my $device = $g->aug_get($spec); - next unless($device =~ m{^/dev/(sd|hd)([a-z]+)}); + push(@guestdevs, $device); + } + + foreach my $key ($g->aug_match('/files/boot/grub/device.map/*')) { + $key =~ m{/files/boot/grub/device.map/(.*)} or die; + my $gdev = $1; + + next if ($gdev =~ /^#comment/); + + my $odev = $g->aug_get($key); + push(@guestdevs, $odev); + } + + foreach my $dev (@guestdevs) { + next unless($dev =~ m{^/dev/(sd|hd)([a-z]+)}); $guestif{$1} ||= {}; $guestif{$1}->{$1.$2} = 1; } @@ -1554,8 +1570,8 @@ sub remap_block_devices $self->_augeas_error($@) if ($@); - # If fstab contains references to sdX, these could refer to IDE or SCSI - # devices. We may need to update them. + # If guest config contains references to sdX, these could refer to IDE + # or SCSI devices. We may need to update them. if (exists($guestif{sd})) { # Look for IDE and SCSI devices from the domain definition my %domainif; @@ -1613,7 +1629,7 @@ sub remap_block_devices } eval { - # Go through fstab again, updating bare device references + # Update bare device references in fstab foreach my $spec ($g->aug_match('/files/etc/fstab/*/spec')) { my $device = $g->aug_get($spec); @@ -1625,6 +1641,23 @@ sub remap_block_devices $g->aug_set($spec, "/dev/".$map{$name}.$part); } + # Update device.map + foreach my $key ($g->aug_match('/files/boot/grub/device.map/*')) { + $key =~ m{/files/boot/grub/device.map/(.*)} or die; + my $gdev = $1; + + next if ($gdev =~ /^#comment/); + + my $odev = $g->aug_get($key); + + next unless($odev =~ m{^/dev/([a-z]+)(\d*)}); + my $name = $1; + my $part = $2; + + next unless(exists($map{$name})); + + $g->aug_set($key, "/dev/".$map{$name}.$part); + } $g->aug_save(); }; -- 1.7.1
Richard W.M. Jones
2010-Jul-02 17:11 UTC
[Libguestfs] [PATCH 1/2] Add new augeas directory with grub device.map lens
On Wed, Jun 30, 2010 at 11:55:50AM +0100, Matthew Booth wrote:> Add a directory to contain required augeas lenses which aren't yet upstream. > Include a new lens for grub's device.map.And these are not upstream why? I think we should just push these upstream fast as possible, and push them into the Fedora augeas package as patches as we need them. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
Richard W.M. Jones
2010-Jul-02 17:13 UTC
[Libguestfs] [PATCH 2/2] Update grub's device.map
On Wed, Jun 30, 2010 at 11:55:51AM +0100, Matthew Booth wrote:> + foreach my $key ($g->aug_match('/files/boot/grub/device.map/*')) { > + $key =~ m{/files/boot/grub/device.map/(.*)} or die; > + my $gdev = $1; > + > + next if ($gdev =~ /^#comment/);Shouldn't the Augeas lens take care of these? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
Possibly Parallel Threads
- [PATCH] btrfs-progs: fix 32bit int/pointer cast warnings
- [PATCHv2 RFC] virtio-pci: flexible configuration layout
- [PATCHv2 RFC] virtio-pci: flexible configuration layout
- [PATCHv3 RFC] virtio-pci: flexible configuration layout
- [PATCHv3 RFC] virtio-pci: flexible configuration layout