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

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