virt-v2v/SOURCES/0014-convert_linux-extract-qemu-guest-agent-package-name.patch
2022-09-28 20:51:26 +00:00

83 lines
3.5 KiB
Diff

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