|
|
c1a9fa |
From 7dd396af54df3f7563aa3a42b3c17547710aec67 Mon Sep 17 00:00:00 2001
|
|
|
c1a9fa |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
c1a9fa |
Date: Wed, 17 Aug 2022 16:47:36 +0200
|
|
|
c1a9fa |
Subject: [PATCH] convert_linux: start the QEMU guest agent in a
|
|
|
c1a9fa |
distro-specific way
|
|
|
c1a9fa |
|
|
|
c1a9fa |
The current command "service <package-name> start" does not apply to
|
|
|
c1a9fa |
RHEL-6; the service name ("qemu-ga") differs from the package name
|
|
|
c1a9fa |
("qemu-guest-agent") there.
|
|
|
c1a9fa |
|
|
|
c1a9fa |
Overhaul the logic -- detach the command from the package name; cover the
|
|
|
c1a9fa |
RHEL, ALT, SUSE and Debian families separately. Remove the "chkconfig"
|
|
|
c1a9fa |
command, as in all tested / investigated cases, it is unnecessary.
|
|
|
c1a9fa |
|
|
|
c1a9fa |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2028764
|
|
|
c1a9fa |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
c1a9fa |
Message-Id: <20220817144736.18850-1-lersek@redhat.com>
|
|
|
c1a9fa |
Acked-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
c1a9fa |
(cherry picked from commit ad2b4f2e50950a5798a75359badb526290aa92e7)
|
|
|
c1a9fa |
---
|
|
|
c1a9fa |
convert/convert_linux.ml | 56 ++++++++++++++++++++++++++++------------
|
|
|
c1a9fa |
1 file changed, 40 insertions(+), 16 deletions(-)
|
|
|
c1a9fa |
|
|
|
c1a9fa |
diff --git a/convert/convert_linux.ml b/convert/convert_linux.ml
|
|
|
c1a9fa |
index 2aaa438e..b8e9ad15 100644
|
|
|
c1a9fa |
--- a/convert/convert_linux.ml
|
|
|
c1a9fa |
+++ b/convert/convert_linux.ml
|
|
|
c1a9fa |
@@ -66,6 +66,34 @@ let convert (g : G.guestfs) source inspect keep_serial_console _ =
|
|
|
c1a9fa |
| _ -> None
|
|
|
c1a9fa |
in
|
|
|
c1a9fa |
|
|
|
c1a9fa |
+ let qga_svc_start_cmd family distro major =
|
|
|
c1a9fa |
+ match family, distro, major with
|
|
|
c1a9fa |
+ | `RHEL_family, ( "rhel" | "centos" | "scientificlinux" | "redhat-based" |
|
|
|
c1a9fa |
+ "oraclelinux" ), 6 ->
|
|
|
c1a9fa |
+ (* https://bugzilla.redhat.com/show_bug.cgi?id=2028764#c52 *)
|
|
|
c1a9fa |
+ Some "service qemu-ga start"
|
|
|
c1a9fa |
+
|
|
|
c1a9fa |
+ | `RHEL_family, _, _ ->
|
|
|
c1a9fa |
+ (* https://bugzilla.redhat.com/show_bug.cgi?id=2028764#c52 *)
|
|
|
c1a9fa |
+ Some "systemctl start qemu-guest-agent"
|
|
|
c1a9fa |
+
|
|
|
c1a9fa |
+ | `ALT_family, _, _ ->
|
|
|
c1a9fa |
+ (* https://bugzilla.redhat.com/show_bug.cgi?id=2028764#c45 *)
|
|
|
c1a9fa |
+ Some "systemctl start qemu-guest-agent"
|
|
|
c1a9fa |
+
|
|
|
c1a9fa |
+ | `SUSE_family, _, _ ->
|
|
|
c1a9fa |
+ (* https://bugzilla.redhat.com/show_bug.cgi?id=2028764#c51 *)
|
|
|
c1a9fa |
+ None
|
|
|
c1a9fa |
+
|
|
|
c1a9fa |
+ | `Debian_family, _, _ ->
|
|
|
c1a9fa |
+ (* https://bugzilla.redhat.com/show_bug.cgi?id=2028764#c42 *)
|
|
|
c1a9fa |
+ Some "service qemu-guest-agent start"
|
|
|
c1a9fa |
+
|
|
|
c1a9fa |
+ | _ ->
|
|
|
c1a9fa |
+ (* should never be called when "qga_pkg_of_family" returns None *)
|
|
|
c1a9fa |
+ assert false
|
|
|
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 |
@@ -615,23 +643,19 @@ let convert (g : G.guestfs) source inspect keep_serial_console _ =
|
|
|
c1a9fa |
\ \ rm -f %s\n\
|
|
|
c1a9fa |
fi\n" selinux_enforcing selinux_enforcing);
|
|
|
c1a9fa |
|
|
|
c1a9fa |
- (* Start the agent now and at subsequent boots. The following
|
|
|
c1a9fa |
- * commands should work on both sysvinit distros / distro versions
|
|
|
c1a9fa |
- * (regardless of "/etc/rc.d/" vs. "/etc/init.d/" being the scheme
|
|
|
c1a9fa |
- * in use) and systemd distros (via redirection to systemctl).
|
|
|
c1a9fa |
- *
|
|
|
c1a9fa |
- * On distros where the chkconfig command is redirected to
|
|
|
c1a9fa |
- * systemctl, the chkconfig command is likely superfluous. That's
|
|
|
c1a9fa |
- * because on systemd distros, the QGA package comes with such
|
|
|
c1a9fa |
- * runtime dependencies / triggers that the presence of the
|
|
|
c1a9fa |
- * virtio-serial port named "org.qemu.guest_agent.0" automatically
|
|
|
c1a9fa |
- * starts the agent during (second and later) boots. However, even
|
|
|
c1a9fa |
- * on such distros, the chkconfig command should do no harm.
|
|
|
c1a9fa |
+ (* On all the distro families covered by "qga_pkg_of_family" and
|
|
|
c1a9fa |
+ * "qga_svc_start_cmd", the QEMU guest agent service is always
|
|
|
c1a9fa |
+ * enabled by package installation for *subsequent* boots. Package
|
|
|
c1a9fa |
+ * installation may or may not enable the service for the current
|
|
|
c1a9fa |
+ * (i.e., first) boot, however, so try that here manually.
|
|
|
c1a9fa |
*)
|
|
|
c1a9fa |
- fbs "start qga"
|
|
|
c1a9fa |
- (sprintf "#!/bin/sh\n\
|
|
|
c1a9fa |
- service %s start\n\
|
|
|
c1a9fa |
- chkconfig %s on\n" qga_pkg qga_pkg)
|
|
|
c1a9fa |
+ match qga_svc_start_cmd family inspect.i_distro inspect.i_major_version
|
|
|
c1a9fa |
+ with
|
|
|
c1a9fa |
+ | None -> ()
|
|
|
c1a9fa |
+ | Some start_cmd ->
|
|
|
c1a9fa |
+ fbs "start qga"
|
|
|
c1a9fa |
+ (sprintf "#!/bin/sh\n\
|
|
|
c1a9fa |
+ %s\n" start_cmd)
|
|
|
c1a9fa |
with
|
|
|
c1a9fa |
| Guest_packages.Unknown_package_manager msg
|
|
|
c1a9fa |
| Guest_packages.Unimplemented_package_manager msg ->
|