qemu: Fill default value in //cpu/@migratable attribute

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>
This commit is contained in:
Jiri Denemark 2020-06-02 15:34:07 +02:00
parent 19926477cb
commit 201bd5db63
7 changed files with 18 additions and 8 deletions

View 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)

View File

@ -277,7 +277,7 @@
<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'/>

View File

@ -291,7 +291,7 @@
<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'/>

View 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>

View 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>

View 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'/>

View 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>