From nobody Fri Dec 27 12:35:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 173143357632082.68186410123008; Tue, 12 Nov 2024 09:46:16 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 382A61950; Tue, 12 Nov 2024 12:46:15 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7209117DD; Tue, 12 Nov 2024 12:43:13 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 340241453; Tue, 12 Nov 2024 12:43:03 -0500 (EST) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 685451464 for ; Tue, 12 Nov 2024 12:43:02 -0500 (EST) Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4ACHbCaB031378 for ; Tue, 12 Nov 2024 17:43:01 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42v9dv0na3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 12 Nov 2024 17:43:01 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4ACGKrpF008404 for ; Tue, 12 Nov 2024 17:43:00 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 42tjeykyjh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 12 Nov 2024 17:42:59 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4ACHgxIF47382968 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 12 Nov 2024 17:42:59 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 35C1E58069 for ; Tue, 12 Nov 2024 17:42:59 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0488658056 for ; Tue, 12 Nov 2024 17:42:59 +0000 (GMT) Received: from li-d664314c-3171-11b2-a85c-fa8047ef35bd.ibm.com.com (unknown [9.67.103.128]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP for ; Tue, 12 Nov 2024 17:42:58 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h= content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=wO6HW6vWuPc/Qq/7B +4jTefqyYOwAQ1Oa3rgn35UZ7k=; b=c53ssdJaFnQ/xygrdMwUMPrBBGYCRm1Pr BC2+p5hj3sJcDZkn6aprAgwEskh4teQycZl4xrmb4VZlfOU0xMVXpk3dtDusH4cq nWAtj7I+dJzcy/HO0OVS9JKpfmQpsOoxleuTADmjfaAP+wdQBbR7klH9wlty4VpD uZBchDO7Xl8e+4lcjrcH+mk7FEE+6NFJPGIZVgEjWDNBh8SIAVfMYceRU/m38u/Q +oKvVe0NJIQ/pbwiOC78c0U4DY+pCUdTpdF9IpxPDhxvWsENYO1KJbJSDREEX7Po 0uqLo8tgwJgEx7FD7gRz6xcqh+NqNFpz8FH3SLyKI2rsXH8/nVxQQ== From: Collin Walling To: devel@lists.libvirt.org Subject: [PATCH v1 2/5] qemu: parse deprecated-props from query-cpu-model-expansion response Date: Tue, 12 Nov 2024 12:39:57 -0500 Message-ID: <20241112174000.27518-3-walling@linux.ibm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20241112174000.27518-1-walling@linux.ibm.com> References: <20241112174000.27518-1-walling@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 3U7HsTUgC-cXDXtnZc4OViJidTTPiJHE X-Proofpoint-ORIG-GUID: 3U7HsTUgC-cXDXtnZc4OViJidTTPiJHE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 priorityscore=1501 mlxscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411120141 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VXHTR3JLWZRHMVYTDLKQAFXW2PZD3VMH X-Message-ID-Hash: VXHTR3JLWZRHMVYTDLKQAFXW2PZD3VMH X-MailFrom: walling@linux.ibm.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1731433576770116600 Content-Type: text/plain; charset="utf-8" query-cpu-model-expansion may report an array of deprecated properties. This array is optional, and may not be supported for a particular architecture or reported for a particular CPU model. If the output is present, then capture it and store in a qemuMonitorCPUModelInfo struct for later use. The deprecated features will be retained in qemuCaps->kvm->hostCPU.info and will be stored in the capabilities cache file under the element using the following format: At this time the data is only queried, parsed, and cached. The data will be utilized in a subsequent patch. Signed-off-by: Collin Walling --- src/qemu/qemu_capabilities.c | 31 +++++++++++++++++++ src/qemu/qemu_monitor.c | 10 ++++++ src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 18 +++++++++++ .../qemucapabilitiesdata/caps_9.1.0_s390x.xml | 6 ++++ .../qemucapabilitiesdata/caps_9.2.0_s390x.xml | 6 ++++ 6 files changed, 72 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 6b67da30ec..9850ed8458 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4013,6 +4013,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *cap= s, const char *typeStr) { xmlNodePtr hostCPUNode; + xmlNodePtr deprecated_props; g_autofree xmlNodePtr *nodes =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autoptr(qemuMonitorCPUModelInfo) hostCPU =3D NULL; @@ -4105,6 +4106,24 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *ca= ps, } } =20 + ctxt->node =3D hostCPUNode; + + if ((deprecated_props =3D virXPathNode("./deprecatedFeatures", ctxt)))= { + g_autoptr(GPtrArray) props =3D virXMLNodeGetSubelementList(depreca= ted_props, NULL); + + hostCPU->deprecated_props =3D g_new0(char *, props->len); + + for (i =3D 0; i < props->len; i++) { + xmlNodePtr prop =3D g_ptr_array_index(props, i); + + if (!(hostCPU->deprecated_props[i] =3D virXMLPropString(prop, = "name"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing 'name' attribute for a host CPU = model deprecated property in QEMU capabilities cache")); + return -1; + } + } + } + caps->hostCPU.info =3D g_steal_pointer(&hostCPU); return 0; } @@ -4837,6 +4856,18 @@ virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsAccel *= caps, virBufferAddLit(buf, "/>\n"); } =20 + if (model->deprecated_props) { + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + + for (i =3D 0; i < g_strv_length(model->deprecated_props); i++) + virBufferAsprintf(buf, "\n", + model->deprecated_props[i]); + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index fd888e2468..e5d231a867 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3290,6 +3290,7 @@ qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfo *= model_info) g_free(model_info->props[i].value.string); } =20 + g_strfreev(model_info->deprecated_props); g_free(model_info->props); g_free(model_info->name); g_free(model_info); @@ -3334,6 +3335,15 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUMode= lInfo *orig) } } =20 + if (orig->deprecated_props) { + copy->deprecated_props =3D g_new0(char *, + g_strv_length(orig->deprecated_pro= ps)); + + for (i =3D 0; i < g_strv_length(orig->deprecated_props); i++) { + copy->deprecated_props[i] =3D g_strdup(orig->deprecated_props[= i]); + } + } + return copy; } =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 4341519cfe..97bc1d9a2c 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1146,6 +1146,7 @@ struct _qemuMonitorCPUModelInfo { char *name; size_t nprops; qemuMonitorCPUProperty *props; + GStrv deprecated_props; bool migratability; }; =20 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7c916efacf..5216284c31 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5095,6 +5095,7 @@ qemuMonitorJSONParseCPUModelExpansionData(virJSONValu= e *data, bool fail_no_props, virJSONValue **cpu_model, virJSONValue **cpu_props, + virJSONValue **cpu_deprecated_pr= ops, const char **cpu_name) { if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-expansion", @@ -5102,6 +5103,12 @@ qemuMonitorJSONParseCPUModelExpansionData(virJSONVal= ue *data, cpu_name) < 0) return -1; =20 + /* + * Unconditionally check for the deprecated-props array, as + * it is not a guarantee response even if QEMU supports it. + */ + *cpu_deprecated_props =3D virJSONValueObjectGetArray(data, "deprecated= -props"); + return 0; } =20 @@ -5109,6 +5116,7 @@ qemuMonitorJSONParseCPUModelExpansionData(virJSONValu= e *data, static int qemuMonitorJSONParseCPUModelExpansion(const char *cpu_name, virJSONValue *cpu_props, + virJSONValue *cpu_deprecated_props, qemuMonitorCPUModelInfo **model_info) { g_autoptr(qemuMonitorCPUModelInfo) expanded_model =3D NULL; @@ -5116,6 +5124,12 @@ qemuMonitorJSONParseCPUModelExpansion(const char *cp= u_name, if (qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, &expanded_model)= < 0) return -1; =20 + if (cpu_deprecated_props && + virJSONValueArraySize(cpu_deprecated_props) && + (!(expanded_model->deprecated_props =3D virJSONValueArrayToStringL= ist(cpu_deprecated_props)))) { + return -1; + } + *model_info =3D g_steal_pointer(&expanded_model); return 0; } @@ -5180,6 +5194,7 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, g_autoptr(virJSONValue) fullData =3D NULL; virJSONValue *cpu_model; virJSONValue *cpu_props =3D NULL; + virJSONValue *cpu_deprecated_props =3D NULL; const char *cpu_name =3D ""; int rc; =20 @@ -5193,6 +5208,7 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, =20 if (qemuMonitorJSONParseCPUModelExpansionData(data, fail_no_props, &cpu_model, &cpu_props, + &cpu_deprecated_props, &cpu_name) < 0) return -1; =20 @@ -5211,11 +5227,13 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mo= n, =20 if (qemuMonitorJSONParseCPUModelExpansionData(fullData, fail_no_pr= ops, &cpu_model, &cpu_pro= ps, + &cpu_deprecated_prop= s, &cpu_name) < 0) return -1; } =20 return qemuMonitorJSONParseCPUModelExpansion(cpu_name, cpu_props, + cpu_deprecated_props, model_info); } =20 diff --git a/tests/qemucapabilitiesdata/caps_9.1.0_s390x.xml b/tests/qemuca= pabilitiesdata/caps_9.1.0_s390x.xml index 50e9a60a1f..5e8db88e52 100644 --- a/tests/qemucapabilitiesdata/caps_9.1.0_s390x.xml +++ b/tests/qemucapabilitiesdata/caps_9.1.0_s390x.xml @@ -193,6 +193,12 @@ + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml b/tests/qemuca= pabilitiesdata/caps_9.2.0_s390x.xml index 68a6778a25..0fa73e9918 100644 --- a/tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml +++ b/tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml @@ -195,6 +195,12 @@ + + + + + + --=20 2.45.1