[Libguestfs] [PATCH v5 1/3] v2v: bootloaders: search grub config for all distributions

Pino Toscano ptoscano at redhat.com
Fri Nov 11 13:49:38 UTC 2016


On Thursday, 10 November 2016 14:59:59 CET Richard W.M. Jones wrote:
> From: Pavel Butsykin <pbutsykin at virtuozzo.com>
> 
> This patch improves the search of grub config on EFI partition. This
> means that the config will be found not only for rhel but also for
> many other distributions.  Tests were performed on the following
> distributions: centos, fedora, ubuntu, suse. In all cases, the config
> path was /boot/efi/EFI/*distname*/grub.cfg
> 
> The main purpose of the patch is to improve support for converting of
> vm with UEFI for most distributions. Unfortunately this patch does not
> solve the problem for all distributions, for example Debian does not
> store grub config on the EFI partition, therefore for such
> distributions another solution is necessary.
> 
> Signed-off-by: Pavel Butsykin <pbutsykin at virtuozzo.com>
> Signed-off-by: Richard W.M. Jones <rjones at redhat.com>
> ---

Mostly LGTM, just one thing it can be improved.

>  class bootloader_grub1 (g : G.guestfs) inspect grub_config =
> +  let () =
> +    if grub_config = "/boot/efi/EFI/redhat/grub.conf" then
> +      g#aug_transform "grub" "/boot/efi/EFI/redhat/grub.conf" in

Augeas < 1.7.0 does not like adding a transformation for a file with
the same lens it is handled already [1]. As workaround, we can first
try to list the configuration file: if there are no results, then the
transformation is applied. Something like:

  let () =
    (* Apply the "grub" lens if it is not handling the file
     * already -- Augeas < 1.7.0 will error out otherwise.
     *)
    if g#aug_ls grub_config = [||] then
      g#aug_transform "grub" grub_config in

This way it will:
- pick configuration files for any distro, not just redhat-based ones
  (fixing what Pavel reported)
- work fine (by doing nothing) with Augeas >= 1.7.0

[1] https://www.redhat.com/archives/augeas-devel/2016-November/thread.html

-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20161111/267dd081/attachment.sig>


More information about the Libguestfs mailing list