import virt-v2v-1.42.0-19.module+el8.6.0+15577+2ffd6ffa

This commit is contained in:
CentOS Sources 2022-08-02 03:08:13 -04:00 committed by root
parent 4b35db3e90
commit f70f19359e
2 changed files with 105 additions and 1 deletions

View File

@ -0,0 +1,99 @@
From 6c1260b543ed5a947481f7b12943494eeea085fb Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 25 May 2022 16:47:04 +0100
Subject: [PATCH] convert: If listing RPM applications fails, rebuild DB and
retry
In libguestfs before commit 488245ed6c ("daemon: rpm: Check return
values from librpm calls") we didn't bother to check the return values
from any librpm calls. In some cases where the RPM database is
faulty, this caused us to return a zero-length array of applications
(but no error indication). Libguestfs has subsequently been fixed so
now it returns an error if the RPM database is corrupt.
This commit changes virt-v2v behaviour so that if either
guestfs_inspect_list_applications2 returns a zero-length list (ie. old
libguestfs) or it throws an error (new libguestfs) then we attempt to
rebuild the RPM database and retry the operation. Rebuilding the
database can recover from some but not all RPM DB corruption.
See-also: https://bugzilla.redhat.com/show_bug.cgi?id=2089623#c12
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2089623
Reported-by: Xiaodai Wang
Reported-by: Ming Xie
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 31bf5db25bcfd8a9f5a48cc0523abae28861de9a)
(cherry picked from commit 87e5404d20ec54d16d22a7bb8f06ea91076c91f7)
---
v2v/inspect_source.ml | 34 ++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/v2v/inspect_source.ml b/v2v/inspect_source.ml
index b8a3c8ad..554fde1d 100644
--- a/v2v/inspect_source.ml
+++ b/v2v/inspect_source.ml
@@ -34,6 +34,7 @@ let rec inspect_source root_choice g =
reject_if_not_installed_image g root;
let typ = g#inspect_get_type root in
+ let package_format = g#inspect_get_package_format root in
(* Mount up the filesystems. *)
let mps = g#inspect_get_mountpoints root in
@@ -71,7 +72,7 @@ let rec inspect_source root_choice g =
) mps;
(* Get list of applications/packages installed. *)
- let apps = g#inspect_list_applications2 root in
+ let apps = list_applications g root package_format in
let apps = Array.to_list apps in
(* A map of app2_name -> application2, for easier lookups. Note
@@ -106,7 +107,7 @@ let rec inspect_source root_choice g =
i_arch = g#inspect_get_arch root;
i_major_version = g#inspect_get_major_version root;
i_minor_version = g#inspect_get_minor_version root;
- i_package_format = g#inspect_get_package_format root;
+ i_package_format = package_format;
i_package_management = g#inspect_get_package_management root;
i_product_name = g#inspect_get_product_name root;
i_product_variant = g#inspect_get_product_variant root;
@@ -186,6 +187,35 @@ and reject_if_not_installed_image g root =
if fmt <> "installed" then
error (f_"libguestfs thinks this is not an installed operating system (it might be, for example, an installer disk or live CD). If this is wrong, it is probably a bug in libguestfs. root=%s fmt=%s") root fmt
+(* Wrapper around g#inspect_list_applications2 which, for RPM
+ * guests, on failure tries to rebuild the RPM database before
+ * repeating the operation.
+ *)
+and list_applications g root = function
+ | "rpm" ->
+ (* RPM guest.
+ *
+ * In libguestfs before commit 488245ed6c ("daemon: rpm: Check
+ * return values from librpm calls"), a corrupt RPM database
+ * would return an empty array here with no exception. Hence
+ * the check below which turns empty array => exception. In
+ * libguestfs after that commit, inspect_list_applications2
+ * will raise an exception if it detects a corrupt RPM database.
+ *)
+ (try
+ let apps = g#inspect_list_applications2 root in
+ if apps = [||] then raise (G.Error "no applications returned");
+ apps
+ with G.Error msg ->
+ debug "%s" msg;
+ debug "rebuilding RPM database and retrying ...";
+ ignore (g#sh "rpmdb --rebuilddb");
+ g#inspect_list_applications2 root
+ )
+ | _ ->
+ (* Non-RPM guest, just do it. *)
+ g#inspect_list_applications2 root
+
(* See if this guest could use UEFI to boot. It should use GPT and
* it should have an EFI System Partition (ESP).
*
--
2.31.1

View File

@ -10,7 +10,7 @@
Name: virt-v2v
Epoch: 1
Version: 1.42.0
Release: 18%{?dist}
Release: 19%{?dist}
Summary: Convert a virtual machine to run on KVM
License: GPLv2+
@ -83,6 +83,7 @@ Patch0044: 0044-v2v-vcenter-Implement-cookie-scripts.patch
Patch0045: 0045-convert-convert_windows.ml-Handle-date-formats-with-.patch
Patch0046: 0046-v2v-Force-format-of-input-to-be-specified.patch
Patch0047: 0047-v2v-Cope-with-libvirt-vpx-esx-driver-which-does-not-.patch
Patch0048: 0048-convert-If-listing-RPM-applications-fails-rebuild-DB.patch
# Patches which apply to the common/ submodule.
# These have to be hand-modified.
@ -326,6 +327,10 @@ rm $RPM_BUILD_ROOT%{_mandir}/man1/virt-v2v-test-harness.1*
%changelog
* Tue Jun 07 2022 Richard W.M. Jones <rjones@redhat.com> - 1:1.42.0-19
- If listing RPM applications fails, rebuild DB and retry
resolves: rhbz#2093415
* Wed Nov 24 2021 Richard W.M. Jones <rjones@redhat.com> - 1:1.42.0-18
- Additional fix for backing file specified without backing format
related: rhbz#2025769