1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-10 05:17:59 +03:00

qemu: Use host-model CPU on s390 by default

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>
This commit is contained in:
Jiri Denemark 2019-11-12 15:28:33 +01:00
parent 0a24331c6e
commit 24d8202294
3 changed files with 26 additions and 13 deletions

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

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

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