From nobody Sun Dec 22 08:54:06 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 1734390430650781.790776260859; Mon, 16 Dec 2024 15:07:10 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id A4E011505; Mon, 16 Dec 2024 18:07:09 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 954331569; Mon, 16 Dec 2024 18:04:29 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 64A9314B5; Mon, 16 Dec 2024 18:04:21 -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 9593A14AC for ; Mon, 16 Dec 2024 18:04:20 -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 4BGCr38K008928; Mon, 16 Dec 2024 23:04:19 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 43j98h5sxy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 16 Dec 2024 23:04:19 +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 4BGLDTDp014340; Mon, 16 Dec 2024 23:04:18 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 43hmqy081e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 16 Dec 2024 23:04:18 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4BGN4GZq30474828 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 23:04:16 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 847FE5808E; Mon, 16 Dec 2024 23:04:16 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 155755808B; Mon, 16 Dec 2024 23:04:16 +0000 (GMT) Received: from li-d664314c-3171-11b2-a85c-fa8047ef35bd.ibm.com.com (unknown [9.67.33.76]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 16 Dec 2024 23:04:15 +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=-2.4 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=h1l/3DLs0rY0A1ZR2 hIBzf7EDwdQJAQ/FAWjBcYV3DQ=; b=RMKJNy9K7xSW03HenNEs4LDjnXr+KDw0d l8RowQWQRSXs461UF8ZI4KfxjLRVLjPGIEYcdSSGjDO4gyN86ljZ4EhHXjXfwIzL F6Z/jOhRb6xTuVyXgdGzx6/0ucupAl/+Yj3ODkX/ySqwBSu+DWPRvFAKx4AIiexj LnaltnLVwDmLBrS9ezKDfIYeih0ao5Mf3bT9VGzC0QQsCuETtWYO5cdOIvT0ycJ1 phUgMYqtBTBj8KhrpsDTUAvo4GD0tNUwBJouXDFWRz6ZF1HdY3fgV20r16f0lCxo D1+pThQbupo7njUnN/ZuFNHhfHFkmy7ouDEvIF39KmclfYxBag8cA== From: Collin Walling To: devel@lists.libvirt.org Subject: [PATCH v3 2/7] qemu: parse deprecated-props from query-cpu-model-expansion response Date: Mon, 16 Dec 2024 18:03:53 -0500 Message-ID: <20241216230358.60940-3-walling@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241216230358.60940-1-walling@linux.ibm.com> References: <20241216230358.60940-1-walling@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: sZ_WR2LfpYlpAexbpcsn76CMrekWYdVy X-Proofpoint-GUID: sZ_WR2LfpYlpAexbpcsn76CMrekWYdVy 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 priorityscore=1501 phishscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 bulkscore=0 adultscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412160188 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LYW5CLLVEDLMP6EG7EMIXOCEV6FKTVEN X-Message-ID-Hash: LYW5CLLVEDLMP6EG7EMIXOCEV6FKTVEN 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 CC: fiuczy@linux.ibm.com, jdenemar@redhat.com 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: 1734390431250116600 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 Reviewed-by: Boris Fiuczynski --- src/qemu/qemu_capabilities.c | 31 +++++++++++++++++++ src/qemu/qemu_monitor.c | 7 +++++ 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, 69 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index dec3199fce..e7dacb5570 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4019,6 +4019,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; @@ -4111,6 +4112,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 + 1); + + 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; } @@ -4843,6 +4862,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 73f37d26eb..8590a1a0a5 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3306,6 +3306,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); @@ -3350,6 +3351,12 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUMode= lInfo *orig) } } =20 + if (orig->deprecated_props) { + copy->deprecated_props =3D g_new0(char *, + g_strv_length(orig->deprecated_pro= ps)); + copy->deprecated_props =3D g_strdupv(orig->deprecated_props); + } + return copy; } =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 89a59dfd27..d4d9b98ba7 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1150,6 +1150,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 fa8c5b1aea..6500e01d3f 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5105,6 +5105,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", @@ -5112,6 +5113,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 @@ -5119,6 +5126,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; @@ -5126,6 +5134,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; } @@ -5190,6 +5204,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 @@ -5203,6 +5218,7 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, =20 if (qemuMonitorJSONParseCPUModelExpansionData(data, fail_no_props, &cpu_model, &cpu_props, + &cpu_deprecated_props, &cpu_name) < 0) return -1; =20 @@ -5221,11 +5237,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 6d4f6726fb..79a149d187 100644 --- a/tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml +++ b/tests/qemucapabilitiesdata/caps_9.2.0_s390x.xml @@ -196,6 +196,12 @@ + + + + + + --=20 2.47.1