convert: linux: Ignore /etc/lvm/archive/*.vg files

resolves: RHEL-113820
mlcustomize/inject_virtio_win.ml: Use viostor.inf instead of guestor
resolves: RHEL-112517
Fix for setting boot order for Linux guests based on grub location
resolves: RHEL-115989, RHEL-115990
This commit is contained in:
Richard W.M. Jones 2025-09-18 14:38:12 +01:00
parent f79affa10c
commit 9593fa2f52
13 changed files with 277 additions and 18 deletions

View File

@ -0,0 +1,73 @@
From 1f6d4e079dd5fdc9ed4c84ada57835b733bbbe78 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 18 Sep 2025 12:21:58 +0100
Subject: [PATCH] convert: linux: Move uninstall_packages function below
do_convert
The structure of conversion is the do_convert () function, followed by
the subfunctions that are used for conversion. Move
uninstall_packages below do_convert so it's like all the other
functions.
This is just code motion, there is no functional change.
Updates: commit b3268a13beca4da218e7ffe4648a18420296103a
---
convert/convert_linux.ml | 37 ++++++++++++++++++-------------------
1 file changed, 18 insertions(+), 19 deletions(-)
diff --git a/convert/convert_linux.ml b/convert/convert_linux.ml
index 872fa663..f339361a 100644
--- a/convert/convert_linux.ml
+++ b/convert/convert_linux.ml
@@ -131,25 +131,6 @@ let convert (g : G.guestfs) source inspect i_firmware _ keep_serial_console _ =
(*----------------------------------------------------------------------*)
(* Conversion step. *)
- let uninstall_packages pkgs =
- if pkgs <> [] then (
- let cmd =
- try Guest_packages.uninstall_command pkgs inspect.i_package_management
- with
- | Guest_packages.Unknown_package_manager msg
- | Guest_packages.Unimplemented_package_manager msg ->
- error "%s" msg
- in
- (try ignore (g#sh cmd)
- with G.Error msg ->
- warning (f_"could not uninstall packages %s: %s (ignored)")
- (String.concat " " pkgs) msg
- );
- (* Reload Augeas in case anything changed. *)
- Linux.augeas_reload g
- )
- in
-
let rec do_convert () =
augeas_grub_configuration ();
@@ -1378,6 +1359,24 @@ fi
"/etc/blkid/blkid.tab"; "/etc/blkid.tab";
"/etc/lvm/cache/.cache"; "/etc/lvm/devices/system.devices"
];
+
+ and uninstall_packages pkgs =
+ if pkgs <> [] then (
+ let cmd =
+ try Guest_packages.uninstall_command pkgs inspect.i_package_management
+ with
+ | Guest_packages.Unknown_package_manager msg
+ | Guest_packages.Unimplemented_package_manager msg ->
+ error "%s" msg
+ in
+ (try ignore (g#sh cmd)
+ with G.Error msg ->
+ warning (f_"could not uninstall packages %s: %s (ignored)")
+ (String.concat " " pkgs) msg
+ );
+ (* Reload Augeas in case anything changed. *)
+ Linux.augeas_reload g
+ )
in
do_convert ()

View File

@ -0,0 +1,59 @@
From 46af0d612adeb43af416b8a4cc7d4b39c58355bf Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 18 Sep 2025 12:27:22 +0100
Subject: [PATCH] convert: Rename uninstall_packages to indicate it is
best-effort
Rename uninstall_packages -> uninstall_packages_nonfatal to indicate
that this is a best effort operation. I also added a comment about
what this function does.
---
convert/convert_linux.ml | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/convert/convert_linux.ml b/convert/convert_linux.ml
index f339361a..6e08b857 100644
--- a/convert/convert_linux.ml
+++ b/convert/convert_linux.ml
@@ -258,7 +258,7 @@ let convert (g : G.guestfs) source inspect i_firmware _ keep_serial_console _ =
fun { G.app2_name = name } -> name = package_name
) inspect.i_apps in
if has_guest_additions then
- uninstall_packages [package_name];
+ uninstall_packages_nonfatal [package_name];
(* Guest Additions might have been installed from a tarball. The
* above code won't detect this case. Look for the uninstall tool
@@ -403,7 +403,7 @@ let convert (g : G.guestfs) source inspect i_firmware _ keep_serial_console _ =
)
);
- uninstall_packages !remove;
+ uninstall_packages_nonfatal !remove;
(* VMware Tools may have been installed from a tarball, so the
* above code won't remove it. Look for the uninstall tool and run
@@ -451,7 +451,7 @@ let convert (g : G.guestfs) source inspect i_firmware _ keep_serial_console _ =
let pkgs = List.map (fun { G.app2_name = name } -> name) pkgs in
if pkgs <> [] then (
- uninstall_packages pkgs;
+ uninstall_packages_nonfatal pkgs;
(* Installing these guest utilities automatically unconfigures
* ttys in /etc/inittab if the system uses it. We need to put
@@ -1360,7 +1360,13 @@ fi
"/etc/lvm/cache/.cache"; "/etc/lvm/devices/system.devices"
];
- and uninstall_packages pkgs =
+ (* This is a wrapper around Guestfs_packages.uninstall_command
+ * which catches errors and turns them into warnings, since
+ * uninstalling packages is best effort in virt-v2v. It also
+ * reloads the Augeas configuration since removing packages might
+ * change /etc files.
+ *)
+ and uninstall_packages_nonfatal pkgs =
if pkgs <> [] then (
let cmd =
try Guest_packages.uninstall_command pkgs inspect.i_package_management

View File

@ -0,0 +1,68 @@
From d240eeb93950990bbb95b9d9654ba8bda43c3a04 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 18 Sep 2025 10:37:54 +0100
Subject: [PATCH] convert: linux: Ignore /etc/lvm/archive/*.vg files
RHEL 7.2 had a bug where old volume group archive files did not get
cleaned up. This was fixed later, but when converting some long-lived
RHEL 7.2 guests where many thousands of these files might have
accumulated, Augeas would try to read them all into memory, and this
would fail in the restricted environment of the libguestfs appliance.
Since we don't care at all about these files, fix this by ignoring
these files.
I added a generic mechanism here to allow us to extend this list on a
case-by-case basis in future.
There are other places in virt-v2v where 'aug_init' will be called in
a way that will load everything (eg. setting hostname and password),
but we can fix those later if they happen to customers.
Fixes: https://issues.redhat.com/browse/RHEL-113820
Thanks: Sean Haselden
Thanks: Alasdair Kergon
---
convert/convert_linux.ml | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/convert/convert_linux.ml b/convert/convert_linux.ml
index 6e08b857..45ff8036 100644
--- a/convert/convert_linux.ml
+++ b/convert/convert_linux.ml
@@ -110,11 +110,31 @@ let convert (g : G.guestfs) source inspect i_firmware _ keep_serial_console _ =
required in libguestfs.");
(* We use Augeas for inspection and conversion, so initialize it early.
- * Calling debug_augeas_errors will display any //error nodes in
- * debugging output if verbose (but otherwise it does nothing).
*)
- g#aug_init "/" 1;
- debug_augeas_errors g;
+ let () =
+ let aug_save_backup = 1
+ and aug_no_load = 32 in
+ g#aug_init "/" (aug_save_backup + aug_no_load);
+
+ (* Exclude some lense includes which are problematic on a case-by-case
+ * basis. Note the double quotes are part of the incl, and the incl
+ * must exactly match the definition in the Augeas lens file.
+ * - "/etc/lvm/archive/*.vg" because of RHEL-113820
+ *)
+ let removed_incls = [ {|"/etc/lvm/archive/*.vg"|} ] in
+ List.iter (
+ fun incl ->
+ let augpath = sprintf "/augeas/load//incl[%s]" incl in
+ let n = g#aug_rm augpath in
+ debug "convert_linux: removed %d incl(s) matching %s" n incl;
+ ) removed_incls;
+
+ g#aug_load ();
+
+ (* Calling debug_augeas_errors will display any //error nodes in
+ * debugging output if verbose (but otherwise it does nothing).
+ *)
+ debug_augeas_errors g in
(* Clean RPM database. This must be done early to avoid RHBZ#1143866. *)
Array.iter g#rm_f (g#glob_expand "/var/lib/rpm/__db.00?");

View File

@ -1,4 +1,4 @@
From f7cf3e5f586fec88b1955664f51bc02a65b508ca Mon Sep 17 00:00:00 2001
From e0ebc3ec50bd95d517f4e97a9196259fc2d9b7e9 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sun, 30 Aug 2015 03:21:57 -0400
Subject: [PATCH] RHEL: Fixes for libguestfs-winsupport.

View File

@ -1,4 +1,4 @@
From 3360e6b8fcfaab0f03836bac2f1292ba41a4e73b Mon Sep 17 00:00:00 2001
From 8252595a0b8c6cc3d49343c724620835aab577ea Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sun, 28 Sep 2014 19:14:43 +0100
Subject: [PATCH] RHEL: v2v: Select correct qemu binary for -o qemu mode

View File

@ -1,4 +1,4 @@
From c08c7c740d2d54a9ae0bbd3924926faf157532e7 Mon Sep 17 00:00:00 2001
From 17d92538e3dd2c1788163a6707d8f923f4a3f284 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 30 Sep 2014 10:50:27 +0100
Subject: [PATCH] RHEL: v2v: Disable the --qemu-boot / -oo qemu-boot option

View File

@ -1,4 +1,4 @@
From 7a9779d640148f3ac727423dd02e2a01a18c475f Mon Sep 17 00:00:00 2001
From cdcb70c77b22a2dcb5ffae5ad43d561101be8376 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 24 Apr 2015 09:45:41 -0400
Subject: [PATCH] RHEL: Fix list of supported sound cards to match RHEL qemu

View File

@ -1,4 +1,4 @@
From 7334270d0037d43309e12ee985818e7af7ea89fd Mon Sep 17 00:00:00 2001
From c00816e9a4f16b074c62f74f513cfc25d64cee17 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 2 Mar 2017 14:21:37 +0100
Subject: [PATCH] RHEL: v2v: -i disk: force VNC as display (RHBZ#1372671)

View File

@ -1,4 +1,4 @@
From 26945c86859c1d0b047aa3f16f19effa2cf844e5 Mon Sep 17 00:00:00 2001
From aef356963fdac8330de73c0d181ec2fa61c108ca Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Tue, 26 Mar 2019 09:42:25 +0100
Subject: [PATCH] RHEL: point to KB for supported v2v hypervisors/guests

View File

@ -1,4 +1,4 @@
From 6a49ca69b3e8d9639c76dad95d0b33859a8f70e0 Mon Sep 17 00:00:00 2001
From 141d4f6e743c66bef61d8378c1ef1bdc4f25df83 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 5 Jul 2022 11:58:09 +0100
Subject: [PATCH] RHEL: tests: Remove btrfs test

View File

@ -1,4 +1,4 @@
From 51db9a96627e87b547df801cffbe913eb68da20a Mon Sep 17 00:00:00 2001
From 071ccf109b15d6af641e308645e99c74ecc20ad1 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 9 Jul 2024 11:30:09 +0100
Subject: [PATCH] RHEL: Add warning about virt-v2v-in-place not being supported

View File

@ -0,0 +1,49 @@
From 1471b40d3563987f0170229b04a5ebe2ca1bf82b Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 18 Sep 2025 14:33:25 +0100
Subject: [PATCH] Update common submodule
NOTE: This is a temporary RHEL 10.2 patch.
Pull in the following commits from the common submodule:
Richard W.M. Jones (2):
daemon, generator: Use power of 2 for initial size of Hashtbl.create
mlcustomize/inject_virtio_win.ml: Use viostor.inf instead of guestor
Fixes: https://issues.redhat.com/browse/RHEL-112517
---
common | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Submodule common 5be8d552..ad415701:
diff --git a/common/mlcustomize/customize_run.ml b/common/mlcustomize/customize_run.ml
index ff719f4e..64afd3ab 100644
--- a/common/mlcustomize/customize_run.ml
+++ b/common/mlcustomize/customize_run.ml
@@ -97,7 +97,7 @@ let run (g : G.guestfs) root (ops : ops) =
) in
(* Store the passwords and set them all at the end. *)
- let passwords = Hashtbl.create 13 in
+ let passwords = Hashtbl.create 16 in
let set_password user pw =
if Hashtbl.mem passwords user then
error (f_"multiple --root-password/--password options set the \
diff --git a/common/mlcustomize/inject_virtio_win.ml b/common/mlcustomize/inject_virtio_win.ml
index b26b14d3..2056d148 100644
--- a/common/mlcustomize/inject_virtio_win.ml
+++ b/common/mlcustomize/inject_virtio_win.ml
@@ -310,9 +310,9 @@ and ddb_regedits inspect drv_name drv_pciid =
* one must add keys into the DriverDatabase.
*)
- let drv_inf = "guestor.inf" in
- let drv_inf_label = drv_inf ^ "_tmp" in
- let drv_config = "guestor_conf" in
+ let drv_inf = "viostor.inf" in
+ let drv_inf_label = drv_inf ^ "_amd64_0000000000000000" in
+ let drv_config = "scsi_inst" in
[
[ "DriverDatabase"; "DriverInfFiles"; drv_inf ],

View File

@ -45,7 +45,7 @@ ExclusiveArch: x86_64
Name: virt-v2v
Epoch: 1
Version: 2.9.6
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Convert a virtual machine to run on KVM
License: GPL-2.0-or-later AND LGPL-2.0-or-later
@ -67,14 +67,18 @@ Source3: copy-patches.sh
# Patches.
Patch0001: 0001-convert-Look-for-GRUB-signature-first-to-identify-bo.patch
Patch0002: 0002-vddk-Make-the-thumbprint-optional.patch
Patch0003: 0003-RHEL-Fixes-for-libguestfs-winsupport.patch
Patch0004: 0004-RHEL-v2v-Select-correct-qemu-binary-for-o-qemu-mode-.patch
Patch0005: 0005-RHEL-v2v-Disable-the-qemu-boot-oo-qemu-boot-option-R.patch
Patch0006: 0006-RHEL-Fix-list-of-supported-sound-cards-to-match-RHEL.patch
Patch0007: 0007-RHEL-v2v-i-disk-force-VNC-as-display-RHBZ-1372671.patch
Patch0008: 0008-RHEL-point-to-KB-for-supported-v2v-hypervisors-guest.patch
Patch0009: 0009-RHEL-tests-Remove-btrfs-test.patch
Patch0010: 0010-RHEL-Add-warning-about-virt-v2v-in-place-not-being-s.patch
Patch0003: 0003-convert-linux-Move-uninstall_packages-function-below.patch
Patch0004: 0004-convert-Rename-uninstall_packages-to-indicate-it-is-.patch
Patch0005: 0005-convert-linux-Ignore-etc-lvm-archive-.vg-files.patch
Patch0006: 0006-RHEL-Fixes-for-libguestfs-winsupport.patch
Patch0007: 0007-RHEL-v2v-Select-correct-qemu-binary-for-o-qemu-mode-.patch
Patch0008: 0008-RHEL-v2v-Disable-the-qemu-boot-oo-qemu-boot-option-R.patch
Patch0009: 0009-RHEL-Fix-list-of-supported-sound-cards-to-match-RHEL.patch
Patch0010: 0010-RHEL-v2v-i-disk-force-VNC-as-display-RHBZ-1372671.patch
Patch0011: 0011-RHEL-point-to-KB-for-supported-v2v-hypervisors-guest.patch
Patch0012: 0012-RHEL-tests-Remove-btrfs-test.patch
Patch0013: 0013-RHEL-Add-warning-about-virt-v2v-in-place-not-being-s.patch
Patch0014: 0014-Update-common-submodule.patch
BuildRequires: autoconf, automake, libtool
BuildRequires: make
@ -379,13 +383,19 @@ done
%changelog
* Thu Sep 11 2025 Richard W.M. Jones <rjones@redhat.com> - 1:2.9.6-1
* Thu Sep 18 2025 Richard W.M. Jones <rjones@redhat.com> - 1:2.9.6-2
- Rebase to virt-v2v 2.9.6
resolves: RHEL-111241
- Tighten permissions on windows C:\Program Files\Guestfs
resolves: RHEL-104352
- Don't output floppy XML with qemu lacks support
resolves: RHEL-90175
- convert: linux: Ignore /etc/lvm/archive/*.vg files
resolves: RHEL-113820
- mlcustomize/inject_virtio_win.ml: Use viostor.inf instead of guestor
resolves: RHEL-112517
- Fix for setting boot order for Linux guests based on grub location
resolves: RHEL-115989, RHEL-115990
* Thu Aug 21 2025 Richard W.M. Jones <rjones@redhat.com> - 1:2.8.1-9
- Rebase to virt-v2v 2.8.1