From nobody Fri Dec 27 12:36:54 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 17314335358961002.9673604953034; Tue, 12 Nov 2024 09:45:35 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id CF20017A5; Tue, 12 Nov 2024 12:45:34 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0E6EE1976; Tue, 12 Nov 2024 12:43:12 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id AFA571450; Tue, 12 Nov 2024 12:43:02 -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 0E676144B for ; Tue, 12 Nov 2024 12:43:01 -0500 (EST) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4ACHe64u030157 for ; Tue, 12 Nov 2024 17:43:01 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42vbm5g0av-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 12 Nov 2024 17:43:00 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4ACHZ2W8029698 for ; Tue, 12 Nov 2024 17:42:59 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 42tkjkue7q-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 smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4ACHgwSS28639590 (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 E09E35805D for ; Tue, 12 Nov 2024 17:42:58 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B1D3358056 for ; Tue, 12 Nov 2024 17:42:58 +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=uJdSZfz8iytkMbdoA vuf7SFW+ZzAEy0jo7ihLf3N7C4=; b=CE9170EuTy3Y/dgM9s1O2cCZ1mdxMNCvu XvPpiL+SPJ87E9KxDRwPBXOJT5C4VPP8polwA2sYuy3ogMq6ikppRUjv38LVIvj7 +bWmMnPkO8wNHzbELVdi10I1sB188Wr7FCBSgKLDSKVs2D9XACPGjI1AboCd2LYH cA+PO6tgWXCNDowp6+/8QlnG/CtHsf4KFuRsbVvcTHEizG87IwQbXUa4JiRRtdpj HsLxoAXSXhhpnG9nN8RkiJk+D+7WvPuNCAVOTjX4Gys7PAxknop2UuXJc104Q0yG FndVdIOKHo7Tvw+RnJP519U0gXa6rbpxLRol+sx2JVPPchAlrD+IA== From: Collin Walling To: devel@lists.libvirt.org Subject: [PATCH v1 1/5] qemuMonitorJSONGetCPUModelExpansion: refactor parsing functions Date: Tue, 12 Nov 2024 12:39:56 -0500 Message-ID: <20241112174000.27518-2-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-ORIG-GUID: Z99v9VyYuUz2PUfS4qd_Rbkw35DwhH2h X-Proofpoint-GUID: Z99v9VyYuUz2PUfS4qd_Rbkw35DwhH2h 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 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 priorityscore=1501 impostorscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 mlxscore=0 mlxlogscore=872 malwarescore=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: JF22NE3AVLFA76XFIEMRX64JCS2LO3RU X-Message-ID-Hash: JF22NE3AVLFA76XFIEMRX64JCS2LO3RU 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: 1731433536534116600 Content-Type: text/plain; charset="utf-8" Refactor the CPU Model parsing functions within qemuMonitorJSONGetCPUModelExpansion. The new functions, qemuMonitorJSONParseCPUModelExpansionData and qemuMonitorJSONParseCPUModelExpansion invoke the functions they replace and leave room for a subsequent patch to handle parsing the (optional) deprecated_props field resulting from the command. Signed-off-by: Collin Walling --- src/qemu/qemu_monitor_json.c | 46 ++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index c594b33106..7c916efacf 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5090,6 +5090,37 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name, } =20 =20 +static int +qemuMonitorJSONParseCPUModelExpansionData(virJSONValue *data, + bool fail_no_props, + virJSONValue **cpu_model, + virJSONValue **cpu_props, + const char **cpu_name) +{ + if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-expansion", + fail_no_props, cpu_model, cpu_pro= ps, + cpu_name) < 0) + return -1; + + return 0; +} + + +static int +qemuMonitorJSONParseCPUModelExpansion(const char *cpu_name, + virJSONValue *cpu_props, + qemuMonitorCPUModelInfo **model_info) +{ + g_autoptr(qemuMonitorCPUModelInfo) expanded_model =3D NULL; + + if (qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, &expanded_model)= < 0) + return -1; + + *model_info =3D g_steal_pointer(&expanded_model); + return 0; +} + + static int qemuMonitorJSONQueryCPUModelExpansionOne(qemuMonitor *mon, qemuMonitorCPUModelExpansionType = type, @@ -5160,9 +5191,9 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon, if ((rc =3D qemuMonitorJSONQueryCPUModelExpansionOne(mon, type, &model= , &data)) <=3D 0) return rc; =20 - if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-expansion", - fail_no_props, &cpu_model, &cpu_p= rops, - &cpu_name) < 0) + if (qemuMonitorJSONParseCPUModelExpansionData(data, fail_no_props, + &cpu_model, &cpu_props, + &cpu_name) < 0) return -1; =20 /* QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL requests "full" expans= ion @@ -5178,13 +5209,14 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mo= n, if ((rc =3D qemuMonitorJSONQueryCPUModelExpansionOne(mon, type, &f= ullModel, &fullData)) <=3D 0) return rc; =20 - if (qemuMonitorJSONParseCPUModelData(fullData, "query-cpu-model-ex= pansion", - fail_no_props, &cpu_model, &c= pu_props, - &cpu_name) < 0) + if (qemuMonitorJSONParseCPUModelExpansionData(fullData, fail_no_pr= ops, + &cpu_model, &cpu_pro= ps, + &cpu_name) < 0) return -1; } =20 - return qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, model_info); + return qemuMonitorJSONParseCPUModelExpansion(cpu_name, cpu_props, + model_info); } =20 =20 --=20 2.45.1