RHEL >= 9.0 on x86_64 requires the processor to support the "x86-64-v2"
microarchitecture level, which the default QEMU VCPU model does not
satisfy. Activate host-passthrough for such guest OSes.

(Libosinfo does not track processor support, so in the future we may have
to extend the expression added in this patch to other distros.)

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2076013
Signed-off-by: Laszlo Ersek <[email protected]>
---
 convert/convert_linux.ml | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/convert/convert_linux.ml b/convert/convert_linux.ml
index 93b3922cac60..5660494973b1 100644
--- a/convert/convert_linux.ml
+++ b/convert/convert_linux.ml
@@ -139,65 +139,73 @@ let convert (g : G.guestfs) source inspect 
keep_serial_console _ =
            let { Libosinfo_utils.q35; vio10 } =
              Libosinfo_utils.os_support_of_osinfo_device_list devices in
            (if q35 then Q35 else I440FX), vio10
          with
          | Not_found ->
            (* Pivot on the year 2007.  Any Linux distro from earlier than 2007
             * should use i440fx, anything 2007 or newer should use q35.
             *)
            (match inspect.i_distro, inspect.i_major_version with
             | "fedora", _ -> Q35
             | ("rhel"|"centos"|"scientificlinux"|"redhat-based"|"oraclelinux"),
               major ->
               if major <= 4 then I440FX else Q35
             | ("sles"|"suse-based"|"opensuse"), major ->
               if major < 10 then I440FX else Q35
             | ("debian"|"ubuntu"|"linuxmint"|"kalilinux"), major ->
               if major < 4 then I440FX else Q35
 
             (* reasonable default for all modern Linux kernels *)
             | _, _ -> Q35
            ), true
         )
 
       | _ -> Virt, true
     in
 
+    (* RHEL >= 9.0 on x86_64 requires the processor to support the "x86-64-v2"
+     * microarchitecture level, which the default QEMU VCPU model does not
+     * satisfy.  Refer to RHBZ#2076013.
+     *)
+    let default_cpu_suffices = inspect.i_distro <> "rhel" ||
+                               inspect.i_arch <> "x86_64" ||
+                               inspect.i_major_version < 9 in
+
     (* Return guest capabilities from the convert () function. *)
     let guestcaps = {
       gcaps_block_bus = block_type;
       gcaps_net_bus = net_type;
       gcaps_virtio_rng = kernel.ki_supports_virtio_rng;
       gcaps_virtio_balloon = kernel.ki_supports_virtio_balloon;
       gcaps_isa_pvpanic = kernel.ki_supports_isa_pvpanic;
       gcaps_virtio_socket = kernel.ki_supports_virtio_socket;
       gcaps_machine = machine;
       gcaps_arch = Utils.kvm_arch inspect.i_arch;
       gcaps_acpi = acpi;
       gcaps_virtio_1_0 = virtio_1_0;
-      gcaps_default_cpu = true;
+      gcaps_default_cpu = default_cpu_suffices;
     } in
 
     guestcaps
 
   and augeas_grub_configuration () =
     if bootloader#set_augeas_configuration () then
       Linux.augeas_reload g
 
   and unconfigure_xen () =
     (* Remove kmod-xenpv-* (RHEL 3). *)
     let xenmods =
       List.filter_map (
         fun { G.app2_name = name } ->
           if name = "kmod-xenpv" || String.is_prefix name "kmod-xenpv-" then
             Some name
           else
             None
       ) inspect.i_apps in
     Linux.remove g inspect xenmods;
 
     (* Undo related nastiness if kmod-xenpv was installed. *)
     if xenmods <> [] then (
       (* kmod-xenpv modules may have been manually copied to other kernels.
        * Hunt them down and destroy them.
        *)
       let dirs = g#find "/lib/modules" in
-- 
2.19.1.3.g30247aa5d201

_______________________________________________
Libguestfs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to