From nobody Fri Oct 11 20:30:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1694466574; cv=none; d=zohomail.com; s=zohoarc; b=gyKBZSNx/2vQp6gBPSs7hGTu8vBewikI53/P+aIH+a80WQ/mG7c4HBSE6tkE/38W1fa+gV2X9Q8AcJFr49Yal3AwZFsGuKSsrMdxyYfBhOC8M4nhaUrC9wwCnSWZ1vZRqK7izdlKYfJwPEypXwe/yew/Og+P8VNAUsUEqJigFpg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694466574; 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=NQVjoMf1d+TR8CSPMABmT7TBjWmcwAdEk28dYK/1Kjs=; b=QG8qGBUgEYg0w85KWYqIR+6qHyT1HP7HsWcebnDuOv3WbYz22d9EKOf8/JPoLhSkY4XaplBuEtcI67E6rZ08UnOcYv21+1xmBSg/FWnoqmajABRTqWwzhjNfbysnaYDoAafGKLHIqvb6pv5GWa/chV8+8qolcbvRqDCKcRYqg8s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1694466574316746.8216174378607; Mon, 11 Sep 2023 14:09:34 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-272-vJLuivToP4icktTdoPaGog-1; Mon, 11 Sep 2023 17:09:28 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 E3CB41C068DC; Mon, 11 Sep 2023 21:09:23 +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 BCF351054FC1; Mon, 11 Sep 2023 21:09:23 +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 891B619465BC; Mon, 11 Sep 2023 21:09:23 +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 657B219465B6 for ; Mon, 11 Sep 2023 21:09:21 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 44B4544069; Mon, 11 Sep 2023 21:09:21 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3CEA144029 for ; Mon, 11 Sep 2023 21:09:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 1BA313C18DD0 for ; Mon, 11 Sep 2023 21:09:21 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-626-zmT4We16MZi8Qyz8bPU4gw-1; Mon, 11 Sep 2023 17:09:18 -0400 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38BL8N0W018655 for ; Mon, 11 Sep 2023 21:09:17 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3t29un0xrv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 11 Sep 2023 21:09:16 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 38BJcgAD023142 for ; Mon, 11 Sep 2023 21:09:15 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3t141ndrk7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 11 Sep 2023 21:09:15 +0000 Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 38BL9ENG21430538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Sep 2023 21:09:14 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B83058052; Mon, 11 Sep 2023 21:09:14 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 404E55805A; Mon, 11 Sep 2023 21:09:14 +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:14 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694466573; 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=NQVjoMf1d+TR8CSPMABmT7TBjWmcwAdEk28dYK/1Kjs=; b=LshWBo5aP/3XCv2VEX5dIBmls4SqoBYHiElefzfOU9B3SL4pONfACDYrRnJXkAYJFUniMT j6wQdQnJ8lM85SlQjIOtK67ttlahCpiYVyGKIPwck8f1LpZjZ/U8g+XTFo9s+fg/7nJ0tl UE6hP+/1VCQ44XGEFhrXCoszoQDPDXY= X-MC-Unique: vJLuivToP4icktTdoPaGog-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: zmT4We16MZi8Qyz8bPU4gw-1 From: Collin Walling To: libvir-list@redhat.com Subject: [PATCH v1 4/9] qemu: capabilities: query and cache host-recommended CPU model Date: Mon, 11 Sep 2023 17:07:11 -0400 Message-ID: <20230911210716.75648-5-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-GUID: icdgSkmeJDvQiedAYZXKJW9YmDtAEFkw X-Proofpoint-ORIG-GUID: icdgSkmeJDvQiedAYZXKJW9YmDtAEFkw 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 malwarescore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 bulkscore=0 suspectscore=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.3 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: 1694466638030100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Query the host-recommended CPU model from QEMU, if it is supported. This model will be stored in the QEMU capabilities file underneath the closing tag, labeled . An example follows, (shortened as to not overwhelm the commit message): ... Signed-off-by: Collin Walling Reviewed-by: Boris Fiuczynski --- src/conf/schemas/cputypes.rng | 1 + src/qemu/qemu_capabilities.c | 108 +++++++++++++++--- src/qemu/qemu_capabilities.h | 3 + src/qemu/qemu_capspriv.h | 6 +- tests/cputest.c | 4 +- .../caps_8.1.0_s390x.replies | 74 ++++++++++++ .../qemucapabilitiesdata/caps_8.1.0_s390x.xml | 54 +++++++++ 7 files changed, 231 insertions(+), 19 deletions(-) diff --git a/src/conf/schemas/cputypes.rng b/src/conf/schemas/cputypes.rng index db1aa57158..5e89d67c8e 100644 --- a/src/conf/schemas/cputypes.rng +++ b/src/conf/schemas/cputypes.rng @@ -10,6 +10,7 @@ host-model host-passthrough maximum + host-recommended diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 40cdcffbfe..59403808ee 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -724,6 +724,11 @@ struct _virQEMUCapsHostCPUData { qemuMonitorCPUModelInfo *info; /* Physical address size of the host CPU or 0 if unknown or not applic= able. */ unsigned int physAddrSize; + /* Host CPU model with delta changes reported by the hypervisor to ens= ure + * migration compatibility with newer machines that may exclude certain + * features available on older machines. + */ + qemuMonitorCPUModelInfo *hostRec; /* Host CPU definition reported in domain capabilities. */ virCPUDef *reported; /* Migratable host CPU definition used for updating guest CPU. */ @@ -732,6 +737,8 @@ struct _virQEMUCapsHostCPUData { * combined with features reported by QEMU. This is used for backward * compatible comparison between a guest CPU and a host CPU. */ virCPUDef *full; + /* CPU definition converted from hostRec model info */ + virCPUDef *recommended; }; =20 typedef struct _virQEMUCapsAccel virQEMUCapsAccel; @@ -1834,6 +1841,12 @@ virQEMUCapsHostCPUDataCopy(virQEMUCapsHostCPUData *d= st, =20 if (src->full) dst->full =3D virCPUDefCopy(src->full); + + if (src->hostRec) + dst->hostRec =3D qemuMonitorCPUModelInfoCopy(src->hostRec); + + if (src->recommended) + dst->recommended =3D virCPUDefCopy(src->recommended); } =20 =20 @@ -1841,9 +1854,11 @@ static void virQEMUCapsHostCPUDataClear(virQEMUCapsHostCPUData *cpuData) { qemuMonitorCPUModelInfoFree(cpuData->info); + qemuMonitorCPUModelInfoFree(cpuData->hostRec); virCPUDefFree(cpuData->reported); virCPUDefFree(cpuData->migratable); virCPUDefFree(cpuData->full); + virCPUDefFree(cpuData->recommended); =20 memset(cpuData, 0, sizeof(*cpuData)); } @@ -2190,6 +2205,9 @@ virQEMUCapsGetHostModel(virQEMUCaps *qemuCaps, /* 'full' is non-NULL only if we have data from both QEMU and * virCPUGetHost */ return cpuData->full ? cpuData->full : cpuData->reported; + + case VIR_QEMU_CAPS_HOST_CPU_RECOMMENDED: + return cpuData->recommended; } =20 return NULL; @@ -2202,7 +2220,8 @@ virQEMUCapsSetHostModel(virQEMUCaps *qemuCaps, unsigned int physAddrSize, virCPUDef *reported, virCPUDef *migratable, - virCPUDef *full) + virCPUDef *full, + virCPUDef *recommended) { virQEMUCapsHostCPUData *cpuData; =20 @@ -2211,6 +2230,7 @@ virQEMUCapsSetHostModel(virQEMUCaps *qemuCaps, cpuData->reported =3D reported; cpuData->migratable =3D migratable; cpuData->full =3D full; + cpuData->recommended =3D recommended; } =20 =20 @@ -3048,6 +3068,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCaps *qemuCaps, { const char *model =3D virQEMUCapsTypeIsAccelerated(virtType) ? "host" = : "max"; g_autoptr(qemuMonitorCPUModelInfo) modelInfo =3D NULL; + g_autoptr(qemuMonitorCPUModelInfo) hostRecInfo =3D NULL; g_autoptr(qemuMonitorCPUModelInfo) nonMigratable =3D NULL; g_autoptr(virCPUDef) cpu =3D NULL; qemuMonitorCPUModelExpansionType type; @@ -3133,6 +3154,19 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCaps *qemuCaps, return -1; } =20 + /* Retrieve the hypervisor recommended host CPU */ + if (virQEMUCapsTypeIsAccelerated(virtType) && + ARCH_IS_S390(qemuCaps->arch) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_STATI= C_RECOMMENDED)) { + type =3D QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_REC; + + if (qemuMonitorGetCPUModelExpansion(mon, type, cpu, true, false, f= ail_no_props, + &hostRecInfo) < 0) + return -1; + + accel->hostCPU.hostRec =3D g_steal_pointer(&hostRecInfo); + } + accel->hostCPU.info =3D g_steal_pointer(&modelInfo); return 0; } @@ -3157,7 +3191,7 @@ virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, size_t n; =20 *features =3D NULL; - modelInfo =3D virQEMUCapsGetCPUModelInfo(qemuCaps, virtType); + modelInfo =3D virQEMUCapsGetCPUModelInfo(qemuCaps, virtType, false); =20 if (!modelInfo) return 0; @@ -3725,14 +3759,19 @@ int virQEMUCapsInitCPUModel(virQEMUCaps *qemuCaps, virDomainVirtType type, virCPUDef *cpu, - bool migratable) + bool migratable, + bool recommended) { - qemuMonitorCPUModelInfo *modelInfo =3D virQEMUCapsGetCPUModelInfo(qemu= Caps, type); + qemuMonitorCPUModelInfo *modelInfo =3D virQEMUCapsGetCPUModelInfo(qemu= Caps, type, + recomm= ended); int ret =3D 1; =20 if (migratable && modelInfo && !modelInfo->migratability) return 1; =20 + if (recommended && !modelInfo) + return 2; + if (ARCH_IS_S390(qemuCaps->arch)) { ret =3D virQEMUCapsInitCPUModelS390(qemuCaps, type, modelInfo, cpu, migratable); @@ -3775,6 +3814,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, virCPUDef *hostCPU =3D NULL; virCPUDef *fullCPU =3D NULL; unsigned int physAddrSize =3D 0; + virCPUDef *recCPU =3D NULL; size_t i; int rc; =20 @@ -3784,7 +3824,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, if (!(cpu =3D virQEMUCapsNewHostCPUModel())) goto error; =20 - if ((rc =3D virQEMUCapsInitCPUModel(qemuCaps, type, cpu, false)) < 0) { + if ((rc =3D virQEMUCapsInitCPUModel(qemuCaps, type, cpu, false, false)= ) < 0) { goto error; } else if (rc =3D=3D 1) { g_autoptr(virDomainCapsCPUModels) cpuModels =3D NULL; @@ -3823,7 +3863,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, if (!(migCPU =3D virQEMUCapsNewHostCPUModel())) goto error; =20 - if ((rc =3D virQEMUCapsInitCPUModel(qemuCaps, type, migCPU, true)) < 0= ) { + if ((rc =3D virQEMUCapsInitCPUModel(qemuCaps, type, migCPU, true, fals= e)) < 0) { goto error; } else if (rc =3D=3D 1) { VIR_DEBUG("CPU migratability not provided by QEMU"); @@ -3833,6 +3873,17 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, goto error; } =20 + if (!(recCPU =3D virQEMUCapsNewHostCPUModel())) + goto error; + + if ((rc =3D virQEMUCapsInitCPUModel(qemuCaps, type, recCPU, false, tru= e)) < 0) { + goto error; + } else if (rc =3D=3D 2) { + VIR_DEBUG("CPU reccomendation not provided by QEMU"); + virCPUDefFree(recCPU); + recCPU =3D NULL; + } + if (ARCH_IS_X86(qemuCaps->arch) && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_UNAVAILABLE_FEATURES)) { if (cpu && @@ -3851,7 +3902,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, if (virQEMUCapsTypeIsAccelerated(type)) virHostCPUGetPhysAddrSize(hostArch, &physAddrSize); =20 - virQEMUCapsSetHostModel(qemuCaps, type, physAddrSize, cpu, migCPU, ful= lCPU); + virQEMUCapsSetHostModel(qemuCaps, type, physAddrSize, cpu, migCPU, ful= lCPU, recCPU); =20 cleanup: virCPUDefFree(cpuExpanded); @@ -3862,6 +3913,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps, virCPUDefFree(cpu); virCPUDefFree(migCPU); virCPUDefFree(fullCPU); + virCPUDefFree(recCPU); virResetLastError(); goto cleanup; } @@ -3878,8 +3930,12 @@ virQEMUCapsUpdateHostCPUModel(virQEMUCaps *qemuCaps, =20 qemuMonitorCPUModelInfo * virQEMUCapsGetCPUModelInfo(virQEMUCaps *qemuCaps, - virDomainVirtType type) + virDomainVirtType type, + bool recommended) { + if (recommended) + return virQEMUCapsGetAccel(qemuCaps, type)->hostCPU.hostRec; + return virQEMUCapsGetAccel(qemuCaps, type)->hostCPU.info; } =20 @@ -4006,6 +4062,17 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *ca= ps, } =20 =20 +static int +virQEMUCapsLoadHostRecCPUModelInfo(virQEMUCapsAccel *caps, + xmlXPathContextPtr ctxt, + const char *typeStr) +{ + g_autofree char *xpath =3D g_strdup_printf("./hostRecCPU[@type=3D'%s']= ", typeStr); + + return virQEMUCapsLoadCPUModelInfo(&caps->hostCPU.hostRec, ctxt, xpath= ); +} + + static int virQEMUCapsLoadCPUModels(virArch arch, virQEMUCapsAccel *caps, @@ -4169,6 +4236,10 @@ virQEMUCapsLoadAccel(virQEMUCaps *qemuCaps, if (virQEMUCapsLoadHostCPUModelInfo(caps, ctxt, typeStr) < 0) return -1; =20 + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION_STATI= C_RECOMMENDED) && + virQEMUCapsLoadHostRecCPUModelInfo(caps, ctxt, typeStr) < 0) + return -1; + if (virQEMUCapsLoadCPUModels(qemuCaps->arch, caps, ctxt, typeStr) < 0) return -1; =20 @@ -4705,18 +4776,24 @@ virQEMUCapsLoadCache(virArch hostArch, static void virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *caps, virBuffer *buf, - const char *typeStr) + const char *typeStr, + bool recommended) { - qemuMonitorCPUModelInfo *model =3D caps->hostCPU.info; + qemuMonitorCPUModelInfo *model; size_t i; =20 + if (recommended) + model =3D caps->hostCPU.hostRec; + else + model =3D caps->hostCPU.info; + if (!model) return; =20 virBufferAsprintf(buf, - "\n", - typeStr, model->name, - model->migratability ? "yes" : "no"); + "<%s type=3D'%s' model=3D'%s' migratability=3D'%s'>\= n", + recommended ? "hostRecCPU" : "hostCPU", typeStr, + model->name, model->migratability ? "yes" : "no"); virBufferAdjustIndent(buf, 2); =20 for (i =3D 0; i < model->nprops; i++) { @@ -4752,7 +4829,7 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *c= aps, } =20 virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + virBufferAsprintf(buf, "\n", recommended ? "hostRecCPU" : "hostCP= U"); } =20 =20 @@ -4846,7 +4923,8 @@ virQEMUCapsFormatAccel(virQEMUCaps *qemuCaps, virQEMUCapsAccel *caps =3D virQEMUCapsGetAccel(qemuCaps, type); const char *typeStr =3D virQEMUCapsAccelStr(type); =20 - virQEMUCapsFormatHostCPUModelInfo(caps, buf, typeStr); + virQEMUCapsFormatHostCPUModelInfo(caps, buf, typeStr, false); + virQEMUCapsFormatHostCPUModelInfo(caps, buf, typeStr, true); virQEMUCapsFormatCPUModels(qemuCaps->arch, caps, buf, typeStr); virQEMUCapsFormatMachines(caps, buf, typeStr); =20 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 4fa64b6435..bb68b74328 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -726,6 +726,9 @@ typedef enum { * combined with features reported by QEMU. This is used for backward * compatible comparison between a guest CPU and a host CPU. */ VIR_QEMU_CAPS_HOST_CPU_FULL, + /* Host CPU definition with a modified feature set based on dropped + * features on newer CPU models. */ + VIR_QEMU_CAPS_HOST_CPU_RECOMMENDED, } virQEMUCapsHostCPUType; =20 virCPUDef *virQEMUCapsGetHostModel(virQEMUCaps *qemuCaps, diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h index 06b36d2eb8..a97710eecf 100644 --- a/src/qemu/qemu_capspriv.h +++ b/src/qemu/qemu_capspriv.h @@ -64,11 +64,13 @@ int virQEMUCapsInitCPUModel(virQEMUCaps *qemuCaps, virDomainVirtType type, virCPUDef *cpu, - bool migratable); + bool migratable, + bool recommended); =20 qemuMonitorCPUModelInfo * virQEMUCapsGetCPUModelInfo(virQEMUCaps *qemuCaps, - virDomainVirtType type); + virDomainVirtType type, + bool recommended); =20 void virQEMUCapsSetCPUModelInfo(virQEMUCaps *qemuCaps, diff --git a/tests/cputest.c b/tests/cputest.c index b3253e3116..8d3a0dd4d9 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -857,7 +857,7 @@ cpuTestJSONCPUID(const void *arg) cpu->match =3D VIR_CPU_MATCH_EXACT; cpu->fallback =3D VIR_CPU_FALLBACK_FORBID; =20 - if (virQEMUCapsInitCPUModel(qemuCaps, VIR_DOMAIN_VIRT_KVM, cpu, false)= !=3D 0) + if (virQEMUCapsInitCPUModel(qemuCaps, VIR_DOMAIN_VIRT_KVM, cpu, false,= false) !=3D 0) return -1; =20 return cpuTestCompareXML(data->arch, cpu, result); @@ -875,7 +875,7 @@ cpuTestJSONSignature(const void *arg) if (!(qemuCaps =3D cpuTestMakeQEMUCaps(data))) return -1; =20 - modelInfo =3D virQEMUCapsGetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM= ); + modelInfo =3D virQEMUCapsGetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM= , false); if (!(hostData =3D virQEMUCapsGetCPUModelX86Data(qemuCaps, modelInfo, = false))) return -1; =20 diff --git a/tests/qemucapabilitiesdata/caps_8.1.0_s390x.replies b/tests/qe= mucapabilitiesdata/caps_8.1.0_s390x.replies index 8cd7312bea..2720408726 100644 --- a/tests/qemucapabilitiesdata/caps_8.1.0_s390x.replies +++ b/tests/qemucapabilitiesdata/caps_8.1.0_s390x.replies @@ -29649,6 +29649,80 @@ "id": "libvirt-37" } =20 +{ + "execute": "query-cpu-model-expansion", + "arguments": { + "type": "static-recommended", + "model": { + "name": "host" + } + }, + "id": "libvirt-38" +} + +{ + "return": { + "model": { + "name": "gen16a-base", + "props": { + "nnpa": true, + "aen": true, + "cmmnt": true, + "vxpdeh": true, + "aefsi": true, + "diag318": true, + "csske": false, + "mepoch": true, + "msa9": true, + "msa8": true, + "msa7": true, + "msa6": true, + "msa5": true, + "msa4": true, + "msa3": true, + "msa2": true, + "msa1": true, + "sthyi": true, + "edat": true, + "ri": true, + "deflate": true, + "edat2": true, + "etoken": true, + "vx": true, + "ipter": true, + "pai": true, + "paie": true, + "mepochptff": true, + "ap": true, + "vxeh": true, + "vxpd": true, + "esop": true, + "msa9_pckmo": true, + "vxeh2": true, + "esort": true, + "apqi": true, + "apft": true, + "els": true, + "iep": true, + "apqci": true, + "cte": false, + "ais": true, + "bpb": false, + "gs": true, + "ppa15": true, + "zpci": true, + "rdp": true, + "sea_esop2": true, + "beareh": true, + "te": false, + "cmm": true, + "vxpdeh2": true + } + } + }, + "id": "libvirt-38" +} + { "execute": "qmp_capabilities", "id": "libvirt-1" diff --git a/tests/qemucapabilitiesdata/caps_8.1.0_s390x.xml b/tests/qemuca= pabilitiesdata/caps_8.1.0_s390x.xml index 0bb4233383..c580cbb5b0 100644 --- a/tests/qemucapabilitiesdata/caps_8.1.0_s390x.xml +++ b/tests/qemucapabilitiesdata/caps_8.1.0_s390x.xml @@ -171,6 +171,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --=20 2.41.0