]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Fill default value in //cpu/@migratable attribute
authorJiri Denemark <jdenemar@redhat.com>
Tue, 2 Jun 2020 13:34:07 +0000 (15:34 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 9 Jun 2020 18:32:50 +0000 (20:32 +0200)
Before QEMU introduced migratable CPU property, "-cpu host" included all
features that could be enabled on the host, even those which would block
migration. In other words, the default was equivalent to migratable=off.
When the migratable property was introduced, the default changed to
migratable=on. Let's record the default in domain XML.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_domain.c
tests/qemustatusxml2xmldata/migration-in-params-in.xml
tests/qemustatusxml2xmldata/migration-out-params-in.xml
tests/qemuxml2xmloutdata/cpu-check-default-none.xml
tests/qemuxml2xmloutdata/cpu-host-kvmclock.xml
tests/qemuxml2xmloutdata/cpu-host-passthrough-features.xml
tests/qemuxml2xmloutdata/kvm-features.xml

index 3239ac1a529c3844800f92f11bca6e00a7e3358d..2dad823a8673710a13916583607e8249f74734df 100644 (file)
@@ -4792,7 +4792,8 @@ qemuDomainDefSetDefaultCPU(virDomainDefPtr def,
 
 
 static int
-qemuDomainDefCPUPostParse(virDomainDefPtr def)
+qemuDomainDefCPUPostParse(virDomainDefPtr def,
+                          virQEMUCapsPtr qemuCaps)
 {
     virCPUFeatureDefPtr sveFeature = NULL;
     bool sveVectorLengthsProvided = false;
@@ -4888,6 +4889,15 @@ qemuDomainDefCPUPostParse(virDomainDefPtr def)
         }
     }
 
+    if (qemuCaps &&
+        def->cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH &&
+        !def->cpu->migratable) {
+        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_MIGRATABLE))
+            def->cpu->migratable = VIR_TRISTATE_SWITCH_ON;
+        else if (ARCH_IS_X86(def->os.arch))
+            def->cpu->migratable = VIR_TRISTATE_SWITCH_OFF;
+    }
+
     /* Nothing to be done if only CPU topology is specified. */
     if (def->cpu->mode == VIR_CPU_MODE_CUSTOM &&
         !def->cpu->model)
@@ -5033,7 +5043,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,
     if (qemuDomainDefVcpusPostParse(def) < 0)
         return -1;
 
-    if (qemuDomainDefCPUPostParse(def) < 0)
+    if (qemuDomainDefCPUPostParse(def, qemuCaps) < 0)
         return -1;
 
     if (qemuDomainDefTsegPostParse(def, qemuCaps) < 0)
index fdc2d3917307ec71899e70506dcbf70a0db78344..93450c38d5f26f0c3607756371fd8dfccf09c69d 100644 (file)
       <apic/>
       <vmport state='off'/>
     </features>
-    <cpu mode='host-passthrough' check='none'/>
+    <cpu mode='host-passthrough' check='none' migratable='on'/>
     <clock offset='utc'>
       <timer name='rtc' tickpolicy='catchup'/>
       <timer name='pit' tickpolicy='delay'/>
index 1956eac12031d62e9c439b6867ed0bf846fdae3e..c1daab4deea0dfab5adf7c00a6ca35ade0fb9e3e 100644 (file)
       <apic/>
       <vmport state='off'/>
     </features>
-    <cpu mode='host-passthrough' check='none'/>
+    <cpu mode='host-passthrough' check='none' migratable='on'/>
     <clock offset='utc'>
       <timer name='rtc' tickpolicy='catchup'/>
       <timer name='pit' tickpolicy='delay'/>
index ddffb2f15bd0be70c2892822e8431af96d425122..9f6b043f2c0813ff639fe6e1df3bfe92ae1f939d 100644 (file)
@@ -8,7 +8,7 @@
     <type arch='x86_64' machine='pc'>hvm</type>
     <boot dev='network'/>
   </os>
-  <cpu mode='host-passthrough' check='none'/>
+  <cpu mode='host-passthrough' check='none' migratable='off'/>
   <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
index 6d8fa367c7f2a8a405c95336831a66da370732c4..9414c41c7add72ae91137b8de306d8e8ef89470d 100644 (file)
@@ -8,7 +8,7 @@
     <type arch='x86_64' machine='pc'>hvm</type>
     <boot dev='network'/>
   </os>
-  <cpu mode='host-passthrough' check='none'/>
+  <cpu mode='host-passthrough' check='none' migratable='off'/>
   <clock offset='utc'>
     <timer name='kvmclock' present='no'/>
   </clock>
index 9a961eb1a1deba0a8f1c60c3bc8cfbe0f85c7390..bd1e50ef6a2418f1515ce11f5c1674e8450a4731 100644 (file)
@@ -13,7 +13,7 @@
     <type arch='i686' machine='pc'>hvm</type>
     <boot dev='hd'/>
   </os>
-  <cpu mode='host-passthrough' check='none'>
+  <cpu mode='host-passthrough' check='none' migratable='off'>
     <feature policy='require' name='abm'/>
     <feature policy='force' name='ds'/>
     <feature policy='disable' name='invtsc'/>
index 7c554671b389da11431e7e04b667594bb52435b6..9c53eb463046f2bae67c2c2785751e8f484ae816 100644 (file)
@@ -15,7 +15,7 @@
       <hint-dedicated state='on'/>
     </kvm>
   </features>
-  <cpu mode='host-passthrough' check='none'/>
+  <cpu mode='host-passthrough' check='none' migratable='off'/>
   <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>