render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
6d1f90
From 3b9e2f17d091c57f1fe7cbad18b0985e0644d8c2 Mon Sep 17 00:00:00 2001
6d1f90
Message-Id: <3b9e2f17d091c57f1fe7cbad18b0985e0644d8c2@dist-git>
6d1f90
From: Jiri Denemark <jdenemar@redhat.com>
6d1f90
Date: Fri, 22 Nov 2019 11:19:24 +0100
6d1f90
Subject: [PATCH] cpu_map: Drop pconfig from Icelake-Server CPU model
6d1f90
MIME-Version: 1.0
6d1f90
Content-Type: text/plain; charset=UTF-8
6d1f90
Content-Transfer-Encoding: 8bit
6d1f90
6d1f90
The pconfig feature was enabled in QEMU by accident in 3.1.0. All other
6d1f90
newer versions do not support it and it was removed from the
6d1f90
Icelake-Server CPU model in QEMU.
6d1f90
6d1f90
We don't normally change our CPU models even when QEMU does so to avoid
6d1f90
breaking migrations between different versions of libvirt. But we can
6d1f90
safely do so in this specific case. QEMU never supported enabling
6d1f90
pconfig so any domain which was able to start has pconfig disabled.
6d1f90
6d1f90
With a small compatibility hack which explicitly disables pconfig when
6d1f90
CPU model equals Icelake-Server in migratable domain definition, only
6d1f90
one migration scenario stays broken (and there's nothing we can do about
6d1f90
it): from any host to a host with libvirt < 5.10.0 and QEMU > 3.1.0.
6d1f90
6d1f90
https://bugzilla.redhat.com/show_bug.cgi?id=1749672
6d1f90
6d1f90
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d1f90
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6d1f90
(cherry picked from commit 9cd03f7957e114892ae54e7ccb3758b6fb440644)
6d1f90
6d1f90
https://bugzilla.redhat.com/show_bug.cgi?id=1775133
6d1f90
https://bugzilla.redhat.com/show_bug.cgi?id=1775134
6d1f90
https://bugzilla.redhat.com/show_bug.cgi?id=1775137
6d1f90
6d1f90
Conflicts:
6d1f90
	src/cpu_map/x86_Icelake-Server.xml
6d1f90
            - still monolithic cpu_map.xml downstream
6d1f90
6d1f90
	src/qemu/qemu_domain.h
6d1f90
            - context
6d1f90
6d1f90
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d1f90
Message-Id: <430d543cce32100e879f1a5ea125abd4428aecf0.1574417839.git.jdenemar@redhat.com>
6d1f90
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
6d1f90
---
6d1f90
 src/cpu/cpu_map.xml                           |  1 -
6d1f90
 src/qemu/qemu_domain.c                        | 23 +++++++++++++++++++
6d1f90
 src/qemu/qemu_domain.h                        |  3 +++
6d1f90
 src/qemu/qemu_migration_cookie.c              |  3 +++
6d1f90
 .../x86_64-cpuid-Ice-Lake-Server-guest.xml    |  1 -
6d1f90
 .../x86_64-cpuid-Ice-Lake-Server-host.xml     | 11 +--------
6d1f90
 .../x86_64-cpuid-Ice-Lake-Server-json.xml     |  1 -
6d1f90
 7 files changed, 30 insertions(+), 13 deletions(-)
6d1f90
6d1f90
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
6d1f90
index acd9dad7dc..7b9f8bb452 100644
6d1f90
--- a/src/cpu/cpu_map.xml
6d1f90
+++ b/src/cpu/cpu_map.xml
6d1f90
@@ -2176,7 +2176,6 @@
6d1f90
       <feature name='pat'/>
6d1f90
       <feature name='pcid'/>
6d1f90
       <feature name='pclmuldq'/>
6d1f90
-      <feature name='pconfig'/>
6d1f90
       <feature name='pdpe1gb'/>
6d1f90
       <feature name='pge'/>
6d1f90
       <feature name='pku'/>
6d1f90
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
6d1f90
index c9899b9e6d..f45d7d427e 100644
6d1f90
--- a/src/qemu/qemu_domain.c
6d1f90
+++ b/src/qemu/qemu_domain.c
6d1f90
@@ -7348,6 +7348,26 @@ qemuDomainDefCopy(virQEMUDriverPtr driver,
6d1f90
 }
6d1f90
 
6d1f90
 
6d1f90
+int
6d1f90
+qemuDomainMakeCPUMigratable(virCPUDefPtr cpu)
6d1f90
+{
6d1f90
+    if (cpu->mode == VIR_CPU_MODE_CUSTOM &&
6d1f90
+        STREQ_NULLABLE(cpu->model, "Icelake-Server")) {
6d1f90
+        /* Originally Icelake-Server CPU model contained pconfig CPU feature.
6d1f90
+         * It was never actually enabled and thus it was removed. To enable
6d1f90
+         * migration to QEMU 3.1.0 (with both new and old libvirt), we
6d1f90
+         * explicitly disable pconfig in migration XML (otherwise old libvirt
6d1f90
+         * would think it was implicitly enabled on the source). New libvirt
6d1f90
+         * will drop it from the XML before starting the domain on new QEMU.
6d1f90
+         */
6d1f90
+        if (virCPUDefUpdateFeature(cpu, "pconfig", VIR_CPU_FEATURE_DISABLE) < 0)
6d1f90
+            return -1;
6d1f90
+    }
6d1f90
+
6d1f90
+    return 0;
6d1f90
+}
6d1f90
+
6d1f90
+
6d1f90
 static int
6d1f90
 qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
6d1f90
                                virDomainDefPtr def,
6d1f90
@@ -7522,6 +7542,9 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
6d1f90
             if (!(def->cpu = virCPUDefCopy(origCPU)))
6d1f90
                 goto cleanup;
6d1f90
         }
6d1f90
+
6d1f90
+        if (qemuDomainMakeCPUMigratable(def->cpu) < 0)
6d1f90
+            goto cleanup;
6d1f90
     }
6d1f90
 
6d1f90
  format:
6d1f90
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
6d1f90
index 8463a8b706..a29a678771 100644
6d1f90
--- a/src/qemu/qemu_domain.h
6d1f90
+++ b/src/qemu/qemu_domain.h
6d1f90
@@ -1072,4 +1072,7 @@ char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv);
6d1f90
 virDomainEventResumedDetailType
6d1f90
 qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason);
6d1f90
 
6d1f90
+int
6d1f90
+qemuDomainMakeCPUMigratable(virCPUDefPtr cpu);
6d1f90
+
6d1f90
 #endif /* __QEMU_DOMAIN_H__ */
6d1f90
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
6d1f90
index 60df449d53..c270896944 100644
6d1f90
--- a/src/qemu/qemu_migration_cookie.c
6d1f90
+++ b/src/qemu/qemu_migration_cookie.c
6d1f90
@@ -543,6 +543,9 @@ qemuMigrationCookieAddCPU(qemuMigrationCookiePtr mig,
6d1f90
     if (!(mig->cpu = virCPUDefCopy(vm->def->cpu)))
6d1f90
         return -1;
6d1f90
 
6d1f90
+    if (qemuDomainMakeCPUMigratable(mig->cpu) < 0)
6d1f90
+        return -1;
6d1f90
+
6d1f90
     mig->flags |= QEMU_MIGRATION_COOKIE_CPU;
6d1f90
 
6d1f90
     return 0;
6d1f90
diff --git a/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-guest.xml b/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-guest.xml
6d1f90
index 6ca2099b33..4676f3aa7d 100644
6d1f90
--- a/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-guest.xml
6d1f90
+++ b/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-guest.xml
6d1f90
@@ -32,5 +32,4 @@
6d1f90
   <feature policy='require' name='rdctl-no'/>
6d1f90
   <feature policy='require' name='ibrs-all'/>
6d1f90
   <feature policy='require' name='skip-l1dfl-vmentry'/>
6d1f90
-  <feature policy='disable' name='pconfig'/>
6d1f90
 </cpu>
6d1f90
diff --git a/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-host.xml b/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-host.xml
6d1f90
index 31af20bc85..35b9e39629 100644
6d1f90
--- a/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-host.xml
6d1f90
+++ b/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-host.xml
6d1f90
@@ -1,6 +1,6 @@
6d1f90
 <cpu>
6d1f90
   <arch>x86_64</arch>
6d1f90
-  <model>Icelake-Client</model>
6d1f90
+  <model>Icelake-Server</model>
6d1f90
   <vendor>Intel</vendor>
6d1f90
   <feature name='ds'/>
6d1f90
   <feature name='acpi'/>
6d1f90
@@ -21,23 +21,14 @@
6d1f90
   <feature name='osxsave'/>
6d1f90
   <feature name='tsc_adjust'/>
6d1f90
   <feature name='cmt'/>
6d1f90
-  <feature name='avx512f'/>
6d1f90
-  <feature name='avx512dq'/>
6d1f90
   <feature name='avx512ifma'/>
6d1f90
-  <feature name='clflushopt'/>
6d1f90
-  <feature name='clwb'/>
6d1f90
-  <feature name='avx512cd'/>
6d1f90
   <feature name='sha-ni'/>
6d1f90
-  <feature name='avx512bw'/>
6d1f90
-  <feature name='avx512vl'/>
6d1f90
   <feature name='ospke'/>
6d1f90
-  <feature name='la57'/>
6d1f90
   <feature name='stibp'/>
6d1f90
   <feature name='arch-capabilities'/>
6d1f90
   <feature name='xsaves'/>
6d1f90
   <feature name='mbm_total'/>
6d1f90
   <feature name='mbm_local'/>
6d1f90
-  <feature name='pdpe1gb'/>
6d1f90
   <feature name='invtsc'/>
6d1f90
   <feature name='rdctl-no'/>
6d1f90
   <feature name='ibrs-all'/>
6d1f90
diff --git a/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-json.xml b/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-json.xml
6d1f90
index b043db58d7..ada11d2608 100644
6d1f90
--- a/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-json.xml
6d1f90
+++ b/tests/cputestdata/x86_64-cpuid-Ice-Lake-Server-json.xml
6d1f90
@@ -13,5 +13,4 @@
6d1f90
   <feature policy='require' name='ibrs-all'/>
6d1f90
   <feature policy='require' name='skip-l1dfl-vmentry'/>
6d1f90
   <feature policy='disable' name='intel-pt'/>
6d1f90
-  <feature policy='disable' name='pconfig'/>
6d1f90
 </cpu>
6d1f90
-- 
6d1f90
2.24.0
6d1f90