From nobody Sun Feb 8 04:57:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1573746343; cv=none; d=zoho.com; s=zohoarc; b=mDRjqGVBhRaWKSz34TD1UomwBn4LX1w6ME25qcMFQDAeuALv82TrmlJLl9o5XZahBOkYVCkiSR6e0ZD2PE8owbmJhjMigPtIKeCRyYCn+asy9vZUpFRYUzZO7NAYb0N5ibT3iy/H+jH4VXnyd9/GU4oPyzYv5StQsjCBPxJ4/ME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573746343; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bke4oMHXy2WYXd90VUZphxRKOqbGXpw7IkPETdstg6c=; b=cPk5AFfGsYwuixjoAP2yoLXxtZf/jAju6rPvV+it6IJJnA86YsCwaiKVXMK2d64oVsuM1DbkWPoWm6v3gxbG2W05e+Bi1mhCyQcxmOolOcYV9S8SEPpOc6H+s5+2bBeY4jeTeaIyaayiuE2vTEPCx08rhQtXBuvRGf/XLbJwsqA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1573746343005998.341329492578; Thu, 14 Nov 2019 07:45:43 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-103-t6f-6xJvMgKhnU9PEwb6TQ-1; Thu, 14 Nov 2019 10:45:39 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 539E18C73FF; Thu, 14 Nov 2019 15:45:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 18D4D108426B; Thu, 14 Nov 2019 15:45:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AF886182B015; Thu, 14 Nov 2019 15:45:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAEFjPsO026817 for ; Thu, 14 Nov 2019 10:45:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 04F346A50B; Thu, 14 Nov 2019 15:45:25 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7AA4F6A500; Thu, 14 Nov 2019 15:45:18 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id D3859100332; Thu, 14 Nov 2019 16:45:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573746341; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bke4oMHXy2WYXd90VUZphxRKOqbGXpw7IkPETdstg6c=; b=HYlg7z5DhguiO+sagxfPLt4wWfyJeoDHGjv70vj0gxc30DI8nS9uDF6JzAzBsps0JXyPIP 7TS588zT+Q7yQpSda7Zd/nKdwQypHFLUr/h+70dXM52KvWTDNEevyteKrOT6+Zf1izYk8N Uf88gk032TXyCjXdcQf2rgxJgoMAoys= From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 14 Nov 2019 16:44:58 +0100 Message-Id: <250657c17e8633ccd06f0f5cb6645d781ccb0dfd.1573746013.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Christian Borntraeger , "Collin L . Walling" , David Hildenbrand Subject: [libvirt] [PATCH 4/4] qemu: Use host-model CPU on s390 by default X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: t6f-6xJvMgKhnU9PEwb6TQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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 --- src/qemu/qemu_domain.c | 33 ++++++++++++------- ...t-cpu-kvm-ccw-virtio-4.2.s390x-latest.args | 4 ++- ...lt-cpu-kvm-ccw-virtio-4.2.s390x-latest.xml | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8bd05f4058..e5269e6300 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4440,6 +4440,7 @@ qemuDomainDefVcpusPostParse(virDomainDefPtr def) =20 static int qemuDomainDefSetDefaultCPU(virDomainDefPtr def, + virCapsPtr caps, virQEMUCapsPtr qemuCaps) { const char *model; @@ -4470,26 +4471,36 @@ qemuDomainDefSetDefaultCPU(virDomainDefPtr def, return -1; } =20 - VIR_DEBUG("Setting default CPU model for domain '%s' to %s", - def->name, model); - if (!def->cpu) def->cpu =3D g_new0(virCPUDef, 1); =20 - /* We need to turn off all CPU checks when the domain is started becau= se - * 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 C= PU - * definition accordingly and set check to FULL when starting the doma= in. */ def->cpu->type =3D VIR_CPU_TYPE_GUEST; - def->cpu->check =3D VIR_CPU_CHECK_NONE; =20 if (STREQ(model, "host")) { - def->cpu->mode =3D 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 =3D VIR_CPU_MODE_HOST_MODEL; + } else { + def->cpu->mode =3D 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 a= ny + * host. QEMU will just disable the unavailable features and we wi= ll + * update the CPU definition accordingly and set check to FULL when + * starting the domain. */ + def->cpu->check =3D VIR_CPU_CHECK_NONE; def->cpu->mode =3D VIR_CPU_MODE_CUSTOM; def->cpu->match =3D VIR_CPU_MATCH_EXACT; def->cpu->fallback =3D VIR_CPU_FALLBACK_FORBID; def->cpu->model =3D g_strdup(model); + + VIR_DEBUG("Setting default CPU model for domain '%s' to %s", + def->name, model); } =20 return 0; @@ -4674,7 +4685,7 @@ qemuDomainDefPostParseBasic(virDomainDefPtr def, =20 static int qemuDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps G_GNUC_UNUSED, + virCapsPtr caps, unsigned int parseFlags, void *opaque, void *parseOpaque) @@ -4706,7 +4717,7 @@ qemuDomainDefPostParse(virDomainDefPtr def, if (qemuCanonicalizeMachine(def, qemuCaps) < 0) return -1; =20 - if (qemuDomainDefSetDefaultCPU(def, qemuCaps) < 0) + if (qemuDomainDefSetDefaultCPU(def, caps, qemuCaps) < 0) return -1; =20 qemuDomainDefEnableDefaultFeatures(def, qemuCaps); diff --git a/tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-4.2.s39= 0x-latest.args b/tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-4.2= .s390x-latest.args index 4b7345630b..0386019418 100644 --- a/tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-4.2.s390x-late= st.args +++ b/tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-4.2.s390x-late= st.args @@ -13,7 +13,9 @@ QEMU_AUDIO_DRV=3Dnone \ -object secret,id=3DmasterKey0,format=3Draw,\ file=3D/tmp/lib/domain--1-test/master-key.aes \ -machine s390-ccw-virtio-4.2,accel=3Dkvm,usb=3Doff,dump-guest-core=3Doff \ --cpu host \ +-cpu z13.2-base,aen=3Don,aefsi=3Don,msa5=3Don,msa4=3Don,msa3=3Don,msa2=3Do= n,msa1=3Don,\ +sthyi=3Don,edat=3Don,ri=3Don,edat2=3Don,vx=3Don,ipter=3Don,ap=3Don,esop=3D= on,apft=3Don,apqci=3Don,\ +cte=3Don,bpb=3Don,ppa15=3Don,zpci=3Don,sea_esop2=3Don,te=3Don,cmm=3Don \ -m 256 \ -overcommit mem-lock=3Doff \ -smp 1,sockets=3D1,cores=3D1,threads=3D1 \ diff --git a/tests/qemuxml2xmloutdata/s390-default-cpu-kvm-ccw-virtio-4.2.s= 390x-latest.xml b/tests/qemuxml2xmloutdata/s390-default-cpu-kvm-ccw-virtio-= 4.2.s390x-latest.xml index eec5051934..1cc2edd893 100644 --- a/tests/qemuxml2xmloutdata/s390-default-cpu-kvm-ccw-virtio-4.2.s390x-la= test.xml +++ b/tests/qemuxml2xmloutdata/s390-default-cpu-kvm-ccw-virtio-4.2.s390x-la= test.xml @@ -8,7 +8,7 @@ hvm - + destroy restart --=20 2.24.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list