]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Use host-model CPU on s390 by default
authorJiri Denemark <jdenemar@redhat.com>
Tue, 12 Nov 2019 14:28:33 +0000 (15:28 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 25 Nov 2019 14:29:19 +0000 (15:29 +0100)
On s390 machines host-passthrough and host-model CPUs result in the same
guest ABI (with QEMU new enough to be able to tell us what "host" CPU is
expanded to, which was implemented around 2.9.0). So instead of using
host-passthrough CPU when there's no CPU specified in a domain XML we
can safely use host-model and benefit from CPU compatibility checks
during migration, snapshot restore and similar operations.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain.c
tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-4.2.s390x-latest.args
tests/qemuxml2xmloutdata/s390-default-cpu-kvm-ccw-virtio-4.2.s390x-latest.xml

index d14f0dabf36c1eee5edbca2f66908a03c9b7fa2d..a1d8dca5125bebf1f78236fd410a33205abbefed 100644 (file)
@@ -4435,6 +4435,7 @@ qemuDomainDefVcpusPostParse(virDomainDefPtr def)
 
 static int
 qemuDomainDefSetDefaultCPU(virDomainDefPtr def,
+                           virCapsPtr caps,
                            virQEMUCapsPtr qemuCaps)
 {
     const char *model;
@@ -4465,26 +4466,36 @@ qemuDomainDefSetDefaultCPU(virDomainDefPtr def,
         return -1;
     }
 
-    VIR_DEBUG("Setting default CPU model for domain '%s' to %s",
-              def->name, model);
-
     if (!def->cpu)
         def->cpu = g_new0(virCPUDef, 1);
 
-    /* We need to turn off all CPU checks when the domain is started because
-     * the default CPU (e.g., qemu64) may not be runnable on any host. QEMU
-     * will just disable the unavailable features and we will update the CPU
-     * definition accordingly and set check to FULL when starting the domain. */
     def->cpu->type = VIR_CPU_TYPE_GUEST;
-    def->cpu->check = VIR_CPU_CHECK_NONE;
 
     if (STREQ(model, "host")) {
-        def->cpu->mode = VIR_CPU_MODE_HOST_PASSTHROUGH;
+        if (ARCH_IS_S390(def->os.arch) &&
+            virQEMUCapsIsCPUModeSupported(qemuCaps, caps, def->virtType,
+                                          VIR_CPU_MODE_HOST_MODEL)) {
+            def->cpu->mode = VIR_CPU_MODE_HOST_MODEL;
+        } else {
+            def->cpu->mode = VIR_CPU_MODE_HOST_PASSTHROUGH;
+        }
+
+        VIR_DEBUG("Setting default CPU mode for domain '%s' to %s",
+                  def->name, virCPUModeTypeToString(def->cpu->mode));
     } else {
+        /* We need to turn off all CPU checks when the domain is started
+         * because the default CPU (e.g., qemu64) may not be runnable on any
+         * host. QEMU will just disable the unavailable features and we will
+         * update the CPU definition accordingly and set check to FULL when
+         * starting the domain. */
+        def->cpu->check = VIR_CPU_CHECK_NONE;
         def->cpu->mode = VIR_CPU_MODE_CUSTOM;
         def->cpu->match = VIR_CPU_MATCH_EXACT;
         def->cpu->fallback = VIR_CPU_FALLBACK_FORBID;
         def->cpu->model = g_strdup(model);
+
+        VIR_DEBUG("Setting default CPU model for domain '%s' to %s",
+                  def->name, model);
     }
 
     return 0;
@@ -4669,7 +4680,7 @@ qemuDomainDefPostParseBasic(virDomainDefPtr def,
 
 static int
 qemuDomainDefPostParse(virDomainDefPtr def,
-                       virCapsPtr caps G_GNUC_UNUSED,
+                       virCapsPtr caps,
                        unsigned int parseFlags,
                        void *opaque,
                        void *parseOpaque)
@@ -4701,7 +4712,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,
     if (qemuCanonicalizeMachine(def, qemuCaps) < 0)
         return -1;
 
-    if (qemuDomainDefSetDefaultCPU(def, qemuCaps) < 0)
+    if (qemuDomainDefSetDefaultCPU(def, caps, qemuCaps) < 0)
         return -1;
 
     qemuDomainDefEnableDefaultFeatures(def, qemuCaps);
index 4b7345630b419a8e502f506178fffa319f289919..038601941818b1bc083d182a775ce24cc74a44c3 100644 (file)
@@ -13,7 +13,9 @@ QEMU_AUDIO_DRV=none \
 -object secret,id=masterKey0,format=raw,\
 file=/tmp/lib/domain--1-test/master-key.aes \
 -machine s390-ccw-virtio-4.2,accel=kvm,usb=off,dump-guest-core=off \
--cpu host \
+-cpu z13.2-base,aen=on,aefsi=on,msa5=on,msa4=on,msa3=on,msa2=on,msa1=on,\
+sthyi=on,edat=on,ri=on,edat2=on,vx=on,ipter=on,ap=on,esop=on,apft=on,apqci=on,\
+cte=on,bpb=on,ppa15=on,zpci=on,sea_esop2=on,te=on,cmm=on \
 -m 256 \
 -overcommit mem-lock=off \
 -smp 1,sockets=1,cores=1,threads=1 \
index eec5051934c0bce632f22e2b8eff9ce8edae92bd..1cc2edd8938a081d5d7fed17bd577c438e23b099 100644 (file)
@@ -8,7 +8,7 @@
     <type arch='s390x' machine='s390-ccw-virtio-4.2'>hvm</type>
     <boot dev='hd'/>
   </os>
-  <cpu mode='host-passthrough' check='none'/>
+  <cpu mode='host-model' check='partial'/>
   <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>