[Libguestfs] [PATCH 5/7] RedHat: Check which filesystem the grub configuration is on

Richard W.M. Jones rjones at redhat.com
Tue Apr 26 16:54:42 UTC 2011


On Tue, Apr 26, 2011 at 05:03:50PM +0100, Matthew Booth wrote:
> ---
>  lib/Sys/VirtConvert/Converter/RedHat.pm |   23 ++++++++++++++++-------
>  1 files changed, 16 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/Sys/VirtConvert/Converter/RedHat.pm b/lib/Sys/VirtConvert/Converter/RedHat.pm
> index 456110b..82d52de 100644
> --- a/lib/Sys/VirtConvert/Converter/RedHat.pm
> +++ b/lib/Sys/VirtConvert/Converter/RedHat.pm
> @@ -112,7 +112,7 @@ sub convert
>      _init_selinux($g);
>      _init_augeas($g);
>      _init_modprobe_aliases($g, $desc);
> -    _init_kernels($g, $desc);
> +    _init_kernels($g, $root, $desc);
>      my $modpath = _init_modpath($g);
>  
>      # Un-configure HV specific attributes which don't require a direct
> @@ -583,17 +583,26 @@ sub _list_kernels
>  
>  sub _init_kernels
>  {
> -    my ($g, $desc) = @_;
> +    my ($g, $root, $desc) = @_;
>  
>      if ($desc->{os} eq "linux") {
>          # Iterate over entries in grub.conf, populating $desc->{boot}
>          # For every kernel we find, inspect it and add to $desc->{kernels}
>  
> -        # All known past and present Red Hat-based distros mount a
> -        # boot partition on /boot.  We may have to revisit this if
> -        # this assumption changes in future.  (Old Perl inspection
> -        # code used to try to detect this setting).
> -        my $grub = "/boot";
> +        # Find the path which needs to be prepended to paths in grub.conf to
> +        # make them absolute
> +        # Default to / (no prefix required)
> +        my $grub = "";
> +
> +        # Look for the most specific mount point discovered
> +        my %mounts = $g->inspect_get_mountpoints($root);
> +        foreach my $path qw(/boot/grub /boot) {
> +            if (exists($mounts{$path})) {
> +                $grub = $path;
> +                last;
> +            }
> +        }
> +

ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list