[Libguestfs] [v2v PATCH 3/4] convert_linux: extract qemu-guest-agent package name
Richard W.M. Jones
rjones at redhat.com
Tue Jun 7 12:45:50 UTC 2022
On Mon, Jun 06, 2022 at 04:19:40PM +0200, Laszlo Ersek wrote:
> 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§ion=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 at redhat.com>
> ---
> 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 79462aa1e7ae..2ddbc07aa86a 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
> --
> 2.19.1.3.g30247aa5d201
Neutral change, so:
Reviewed-by: Richard W.M. Jones <rjones at redhat.com>
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
More information about the Libguestfs
mailing list