From nobody Mon Dec 30 17:39:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1694466581; cv=none; d=zohomail.com; s=zohoarc; b=aFVonKK9J8NeC4KKxDsSliXfybI+Yv5rcr/kUM8EIrhuSsBGNxs9HA3tfWinVRnVFktsmobWgd4NcxjY9qYmE53Jo8ZHie3gWGmJ236/QJCuEopDL0JgdUCFbjr9MWU60dPJ1dYHb2klJnhesXeBA0fpAmy9b3/HdghHCaR2GJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694466581; 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=Qlol5rDKgoofkYOQ5N1b1UJNlXu4MkB3CYqoquYqgrQ=; b=GODAzOmD9KT3dSWF1eRntBcva/dd6KW3wXfNDiAOYRFnm0+XNgbU3Draegyp+zUWkJOqlv9s6J9qR4PKMCqZW+PU4lNipZTLRaGW95XzAOpJVV9i1K7b9IkH+eo0sdmzfSbUp4QbKgQ1HmDgYqrqd3Iu5AKPvihzz7/XMfgWrqw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 169446658169696.6080268844928; Mon, 11 Sep 2023 14:09:41 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-475-_Vk4cawjMWq5myLLZa2Fxg-1; Mon, 11 Sep 2023 17:09:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 744C1816536; Mon, 11 Sep 2023 21:09:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C02240C6EC0; Mon, 11 Sep 2023 21:09:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3ED8319465A8; Mon, 11 Sep 2023 21:09:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3B37B1946A47 for ; Mon, 11 Sep 2023 21:09:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2B1A744029; Mon, 11 Sep 2023 21:09:24 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2360444069 for ; Mon, 11 Sep 2023 21:09:24 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E4A068A4378 for ; Mon, 11 Sep 2023 21:09:23 +0000 (UTC) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-A-Y8NbdsM0i82cC1mCjH3Q-1; Mon, 11 Sep 2023 17:09:19 -0400 Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38BKuauN011916 for ; Mon, 11 Sep 2023 21:09:18 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3t2acfrkfg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 11 Sep 2023 21:09:17 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 38BKex37002352 for ; Mon, 11 Sep 2023 21:09:17 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3t158jwcp6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 11 Sep 2023 21:09:17 +0000 Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 38BL9FGO35652066 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Sep 2023 21:09:16 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE93C5805A; Mon, 11 Sep 2023 21:09:15 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6DC025805E; Mon, 11 Sep 2023 21:09:15 +0000 (GMT) Received: from li-d664314c-3171-11b2-a85c-fa8047ef35bd.ibm.com.com (unknown [9.67.49.93]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 11 Sep 2023 21:09:15 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694466580; 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=Qlol5rDKgoofkYOQ5N1b1UJNlXu4MkB3CYqoquYqgrQ=; b=A3TH3p/U8GMB1NerJnAWJCtYoMK3NOl8iCbWvxC9TLLR7W9p4e/dNnMifYpRPgq06FPYPF 9NeaOMlDB+Wzw0sVaMGqIpYE8MuQJpiB9r8EsSg1//bvg4SzOX4RV7qK6+0f7iHTJq5dek LNgjWQSUai/VbYvWLrp+bfIyCmHiBas= X-MC-Unique: _Vk4cawjMWq5myLLZa2Fxg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: A-Y8NbdsM0i82cC1mCjH3Q-1 From: Collin Walling To: libvir-list@redhat.com Subject: [PATCH v1 7/9] qemu: process: allow guest to use host-recommended CPU model Date: Mon, 11 Sep 2023 17:07:14 -0400 Message-ID: <20230911210716.75648-8-walling@linux.ibm.com> In-Reply-To: <20230911210716.75648-1-walling@linux.ibm.com> References: <20230911210716.75648-1-walling@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: K8T5ocht5zInuscql9hd149PhFBvU6P_ X-Proofpoint-GUID: K8T5ocht5zInuscql9hd149PhFBvU6P_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-11_16,2023-09-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309110194 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Fiuczynski Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: linux.ibm.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694466583576100001 Content-Type: text/plain; charset="utf-8"; x-default="true" A guest may enable the host-recommended CPU model via the following domain XML: Once the guest is running, the deprecated features will nest under the tag paired with the "disable" policy, e.g.: gen16a-base ... Though existing guests must restart for the CPU model to update with these changes, this at least removes a requirement of the user to manually stay up-to-date on which features are recommended to be disabled as future hardware updates come into play -- so long as the hypervisor maintains the most up-to-date CPU model definitions. Signed-off-by: Collin Walling Reviewed-by: Boris Fiuczynski --- src/cpu/cpu.c | 1 + src/qemu/qemu_command.c | 4 +++ src/qemu/qemu_process.c | 9 ++++-- src/qemu/qemu_validate.c | 7 ++++ ...c-cpu-kvm-ccw-virtio-8.1.s390x-latest.args | 32 +++++++++++++++++++ .../s390-host-rec-cpu-kvm-ccw-virtio-8.1.xml | 17 ++++++++++ tests/qemuxml2argvtest.c | 2 ++ ...ec-cpu-kvm-ccw-virtio-8.1.s390x-latest.xml | 25 +++++++++++++++ tests/qemuxml2xmltest.c | 1 + 9 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/s390-host-rec-cpu-kvm-ccw-virtio= -8.1.s390x-latest.args create mode 100644 tests/qemuxml2argvdata/s390-host-rec-cpu-kvm-ccw-virtio= -8.1.xml create mode 100644 tests/qemuxml2xmloutdata/s390-host-rec-cpu-kvm-ccw-virt= io-8.1.s390x-latest.xml diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 805aff1bf5..4ac34a5efb 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -981,6 +981,7 @@ virCPUTranslate(virArch arch, =20 if (cpu->mode =3D=3D VIR_CPU_MODE_HOST_MODEL || cpu->mode =3D=3D VIR_CPU_MODE_HOST_PASSTHROUGH || + cpu->mode =3D=3D VIR_CPU_MODE_HOST_RECOMMENDED || cpu->mode =3D=3D VIR_CPU_MODE_MAXIMUM) return 0; =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a45e2fbb95..ace9deb246 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6294,6 +6294,10 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver, break; =20 case VIR_CPU_MODE_HOST_RECOMMENDED: + if (ARCH_IS_S390(def->os.arch)) + virBufferAddLit(buf, "host-recommended"); + break; + case VIR_CPU_MODE_LAST: break; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 7a1cdb0302..4ff8c1c87a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6303,6 +6303,7 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, if (def->cpu->mode !=3D VIR_CPU_MODE_HOST_PASSTHROUGH && def->cpu->mode !=3D VIR_CPU_MODE_MAXIMUM) { g_autoptr(virDomainCapsCPUModels) cpuModels =3D NULL; + virQEMUCapsHostCPUType cpuType; =20 if (def->cpu->check =3D=3D VIR_CPU_CHECK_PARTIAL && virCPUCompare(hostarch, @@ -6311,9 +6312,13 @@ qemuProcessUpdateGuestCPU(virDomainDef *def, def->cpu, true) < 0) return -1; =20 + if (def->cpu->mode =3D=3D VIR_CPU_MODE_HOST_RECOMMENDED) + cpuType =3D VIR_QEMU_CAPS_HOST_CPU_RECOMMENDED; + else + cpuType =3D VIR_QEMU_CAPS_HOST_CPU_MIGRATABLE; + if (virCPUUpdate(def->os.arch, def->cpu, - virQEMUCapsGetHostModel(qemuCaps, def->virtType, - VIR_QEMU_CAPS_HOST_CPU_MI= GRATABLE)) < 0) + virQEMUCapsGetHostModel(qemuCaps, def->virtType, = cpuType)) < 0) return -1; =20 cpuModels =3D virQEMUCapsGetCPUModels(qemuCaps, def->virtType, NUL= L, NULL); diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 387c2f1fa8..a60445f686 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -373,6 +373,13 @@ qemuValidateDomainDefCpu(virQEMUDriver *driver, break; =20 case VIR_CPU_MODE_HOST_RECOMMENDED: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANS= ION_STATIC_RECOMMENDED)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("host-recommended CPU is not supported by= QEMU binary")); + return -1; + } + break; + case VIR_CPU_MODE_CUSTOM: case VIR_CPU_MODE_LAST: break; diff --git a/tests/qemuxml2argvdata/s390-host-rec-cpu-kvm-ccw-virtio-8.1.s3= 90x-latest.args b/tests/qemuxml2argvdata/s390-host-rec-cpu-kvm-ccw-virtio-8= .1.s390x-latest.args new file mode 100644 index 0000000000..78546380d7 --- /dev/null +++ b/tests/qemuxml2argvdata/s390-host-rec-cpu-kvm-ccw-virtio-8.1.s390x-lat= est.args @@ -0,0 +1,32 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-test/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-test/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-test/.config \ +/usr/bin/qemu-system-s390x \ +-name guest=3Dtest,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-test/master-key.aes"}' \ +-machine s390-ccw-virtio-8.1,usb=3Doff,dump-guest-core=3Doff,memory-backen= d=3Ds390.ram \ +-accel kvm \ +-cpu gen16a-base,nnpa=3Don,aen=3Don,cmmnt=3Don,vxpdeh=3Don,aefsi=3Don,diag= 318=3Don,csske=3Doff,mepoch=3Don,msa9=3Don,msa8=3Don,msa7=3Don,msa6=3Don,ms= a5=3Don,msa4=3Don,msa3=3Don,msa2=3Don,msa1=3Don,sthyi=3Don,edat=3Don,ri=3Do= n,deflate=3Don,edat2=3Don,etoken=3Don,vx=3Don,ipter=3Don,pai=3Don,paie=3Don= ,mepochptff=3Don,ap=3Don,vxeh=3Don,vxpd=3Don,esop=3Don,msa9_pckmo=3Don,vxeh= 2=3Don,esort=3Don,apqi=3Don,apft=3Don,els=3Don,iep=3Don,apqci=3Don,cte=3Dof= f,ais=3Don,bpb=3Doff,gs=3Don,ppa15=3Don,zpci=3Don,rdp=3Don,sea_esop2=3Don,b= eareh=3Don,te=3Doff,cmm=3Don,vxpdeh2=3Don \ +-m size=3D262144k \ +-object '{"qom-type":"memory-backend-ram","id":"s390.ram","size":268435456= }' \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 9aa4b45c-b9dd-45ef-91fe-862b27b4231f \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-balloon-ccw","id":"balloon0","devno":"fe.0.0000= "}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/s390-host-rec-cpu-kvm-ccw-virtio-8.1.xm= l b/tests/qemuxml2argvdata/s390-host-rec-cpu-kvm-ccw-virtio-8.1.xml new file mode 100644 index 0000000000..cacc1933dd --- /dev/null +++ b/tests/qemuxml2argvdata/s390-host-rec-cpu-kvm-ccw-virtio-8.1.xml @@ -0,0 +1,17 @@ + + test + 9aa4b45c-b9dd-45ef-91fe-862b27b4231f + 262144 + 262144 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-s390x + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 2d06e2a0d1..4c3b698b83 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2295,6 +2295,8 @@ mymain(void) DO_TEST_CAPS_ARCH_LATEST("s390-async-teardown-disabled", "s390x"); DO_TEST_CAPS_ARCH_VER("s390-async-teardown-disabled", "s390x", "6.0.0"= ); =20 + DO_TEST_CAPS_ARCH_LATEST("s390-host-rec-cpu-kvm-ccw-virtio-8.1", "s390= x"); + qemuTestDriverFree(&driver); virFileWrapperClearPrefixes(); =20 diff --git a/tests/qemuxml2xmloutdata/s390-host-rec-cpu-kvm-ccw-virtio-8.1.= s390x-latest.xml b/tests/qemuxml2xmloutdata/s390-host-rec-cpu-kvm-ccw-virti= o-8.1.s390x-latest.xml new file mode 100644 index 0000000000..177694afe8 --- /dev/null +++ b/tests/qemuxml2xmloutdata/s390-host-rec-cpu-kvm-ccw-virtio-8.1.s390x-l= atest.xml @@ -0,0 +1,25 @@ + + test + 9aa4b45c-b9dd-45ef-91fe-862b27b4231f + 262144 + 262144 + 1 + + hvm + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-s390x + +