Expose the aug_transform API through the library, so it's possible to add/remove Augeas transformations to handle files in custom places using existing lenses. --- daemon/augeas.c | 21 +++++++++++++++++++++ generator/actions.ml | 12 ++++++++++++ gobject/Makefile.inc | 2 ++ src/MAX_PROC_NR | 2 +- 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/daemon/augeas.c b/daemon/augeas.c index 14cc0cf..5adc959 100644 --- a/daemon/augeas.c +++ b/daemon/augeas.c @@ -491,3 +491,24 @@ do_aug_label (const char *augpath) return ret; /* caller frees */ } + +/* Takes optional arguments, consult optargs_bitmask. */ +int +do_aug_transform (const char *lens, const char *file, int remove) +{ + int r; + int excl = 0; /* add by default */ + + NEED_AUG (-1); + + if (optargs_bitmask & GUESTFS_AUG_TRANSFORM_REMOVE_BITMASK) + excl = remove; + + r = aug_transform (aug, lens, file, excl); + if (r == -1) { + AUGEAS_ERROR ("aug_transform: %s: %s: %s", lens, file, excl ? "excl" : "incl"); + return -1; + } + + return r; +} diff --git a/generator/actions.ml b/generator/actions.ml index eccef00..aa26649 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -13205,6 +13205,18 @@ only the unallocated blocks will be extracted. This is useful to detect hidden data or to retrieve deleted files which data units have not been overwritten yet." }; + { defaults with + name = "aug_transform"; added = (1, 35, 2); + style = RErr, [String "lens"; String "file"], [ OBool "remove"]; + proc_nr = Some 469; + shortdesc = "add/remove an Augeas lens transformation"; + longdesc = "\ +Add an Augeas transformation for the specified C<lens> so it can +handle C<file>. + +If C<remove> is true (C<false> by default), then the transformation +is removed." }; + ] (* Non-API meta-commands available only in guestfish. diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc index 7698c2a..149e4c6 100644 --- a/gobject/Makefile.inc +++ b/gobject/Makefile.inc @@ -53,6 +53,7 @@ guestfs_gobject_headers= \ include/guestfs-gobject/optargs-add_drive.h \ include/guestfs-gobject/optargs-add_drive_scratch.h \ include/guestfs-gobject/optargs-add_libvirt_dom.h \ + include/guestfs-gobject/optargs-aug_transform.h \ include/guestfs-gobject/optargs-btrfs_filesystem_defragment.h \ include/guestfs-gobject/optargs-btrfs_filesystem_resize.h \ include/guestfs-gobject/optargs-btrfs_fsck.h \ @@ -143,6 +144,7 @@ guestfs_gobject_sources= \ src/optargs-add_drive.c \ src/optargs-add_drive_scratch.c \ src/optargs-add_libvirt_dom.c \ + src/optargs-aug_transform.c \ src/optargs-btrfs_filesystem_defragment.c \ src/optargs-btrfs_filesystem_resize.c \ src/optargs-btrfs_fsck.c \ diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index 1023289..5ef9d24 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -468 +469 -- 2.7.4
Pino Toscano
2016-Aug-19 14:25 UTC
[Libguestfs] [PATCH] v2v: linux: handle UEFI path for Grub1 (RHBZ#1152369)
Add also /boot/efi/EFI/redhat/grub.conf as configuration of Grub 1; since the "grub" lens of Augeas does not handle this path, add a transformation so Augeas can parse it. --- v2v/convert_linux.ml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml index 9941750..2a53315 100644 --- a/v2v/convert_linux.ml +++ b/v2v/convert_linux.ml @@ -96,7 +96,11 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps ] in let locations match inspect.i_firmware with - | I_UEFI _ -> ("/boot/efi/EFI/redhat/grub.cfg", `Grub2) :: locations + | I_UEFI _ -> + [ + "/boot/efi/EFI/redhat/grub.cfg", `Grub2; + "/boot/efi/EFI/redhat/grub.conf", `Grub1; + ] @ locations | I_BIOS -> locations in try List.find ( @@ -111,6 +115,11 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps match grub with | `Grub2 -> "" | `Grub1 -> + if grub_config = "/boot/efi/EFI/redhat/grub.conf" then ( + g#aug_transform "grub" "/boot/efi/EFI/redhat/grub.conf"; + Linux.augeas_reload g; + ); + let mounts = g#inspect_get_mountpoints inspect.i_root in try List.find ( -- 2.7.4
Richard W.M. Jones
2016-Aug-25 14:52 UTC
Re: [Libguestfs] [PATCH] v2v: linux: handle UEFI path for Grub1 (RHBZ#1152369)
On Fri, Aug 19, 2016 at 04:25:42PM +0200, Pino Toscano wrote:> Add also /boot/efi/EFI/redhat/grub.conf as configuration of Grub 1; > since the "grub" lens of Augeas does not handle this path, add a > transformation so Augeas can parse it. > --- > v2v/convert_linux.ml | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml > index 9941750..2a53315 100644 > --- a/v2v/convert_linux.ml > +++ b/v2v/convert_linux.ml > @@ -96,7 +96,11 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps > ] in > let locations > match inspect.i_firmware with > - | I_UEFI _ -> ("/boot/efi/EFI/redhat/grub.cfg", `Grub2) :: locations > + | I_UEFI _ -> > + [ > + "/boot/efi/EFI/redhat/grub.cfg", `Grub2; > + "/boot/efi/EFI/redhat/grub.conf", `Grub1; > + ] @ locations > | I_BIOS -> locations in > try > List.find ( > @@ -111,6 +115,11 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps > match grub with > | `Grub2 -> "" > | `Grub1 -> > + if grub_config = "/boot/efi/EFI/redhat/grub.conf" then ( > + g#aug_transform "grub" "/boot/efi/EFI/redhat/grub.conf"; > + Linux.augeas_reload g; > + ); > + > let mounts = g#inspect_get_mountpoints inspect.i_root in > try > List.find (ACK both. You might need to adjust the augeas min version detection in m4/guestfs_libraries.m4. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Seemingly Similar Threads
- [PATCH v3] v2v: bootloaders: search grub config for all distributions
- [PATCH v5 0/3] v2v and augeas
- [PATCH] v2v: linux: handle UEFI path for Grub1 (RHBZ#1152369)
- [PATCH v2] v2v: factor out bootloader handling
- [PATCH] v2v: fix UEFI bootloader for linux guests