Blame SOURCES/0030-output-create_libvirt_xml-relax-VCPU-feature-checkin.patch

696189
From 29c6ee9322da082e3be9faa94cf4a6840b49cd97 Mon Sep 17 00:00:00 2001
696189
From: Laszlo Ersek <lersek@redhat.com>
696189
Date: Fri, 22 Jul 2022 09:36:27 +0200
696189
Subject: [PATCH] output/create_libvirt_xml: relax VCPU feature checking for
696189
 "qemu64"
696189
696189
When the source domain doesn't specify a VCPU model ("s_cpu_model" is
696189
None), and the guest OS is assumed to work with the default VCPU model
696189
("gcaps_default_cpu" is true), we don't output any <cpu> element. In that
696189
case, libvirtd augments the domain config with:
696189
696189
  [1] <cpu mode='custom' match='exact' check='none'>
696189
        <model fallback='forbid'>qemu64</model>
696189
      </cpu>
696189
696189
where the @check='none' attribute ensures that the converted domain will
696189
be launched, for example, on an Intel host, despite the "qemu64" VCPU
696189
model containing AMD-only feature flags such as "svm".
696189
696189
However, if the source domain explicitly specifies the "qemu64" model
696189
(mostly seen with "-i libvirt -ic qemu://..."), we presently output
696189
696189
  [2] <cpu match='minimum'>
696189
        <model fallback='allow'>qemu64</model>
696189
      </cpu>
696189
696189
which libvirtd completes as
696189
696189
  [3] <cpu mode='custom' match='minimum' check='partial'>
696189
        <model fallback='allow'>qemu64</model>
696189
      </cpu>
696189
696189
In [3], cpu/@match='minimum' and cpu/model/@fallback='allow' are both
696189
laxer than @match='exact' and @fallback='forbid', respectively, in [1].
696189
696189
However, cpu/@check='partial' in [3] is stricter than @check='none' in
696189
[1]; it causes libvirtd to catch the "svm" feature flag on an Intel host,
696189
and prevents the converted domain from starting.
696189
696189
The "qemu64" VCPU model is supposed to run on every possible host
696189
<https://gitlab.com/qemu-project/qemu/-/blob/master/docs/system/cpu-models-x86.rst.inc>,
696189
therefore make an exception for the explicitly specified "qemu64" VCPU
696189
model, and generate the @check='none' attribute.
696189
696189
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2107503
696189
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
696189
Message-Id: <20220722073627.6511-1-lersek@redhat.com>
696189
Acked-by: Richard W.M. Jones <rjones@redhat.com>
696189
(cherry picked from commit e5297c3180fd3ebea41a40f4c5a66969a24b9ff3)
696189
---
696189
 output/create_libvirt_xml.ml | 2 ++
696189
 1 file changed, 2 insertions(+)
696189
696189
diff --git a/output/create_libvirt_xml.ml b/output/create_libvirt_xml.ml
696189
index 531a4f75..bd01304d 100644
696189
--- a/output/create_libvirt_xml.ml
696189
+++ b/output/create_libvirt_xml.ml
696189
@@ -192,6 +192,8 @@ let create_libvirt_xml ?pool source inspect
696189
            List.push_back cpu_attrs ("mode", "host-passthrough");
696189
      | Some model ->
696189
          List.push_back cpu_attrs ("match", "minimum");
696189
+         if model = "qemu64" then
696189
+           List.push_back cpu_attrs ("check", "none");
696189
          (match source.s_cpu_vendor with
696189
           | None -> ()
696189
           | Some vendor ->