Blame SOURCES/0014-convert_linux-extract-qemu-guest-agent-package-name.patch

c1a9fa
From 82c7526e052d2aa64a6754ff0e1082937e3ee4bc Mon Sep 17 00:00:00 2001
c1a9fa
From: Laszlo Ersek <lersek@redhat.com>
c1a9fa
Date: Mon, 13 Jun 2022 19:01:34 +0200
c1a9fa
Subject: [PATCH] convert_linux: extract qemu-guest-agent package name
c1a9fa
c1a9fa
In commit a30383e35d34 ("v2v: linux: do not install qemu-guest-agent if
c1a9fa
already installed", 2019-09-20), the name of the package providing the
c1a9fa
QEMU guest agent was hard-coded as "qemu-guest-agent", regardless of
c1a9fa
distro family. Turns out this is actually correct (and may have been
c1a9fa
intentional, only it was not specifically documented): in all OS families
c1a9fa
currently recognized by our "family" function (`RHEL_family, `ALT_family,
c1a9fa
`SUSE_family, `Debian_family), the *binary* package is indeed called
c1a9fa
"qemu-guest-agent":
c1a9fa
c1a9fa
- https://brewweb.engineering.redhat.com/brew/packageinfo?packageID=47646
c1a9fa
- http://rpmfind.net/linux/rpm2html/search.php?query=qemu-guest-agent&submit=Search+...&system=&arch=
c1a9fa
- https://packages.altlinux.org/en/sisyphus/srpms/qemu/
c1a9fa
- https://packages.debian.org/search?keywords=qemu-guest-agent&searchon=names&suite=all&section=all
c1a9fa
c1a9fa
As a way of documenting this, extract the mapping to a new helper function
c1a9fa
named "qga_pkg_of_family".
c1a9fa
c1a9fa
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2028764
c1a9fa
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
c1a9fa
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
c1a9fa
Message-Id: <20220613170135.12557-4-lersek@redhat.com>
c1a9fa
(cherry picked from commit f65e8e68fb4eb9b8d40ac0fe7bfc3122a13e5251)
c1a9fa
---
c1a9fa
 convert/convert_linux.ml | 33 +++++++++++++++++++++++++--------
c1a9fa
 1 file changed, 25 insertions(+), 8 deletions(-)
c1a9fa
c1a9fa
diff --git a/convert/convert_linux.ml b/convert/convert_linux.ml
c1a9fa
index 79462aa1..2ddbc07a 100644
c1a9fa
--- a/convert/convert_linux.ml
c1a9fa
+++ b/convert/convert_linux.ml
c1a9fa
@@ -56,6 +56,16 @@ let convert (g : G.guestfs) source inspect keep_serial_console _ =
c1a9fa
     | "debian" | "ubuntu" | "linuxmint" | "kalilinux" -> `Debian_family
c1a9fa
     | _ -> assert false in
c1a9fa
 
c1a9fa
+  (* map the OS family name to the qemu-guest-agent package name *)
c1a9fa
+  let qga_pkg_of_family =
c1a9fa
+    function
c1a9fa
+    | `RHEL_family
c1a9fa
+    | `ALT_family
c1a9fa
+    | `SUSE_family
c1a9fa
+    | `Debian_family -> Some "qemu-guest-agent"
c1a9fa
+    | _ -> None
c1a9fa
+  in
c1a9fa
+
c1a9fa
   assert (inspect.i_package_format = "rpm" || inspect.i_package_format = "deb");
c1a9fa
 
c1a9fa
   (* Fail early if i_apps is empty.  Certain steps such as kernel
c1a9fa
@@ -539,14 +549,21 @@ let convert (g : G.guestfs) source inspect keep_serial_console _ =
c1a9fa
 
c1a9fa
   and install_linux_tools () =
c1a9fa
     (* It is not fatal if we fail to install the QEMU guest agent. *)
c1a9fa
-    let has_qemu_guest_agent =
c1a9fa
-      List.exists (
c1a9fa
-        fun { G.app2_name = name } ->
c1a9fa
-          name = "qemu-guest-agent"
c1a9fa
-      ) inspect.i_apps in
c1a9fa
-    if not has_qemu_guest_agent then
c1a9fa
-      (* FIXME -- install qemu-guest-agent here *)
c1a9fa
-      ()
c1a9fa
+    match qga_pkg_of_family family with
c1a9fa
+    | None -> warning (f_"The name of the package that provides the QEMU Guest \
c1a9fa
+                          Agent for this guest OS is unknown.  The guest agent \
c1a9fa
+                          will not be installed.  Please consider reporting a \
c1a9fa
+                          bug according to the BUGS section of the virt-v2v(1) \
c1a9fa
+                          manual.")
c1a9fa
+    | Some qga_pkg ->
c1a9fa
+        let has_qemu_guest_agent =
c1a9fa
+          List.exists (
c1a9fa
+            fun { G.app2_name = name } ->
c1a9fa
+              name = qga_pkg
c1a9fa
+          ) inspect.i_apps in
c1a9fa
+        if not has_qemu_guest_agent then
c1a9fa
+          (* FIXME -- install qemu-guest-agent here *)
c1a9fa
+          ()
c1a9fa
 
c1a9fa
   and configure_kernel () =
c1a9fa
     (* Previously this function would try to install kernels, but we