[Libguestfs] [PATCH v2v v2 3/3] -o qemu: Always use -cpu host unless overridden by source hypervisor

Richard W.M. Jones rjones at redhat.com
Fri Feb 17 11:44:30 UTC 2023


As with the prior commit, prefer -cpu host for all guests (except when
we have more information from the source hypervisor).  Although there
is the disadvantage that -cpu host is non-migratable, in practice it
would be very difficult to live migrate a host launched using direct
qemu commands.

Note that after this change, gcaps_arch_min_version is basically an
informational field.  No output uses it, but it will appear in debug
output and there's the possibility we might use it for a future output
mode.

Thanks: Laszlo Ersek
---
 lib/types.mli         | 6 +++++-
 output/output_qemu.ml | 6 +-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/types.mli b/lib/types.mli
index 743daa8a14..4a183dd3ae 100644
--- a/lib/types.mli
+++ b/lib/types.mli
@@ -268,7 +268,11 @@ type guestcaps = {
       minimum version.  Notably RHEL >= 9 requires at least x86_64-v2.
 
       If the guest is capable of running on QEMU's default VCPU model
-      for the architecture ([-cpu qemu64]) then this is set to [0]. *)
+      for the architecture ([-cpu qemu64]) then this is set to [0].
+
+      Note this capability is not actually used by any current output
+      mode.  It is retained in case we might use it in future, but we
+      might remove it if it is not used. *)
 
   gcaps_virtio_1_0 : bool;
   (** The guest supports the virtio devices that it does at the virtio-1.0
diff --git a/output/output_qemu.ml b/output/output_qemu.ml
index 491906ebf9..2bbacb6eda 100644
--- a/output/output_qemu.ml
+++ b/output/output_qemu.ml
@@ -175,11 +175,7 @@ module QEMU = struct
 
     arg "-m" (Int64.to_string (source.s_memory /^ 1024L /^ 1024L));
 
-    (match source.s_cpu_model, guestcaps.gcaps_arch_min_version with
-      | None, 0 -> ()
-      | None, _ -> arg "-cpu" "host"
-      | Some model, _ -> arg "-cpu" model
-    );
+    arg "-cpu" (Option.default "host" source.s_cpu_model);
 
     if source.s_vcpu > 1 then (
       (match source.s_cpu_topology with
-- 
2.39.0



More information about the Libguestfs mailing list