render / rpms / libvirt

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