From nobody Sat Oct 24 20:20:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1791196855; cv=none; d=zohomail.com; s=zohoarc; b=WUubkEnNbKQoCFgNeuI02CpHTEHDpBOxmw+lyXH7Jdg9iu2oNspYxWmYy5XXNRc7huklHVHHVikYxqUpWOvo7Jg0GbVY0rSN61WkFMlKL+Gzfr7cNlNmpf3UfX7uCAm1dALBR0/4s6zal89FO79ilINttRJo1mCi65DFiVRySXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791196855; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=T6beIQa4tmRPIcY+37lQSDfcN7n+aL3gmSnIWVxy4/o=; b=d1fqkfcRfybKFDUg3uRydCOFSTIagQKxzRUipKVJxWgJwfZsjjN1QnJsfhaVOu3EhSYAbPmI536dyz/KpyGLIq7ruDy4BE5MyQNRtTM6sLsAzpfqcW/UZX5SLWGfw9d+n+x8aE2Oy/tLPLW4LmLOil6qSUxfU34Acjp929mCG+k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1791196855414155.21206089556586; Mon, 5 Oct 2026 03:40:55 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 4085441AED; Mon, 5 Oct 2026 06:40:54 -0400 (EDT) Received: from [172.19.199.16] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id BD3DF419B6; Mon, 5 Oct 2026 06:36:07 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id D70B93FD09; Thu, 1 Oct 2026 22:36:43 -0400 (EDT) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 545443F390 for ; Thu, 1 Oct 2026 22:36:42 -0400 (EDT) Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6922a6iR3548866 for ; Fri, 2 Oct 2026 02:36:41 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 4gx5j5q7kh-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Fri, 02 Oct 2026 02:36:40 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6922K8rw1897651 for ; Fri, 2 Oct 2026 02:36:40 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4h1aa7x2da-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Oct 2026 02:36:39 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6922acc312321514 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Oct 2026 02:36:38 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A585258054; Fri, 2 Oct 2026 02:36:38 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D3175805A; Fri, 2 Oct 2026 02:36:38 +0000 (GMT) Received: from localhost.localdomain (unknown [9.61.240.230]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Oct 2026 02:36:37 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=T6beIQ a4tmRPIcY+37lQSDfcN7n+aL3gmSnIWVxy4/o=; b=Fk8ZzLp1kjzuc3+txUvw3d Zq4SrOFZWt8+Ux07i+ecmxCde665NQ8oKQmMknz1u0ZfBEgNBbDdl6zyDq+uKZc5 Ed0Nq6nYX9ICMk5LCiRiSTyCn/iHhnQUYwslQG5NezatOeT7X4UBE7/n9YrShTqc +C9ac4X1w9oSFCiY2BR8tdkfx5bDH2VG6qINg3QEcHqZs9l9UXlszoz7Fu1ftR14 5zqoFPUudmj24WxSixvVrOxxk/37aNk13Op7XtazCB6f32Noaq01cgDVp3NerPO7 MACPgE21pgWzEXhmLFOKrfK96qpRv0dpdLhbUPX9Hy7TsnStadc3pnoXOJf+tsbw == From: Rorie Reyes To: devel@lists.libvirt.org Subject: [PATCH libvirt v1 1/4] qemu: extend GetCPUModelComparison to return responsible-properties Date: Thu, 1 Oct 2026 22:36:23 -0400 Message-ID: <20261002023636.83991-2-rreyes@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20261002023636.83991-1-rreyes@linux.ibm.com> References: <20261002023636.83991-1-rreyes@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDAyMDAxMCBTYWx0ZWRfX5fJula2OcrMO TJufbVlBeNfhtcUR5L2+f9cvLSjHK+AQAGQTEoCo3+PSAFQCRSiGMcemVtlzNuSvQ8f9VCjP3Fm cVLqwb6XLbgWHKtEKfXQmxYlDrLayOU= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDAyMDAxMCBTYWx0ZWRfX3Q69yDpcqRFQ DTW39Lf5YRAqX8Y9oJB5vVg4XD+1Wh+M/GlFbAI0uYI2qiN6Zf95rG9bleMJbyjZ5a6JVKyY5mL TLwr1DNeP7nXh7QTQwIyyrybXegHryIiYgI35IV5VnH+5f3AnA89TSY2Wvn+4zHNn6C4qwYg3vF PbaXJ+ve1L5Tm6JS24m6eND7vcOzrz9WLGPh++ZDeStPvu2edSiKgmQD2/KJQOVizKz/ofNqWIB eZP/SKWK77eLtUXXsMo7cd8TbjDU+qDuhnzzfwpMOcIA7cxFI7OTJtRA5TmQ86fzQzL/9uZznAw AlepuIBSuetN1TMhgnZi8sEQaX02V5mLOb7Aa3oyPXVmA5iB3x8xyoqmm0j1AaoKln/xWwqA7Q2 +HlGb6sStKzORj3ETv6lVbhwsIWLcpNK9fExg0q0NfrJ3ZLwnD9hwLumf5KvfbnQTNZAC8X1KEf 0QoQ/8dr4BR7xTYk3DA== X-Proofpoint-GUID: hbxFCgsOsEMAIgaDBbWc-0o-DFSYHEAi X-Authority-Analysis: v=2.4 cv=RKcmjIi+ c=1 sm=1 tr=0 ts=6abf18b9 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=StmcJ7hjkdOx9GAX-MIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: hbxFCgsOsEMAIgaDBbWc-0o-DFSYHEAi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-10-02_01,2026-10-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 priorityscore=1501 spamscore=0 bulkscore=0 impostorscore=0 adultscore=0 lowpriorityscore=0 suspectscore=0 malwarescore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2610020010 X-MailFrom: rreyes@linux.ibm.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation Message-ID-Hash: K2UQUHMZ3HKY3FLWKBEMHUUUAKOMTV37 X-Message-ID-Hash: K2UQUHMZ3HKY3FLWKBEMHUUUAKOMTV37 X-Mailman-Approved-At: Mon, 05 Oct 2026 10:34:57 +0000 CC: fiuczy@linux.ibm.com, walling@linux.ibm.com, rreyes@linux.ibm.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1791196856670158503 The qemu-cpu-model-comparison QMP command can return a "responsible-properties" array identifying which CPU properties caused an incompatibility result. Expose this through the JSON monitor layer by adding an optional `responsibleProps` output parameter (char ***) to qemuMonitorJSONGetCPUModelComparison(). When the caller passes a non-NULL pointer the array is populated from the QMP response; passing NULL preserves the existing behaviour so all current callers are unaffected until they opt in. The existing caller in qemu_monitor.c is updated to pass NULL so the build continues to work. A GenericError response from the QMP command is intercepted and re-reported as VIR_ERR_CPU_INCOMPATIBLE with the QEMU error description. Assuming the JSON query was properly constructed, all GenericErrors should indicate an incompatible CPU model due to QEMU binary limitations (e.g. old binary does not recognize newer features or models). The existing unit test is updated to pass the new argument and extended with additional calls: one that verifies the responsible-properties array is correctly populated from the QMP response, one that verifies it is NULL when the key is absent from the response, one that verifies it is NULL when the array is empty, and cases for "identical", "subset", and "superset" results (including a "type" responsible-property) to cover all result-string mappings. Signed-off-by: Rorie Reyes Reviewed-by: Boris Fiuczynski --- src/qemu/qemu_monitor.c | 2 +- src/qemu/qemu_monitor_json.c | 26 +++++- src/qemu/qemu_monitor_json.h | 5 +- tests/qemumonitorjsontest.c | 159 +++++++++++++++++++++++++++++++++-- 4 files changed, 182 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 2c86cd1971..e3edc88814 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3335,7 +3335,7 @@ qemuMonitorGetCPUModelComparison(qemuMonitor *mon, =20 QEMU_CHECK_MONITOR(mon); =20 - return qemuMonitorJSONGetCPUModelComparison(mon, cpu_a, cpu_b, result); + return qemuMonitorJSONGetCPUModelComparison(mon, cpu_a, cpu_b, result,= NULL); } =20 =20 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 8e88dc9442..a895341b67 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5689,7 +5689,8 @@ int qemuMonitorJSONGetCPUModelComparison(qemuMonitor *mon, virCPUDef *cpu_a, virCPUDef *cpu_b, - char **result) + char **result, + char ***responsibleProps) { g_autoptr(virJSONValue) model_a =3D NULL; g_autoptr(virJSONValue) model_b =3D NULL; @@ -5697,6 +5698,11 @@ qemuMonitorJSONGetCPUModelComparison(qemuMonitor *mo= n, g_autoptr(virJSONValue) reply =3D NULL; const char *data_result; virJSONValue *data; + virJSONValue *propsArray; + + *result =3D NULL; + if (responsibleProps) + *responsibleProps =3D NULL; =20 if (!(model_a =3D qemuMonitorJSONMakeCPUModel(cpu_a, true, false)) || !(model_b =3D qemuMonitorJSONMakeCPUModel(cpu_b, true, false))) @@ -5711,6 +5717,13 @@ qemuMonitorJSONGetCPUModelComparison(qemuMonitor *mo= n, if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) return -1; =20 + if (qemuMonitorJSONHasError(reply, "GenericError")) { + virJSONValue *error =3D virJSONValueObjectGet(reply, "error"); + virReportError(VIR_ERR_CPU_INCOMPATIBLE, "%s", + qemuMonitorJSONStringifyError(error)); + return -1; + } + if (qemuMonitorJSONCheckError(cmd, reply) < 0) return -1; =20 @@ -5723,6 +5736,17 @@ qemuMonitorJSONGetCPUModelComparison(qemuMonitor *mo= n, } =20 *result =3D g_strdup(data_result); + + propsArray =3D virJSONValueObjectGetArray(data, "responsible-propertie= s"); + + if (responsibleProps && propsArray && + virJSONValueArraySize(propsArray) > 0 && + !(*responsibleProps =3D virJSONValueArrayToStringList(propsArray))= ) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Invalid 'responsible-properties' list in query-c= pu-model-comparison response")); + return -1; + } + return 0; } =20 diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 63eded7ecb..9a3695d8e1 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -443,8 +443,9 @@ int qemuMonitorJSONGetCPUModelComparison(qemuMonitor *mon, virCPUDef *cpu_a, virCPUDef *cpu_b, - char **result) - ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); + char **result, + char ***responsibleProps) + ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); =20 GHashTable * qemuMonitorJSONGetCommandLineOptions(qemuMonitor *mon); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index a963029c69..ee7123d4c8 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2623,27 +2623,174 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUModelCompa= rison(const void *opaque) g_autoptr(virCPUDef) cpu_a =3D virCPUDefNew(); g_autoptr(virCPUDef) cpu_b =3D virCPUDefNew(); g_autofree char *result =3D NULL; + g_auto(GStrv) responsibleProps =3D NULL; =20 if (!(test =3D qemuMonitorTestNewSchema(data->xmlopt, data->schema))) return -1; =20 + cpu_a->model =3D g_strdup("cpu_a"); + cpu_b->model =3D g_strdup("cpu_b"); + + /* incompatible, NULL responsibleProps =E2=80=94 must still work */ if (qemuMonitorTestAddItem(test, "query-cpu-model-comparison", - "{\"return\":{\"result\":\"test\"}}") < 0) + "{\"return\":{\"result\":\"incompatible\"," + "\"responsible-properties\":[\"prop_a\",\"p= rop_b\"]}}") < 0) return -1; =20 - cpu_a->model =3D g_strdup("cpu_a"); - cpu_b->model =3D g_strdup("cpu_b"); + if (qemuMonitorJSONGetCPUModelComparison(qemuMonitorTestGetMonitor(tes= t), + cpu_a, cpu_b, &result, NULL) = < 0) + return -1; + + if (!result || STRNEQ(result, "incompatible")) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + "Expected result 'incompatible'"); + return -1; + } + + g_clear_pointer(&result, g_free); + + /* incompatible, responsibleProps requested =E2=80=94 missing-features= path */ + if (qemuMonitorTestAddItem(test, "query-cpu-model-comparison", + "{\"return\":{\"result\":\"incompatible\"," + "\"responsible-properties\":[\"prop_a\",\"p= rop_b\"]}}") < 0) + return -1; + + if (qemuMonitorJSONGetCPUModelComparison(qemuMonitorTestGetMonitor(tes= t), + cpu_a, cpu_b, &result, + &responsibleProps) < 0) + return -1; + + if (!result || STRNEQ(result, "incompatible") || + !responsibleProps || + !responsibleProps[0] || STRNEQ(responsibleProps[0], "prop_a") || + !responsibleProps[1] || STRNEQ(responsibleProps[1], "prop_b") || + responsibleProps[2] !=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + "responsible-properties not populated correctly"); + return -1; + } + + g_clear_pointer(&result, g_free); + g_clear_pointer(&responsibleProps, g_strfreev); + + /* responsibleProps requested but key absent in response */ + if (qemuMonitorTestAddItem(test, "query-cpu-model-comparison", + "{\"return\":{\"result\":\"identical\"}}") = < 0) + return -1; + + if (qemuMonitorJSONGetCPUModelComparison(qemuMonitorTestGetMonitor(tes= t), + cpu_a, cpu_b, &result, + &responsibleProps) < 0) + return -1; + + if (responsibleProps !=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + "responsible-properties should be NULL when key abs= ent"); + return -1; + } + + g_clear_pointer(&result, g_free); + + /* responsibleProps requested but array is empty */ + if (qemuMonitorTestAddItem(test, "query-cpu-model-comparison", + "{\"return\":{\"result\":\"incompatible\"," + "\"responsible-properties\":[]}}") < 0) + return -1; + + if (qemuMonitorJSONGetCPUModelComparison(qemuMonitorTestGetMonitor(tes= t), + cpu_a, cpu_b, &result, + &responsibleProps) < 0) + return -1; + + if (responsibleProps !=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + "responsible-properties should be NULL for empty ar= ray"); + return -1; + } + + g_clear_pointer(&result, g_free); + + /* identical =E2=80=94 maps to QEMU_CPU_COMPAT_IDENTICAL, migration al= lowed */ + if (qemuMonitorTestAddItem(test, "query-cpu-model-comparison", + "{\"return\":{\"result\":\"identical\"," + "\"responsible-properties\":[]}}") < 0) + return -1; =20 if (qemuMonitorJSONGetCPUModelComparison(qemuMonitorTestGetMonitor(tes= t), - cpu_a, cpu_b, &result) < 0) + cpu_a, cpu_b, &result, NULL) = < 0) return -1; =20 - if (!result || STRNEQ(result, "test")) { + if (!result || STRNEQ(result, "identical")) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - "Compare result not set"); + "Expected result 'identical'"); return -1; } =20 + g_clear_pointer(&result, g_free); + + /* subset =E2=80=94 maps to QEMU_CPU_COMPAT_SUBSET, migration allowed = */ + if (qemuMonitorTestAddItem(test, "query-cpu-model-comparison", + "{\"return\":{\"result\":\"subset\"," + "\"responsible-properties\":[]}}") < 0) + return -1; + + if (qemuMonitorJSONGetCPUModelComparison(qemuMonitorTestGetMonitor(tes= t), + cpu_a, cpu_b, &result, NULL) = < 0) + return -1; + + if (!result || STRNEQ(result, "subset")) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + "Expected result 'subset'"); + return -1; + } + + g_clear_pointer(&result, g_free); + + /* superset with "type" prop =E2=80=94 generation-mismatch error path = */ + if (qemuMonitorTestAddItem(test, "query-cpu-model-comparison", + "{\"return\":{\"result\":\"superset\"," + "\"responsible-properties\":[\"type\"]}}") = < 0) + return -1; + + if (qemuMonitorJSONGetCPUModelComparison(qemuMonitorTestGetMonitor(tes= t), + cpu_a, cpu_b, &result, + &responsibleProps) < 0) + return -1; + + if (!result || STRNEQ(result, "superset") || + !responsibleProps || + !responsibleProps[0] || STRNEQ(responsibleProps[0], "type") || + responsibleProps[1] !=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + "Expected result 'superset' with props=3D[\"type\"]= "); + return -1; + } + + g_clear_pointer(&result, g_free); + g_clear_pointer(&responsibleProps, g_strfreev); + + /* GenericError from QEMU must be converted to VIR_ERR_CPU_INCOMPATIBL= E */ + if (qemuMonitorTestAddItem(test, "query-cpu-model-comparison", + "{\"error\":{\"class\":\"GenericError\"," + "\"desc\":\"CPU model not found\"}}") < 0) + return -1; + + if (qemuMonitorJSONGetCPUModelComparison(qemuMonitorTestGetMonitor(tes= t), + cpu_a, cpu_b, &result, NULL) = >=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + "Expected query-cpu-model-comparison to fail on Gen= ericError"); + return -1; + } else { + virErrorPtr err =3D virGetLastError(); + if (!err || err->code !=3D VIR_ERR_CPU_INCOMPATIBLE || + !strstr(err->message, "CPU model not found")) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + "Expected VIR_ERR_CPU_INCOMPATIBLE with QEMU er= ror desc"); + return -1; + } + virResetLastError(); + } + return 0; } =20 --=20 2.48.1 From nobody Sat Oct 24 20:20:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1791196937; cv=none; d=zohomail.com; s=zohoarc; b=Bi36fKePo68lwzCc/C37I8FxrXyLXHj88KG2eTmT28KxWt6T2gzTQTlgDyictjWWbisnlXNQ1tJ60oBNLcr+tZwkI3QKE8s3LHks4hB9UBLfmRu5ffAw4igIi+se1H9w9PgGvCpd06YFKOTc7qbYUwdMBsUalHegmqayt7HfImE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791196937; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=ujiPtMqMJ1O0bjySyailtgOlTQFKoHag+I0khbyF2rk=; b=NHCrMjEwPbNiMDaJTyzcAjUgWsXoHGQL3lJBb4aLe/3SfvyfqbBzO1uYKwgmSZSZRSTAodmvlkwcB0MMPabwdllyK7OKm3ZWHfnQ7XN9jjhGNKf9fby7Nvw0LDUY5SW62S+gtmNN3d9WAfanDVx2WfNCS7NeID3C0SCj3Adeo+w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1791196937375200.94018449434134; Mon, 5 Oct 2026 03:42:17 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 43E9241929; Mon, 5 Oct 2026 06:42:16 -0400 (EDT) Received: from [172.19.199.16] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 58EF441C2B; Mon, 5 Oct 2026 06:36:15 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 26D2A3F290; Thu, 1 Oct 2026 22:36:44 -0400 (EDT) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 179EF3F8A8 for ; Thu, 1 Oct 2026 22:36:43 -0400 (EDT) Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6922ZQjr1680341 for ; Fri, 2 Oct 2026 02:36:42 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 4gx5qrq2as-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Fri, 02 Oct 2026 02:36:41 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6922Z4FZ1855105 for ; Fri, 2 Oct 2026 02:36:40 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4h0xcsh2mp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Oct 2026 02:36:40 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6922adTw23331502 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Oct 2026 02:36:39 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B13558054; Fri, 2 Oct 2026 02:36:39 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E59B75805D; Fri, 2 Oct 2026 02:36:38 +0000 (GMT) Received: from localhost.localdomain (unknown [9.61.240.230]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Oct 2026 02:36:38 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=ujiPtM qMJ1O0bjySyailtgOlTQFKoHag+I0khbyF2rk=; b=aMoLf0U8+9puu20V6YRDiX oW2k1IMTrSeJdSq/23yB0E6Qa7ECt1qSkv4hZv5tPVRYf3FDnSbPkd+PoUdjCOac frxEeUmQ90hUIT0XmJ1EzdhjCfP2csdj11q1xErEFn+euq1roJNhjuzwDeFklLTW rioTtEpF9gL7TyxHOJSPVxnsBLxG6eIWTqWfR71+/AVVzOS1bR9DBjyi9Gc4wgB5 EQlrhUH00N1eh8si/6nJTUEm8/zNgBGxkeyRssaCy9Ikcyp6HJPnPz9SmGM5Vi0N IklrzbAnkHGjNy7vtdVNjX7+MJyp+X2fcXRsGmJ+VFk1j4oE63dFsV6MNLx8Wx6A == From: Rorie Reyes To: devel@lists.libvirt.org Subject: [PATCH libvirt v1 2/4] qemu: propagate responsibleProps parameter through monitor layer Date: Thu, 1 Oct 2026 22:36:24 -0400 Message-ID: <20261002023636.83991-3-rreyes@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20261002023636.83991-1-rreyes@linux.ibm.com> References: <20261002023636.83991-1-rreyes@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDAyMDAxMCBTYWx0ZWRfX1OEWPoLa/zcw s1Pu463xi1bVsYUrnr9Qt5plCyD0BnBtHqiXxKo1o0DmwL6tVaJcQvuZUcllFrMAHijJ82/Ehc7 yAN1eb4vftXjObQVMFAcS01kBHWmw21o30wyzsP/CFNsCVxJ0vxA97eCuuqWlYYDrEmbd4JXrpf GU9c4gS8Eiek/WiETGf9WxEP4A/UJ9qo3JmfngAtY7KyyU1qpBxgj2b+1ztbAP2av/WMPMTDBn4 BTRjiULIpNWbY2Jrn/EsKio9LIUrm8ugQMt1/HJIuDjwbdR53sGNbwNOTHpsDj0LtYnqgC3MAaz OWRTJpS16sFF0j29W8/2dI56zAqBzcEIpyLXzVLc/o37ObMjZnTGZyuSHn2k5jJn+DawQQwZnPe iEEssuQ+5Z09svufG0W+XVYKTaHBcjuNHbVPPiavTk50yZqY99qg7tfp6VkgMbdEDPO8KAGVMfl esWJPlG39Ad9raXj2XA== X-Authority-Analysis: v=2.4 cv=SPbXx+vH c=1 sm=1 tr=0 ts=6abf18b9 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=33hl-dTZ7BsMvSj0QHsA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: caZ1rJG-2DP5AixkomncTAlYZhCCN4fQ X-Proofpoint-Spam-Info: AW1haW4tMjYxMDAyMDAxMCBTYWx0ZWRfXwVmnd8Ua7dNw GTOAQY9fnaep/6GItPc4NCQYnJ+qGiacvHt7/Mz5rWJYX9xwVDOo3XV1SZtNglXULedtyGhGVf1 4jntcdKxZ+fbz50PNhTfzJkuE5OFKYw= X-Proofpoint-GUID: caZ1rJG-2DP5AixkomncTAlYZhCCN4fQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-10-02_01,2026-10-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 clxscore=1011 spamscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2610020010 X-MailFrom: rreyes@linux.ibm.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation Message-ID-Hash: QVCVXBS57Q4HVTRY4JLBFIAXYZZ7MTRX X-Message-ID-Hash: QVCVXBS57Q4HVTRY4JLBFIAXYZZ7MTRX X-Mailman-Approved-At: Mon, 05 Oct 2026 10:34:57 +0000 CC: fiuczy@linux.ibm.com, walling@linux.ibm.com, rreyes@linux.ibm.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1791196939008158500 Add the optional `responsibleProps` (char ***) parameter to qemuMonitorGetCPUModelComparison() in the public monitor API and wire it through to the JSON implementation. The parameter is optional =E2=80=94 callers that pass NULL preserve existing behaviour. The existing caller in qemu_driver.c is updated to pass NULL so the build continues to work until the caller is refactored in the next patch. Signed-off-by: Rorie Reyes --- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_monitor.c | 8 +++++--- src/qemu/qemu_monitor.h | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ebf19d7c0f..7332ec0256 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12137,7 +12137,7 @@ qemuConnectCPUModelComparison(virQEMUCaps *qemuCaps, if (qemuProcessQMPStart(proc) < 0) return VIR_CPU_COMPARE_ERROR; =20 - if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a, cpu_b, &result)= < 0) + if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a, cpu_b, &result,= NULL) < 0) return VIR_CPU_COMPARE_ERROR; =20 if (STREQ(result, "identical")) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index e3edc88814..88127ca27d 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3329,13 +3329,15 @@ int qemuMonitorGetCPUModelComparison(qemuMonitor *mon, virCPUDef *cpu_a, virCPUDef *cpu_b, - char **result) + char **result, + char ***responsibleProps) { - VIR_DEBUG("cpu_a=3D%p cpu_b=3D%p", cpu_a, cpu_b); + VIR_DEBUG("cpu_a=3D%p cpu_b=3D%p responsibleProps=3D%p", cpu_a, cpu_b,= responsibleProps); =20 QEMU_CHECK_MONITOR(mon); =20 - return qemuMonitorJSONGetCPUModelComparison(mon, cpu_a, cpu_b, result,= NULL); + return qemuMonitorJSONGetCPUModelComparison(mon, cpu_a, cpu_b, result, + responsibleProps); } =20 =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index e9b6a25f0c..ddea8796c4 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1485,7 +1485,8 @@ int qemuMonitorGetCPUModelComparison(qemuMonitor *mon, virCPUDef *cpu_a, virCPUDef *cpu_b, - char **result); + char **result, + char ***responsibleProps); =20 qemuMonitorCPUModelInfo * qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig); --=20 2.48.1 From nobody Sat Oct 24 20:20:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1791197013; cv=none; d=zohomail.com; s=zohoarc; b=HFpvSziyhQrsFFwGPqxuCaRUevmIw3xR2QhOM3voeg5ZxJyoOoKhUL39ucNWM6AADD7islkroP7Cr5YqfutPpDiNT7JTT9VaMv5OnpwK30yqwenZiIPAnVoqqAOXax67inI1T1DaDCVbDN7Pv8ukU+p9QYG+iibCx7TB/2doTSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791197013; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=alcNTlHbWYZQy+LEvSv9CzD0NwlYydTP9ihOUKrSOsU=; b=Ff0OFt1+cXATeydwLJ/NxoXktWcIGS/XTx9jRLtYberq/+960dhhNXEU3PM1mYhlktJ4YeCcz7xexvZb3IsvdmD/ws7W45MoOKcl8BL9qvgKJPG9KE98/KU+xWtNsJoBaH2OqMOUhnORyNBBMOHRECyLkSFq3nZ8cDK5TUp3/TM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1791197013364576.3650370209031; Mon, 5 Oct 2026 03:43:33 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id A273A41933; Mon, 5 Oct 2026 06:43:31 -0400 (EDT) Received: from [172.19.199.16] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 8B58341812; Mon, 5 Oct 2026 06:36:20 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 8C99E3F290; Thu, 1 Oct 2026 22:36:44 -0400 (EDT) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 790C43F885 for ; Thu, 1 Oct 2026 22:36:43 -0400 (EDT) Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6922Zuf82275175 for ; Fri, 2 Oct 2026 02:36:42 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 4gx4fensdx-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Fri, 02 Oct 2026 02:36:42 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6922K9HC1834184 for ; Fri, 2 Oct 2026 02:36:41 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4h1y2dh0pa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Oct 2026 02:36:41 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6922ae9s33620590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Oct 2026 02:36:40 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 546E95805A; Fri, 2 Oct 2026 02:36:40 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B5FB35805C; Fri, 2 Oct 2026 02:36:39 +0000 (GMT) Received: from localhost.localdomain (unknown [9.61.240.230]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Oct 2026 02:36:39 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=alcNTl HbWYZQy+LEvSv9CzD0NwlYydTP9ihOUKrSOsU=; b=ONtonwh1dCcT646gOcqj3S uP8KYQGIk2dU2SbwEI8NpXfQvNScWm3w8z2C1Nn9n648hBKNBx6EiEO3Az8+/QoD EB+DjLDeqan6NmTCrRC7KDqPMKy5bPf0T5vhWEhMDZ1yV7RJimnhXcwckARyfv+X 8HWEccGW2WKdbGKLeLditUugAUPsAUueWqqILtl062kaOeblPnnJi8xkebBNFGU7 XxLI62EiARhG/JUp43xz1l8sJJUiKBcNYiKslAnUlgJauyUHmmcHFghLpCu0r9BV k5Fkw+2LyyYRnLErZR5xzeNaiS8lRquDQhA7xwtbWBRFUjWUOHxQSX7+/63ami2Q == From: Rorie Reyes To: devel@lists.libvirt.org Subject: [PATCH libvirt v1 3/4] qemu: introduce qemuProcessCPUModelComparison helper Date: Thu, 1 Oct 2026 22:36:25 -0400 Message-ID: <20261002023636.83991-4-rreyes@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20261002023636.83991-1-rreyes@linux.ibm.com> References: <20261002023636.83991-1-rreyes@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=FYWiV5+6 c=1 sm=1 tr=0 ts=6abf18ba cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=otE64QW44qiKqFBSsOcA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDAyMDAxMCBTYWx0ZWRfX9lPlm6NpcOKN fMQhz56t9tL4G1DgvMra9/hd2/0QICgRB04i3E4SGsC3fE+fcUkLCb0bZOjn8WAYEi6zO/4NtPK MNTzuxbHX7huWv9N7Acf6OuuQy3/cJU= X-Proofpoint-ORIG-GUID: 9a3v1mIPSxQqaHYx9jtGzS-cpSEl7aBS X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDAyMDAxMCBTYWx0ZWRfX7bdChryWnoBV cV4mfBI1s9m8RU+gbkuoQMyvNA1Dley7UrZ9OTYyzRFSnr5O68RZzcO6/tCnFS/S+itbH40NDGS 39Waukc27WUCMHLH0KAZzgm7G8YmwZtzz6dXBoNJxQRapQnmrkBJlqKnP4s3iSLJSn9QD8UBrTf LVAPrfh+XhydE69mLKV6Xhxw+RdSZhoqbzmGL4zy0YiGe7li7VRTIU7PkZ9cwQFPlLcwM+ysLTN c6LvOkFc6aS1iJmNJ04muviKf69qo7e4xzsBsGS/YXXmFHiCz4sDyMbQQRNNCaoHD+izadAA7hd 3Iao9xeUpp+7BKVQwanI5JKSRUDBJS+qMSNRbDW7jlnL+QK2N2afGx3HoT8fsqxuLAbxqvZTgdT tAoAkfC478UNGIItXOpPGDTmPMvgqzPW3YaInsrMuyst+dQTweLqo+DZTqAQCnG2GxpbVTrA7m1 pychGbo5o8dY6fH09Fw== X-Proofpoint-GUID: 9a3v1mIPSxQqaHYx9jtGzS-cpSEl7aBS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-10-02_01,2026-10-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 impostorscore=0 spamscore=0 phishscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2610020010 X-MailFrom: rreyes@linux.ibm.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation Message-ID-Hash: WSVPB7BHOB4LAZNCJAL4BW2QSSYJCZ6G X-Message-ID-Hash: WSVPB7BHOB4LAZNCJAL4BW2QSSYJCZ6G X-Mailman-Approved-At: Mon, 05 Oct 2026 10:34:58 +0000 CC: fiuczy@linux.ibm.com, walling@linux.ibm.com, rreyes@linux.ibm.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1791197015424158500 Add a new internal qemuCPUModelCompatResult enum to qemu_process.h with values for IDENTICAL, SUBSET, SUPERSET, INCOMPATIBLE, and ERROR, and a new shared helper qemuProcessCPUModelComparison() in qemu_process.c that wraps the QMP probe and maps the result string to the enum. Refactor qemuConnectCPUModelComparison() in qemu_driver.c to delegate to the new helper, eliminating the duplicated QMP probe boilerplate. qemuConnectCPUModelComparison() maps the internal enum back to virCPUCompareResult, treating SUBSET as VIR_CPU_COMPARE_INCOMPATIBLE to preserve existing public API behaviour. Signed-off-by: Rorie Reyes --- src/qemu/qemu_driver.c | 20 +++++++---------- src/qemu/qemu_process.c | 50 +++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_process.h | 21 +++++++++++++++++ 3 files changed, 79 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7332ec0256..56a254f0ec 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12127,25 +12127,21 @@ qemuConnectCPUModelComparison(virQEMUCaps *qemuCa= ps, virCPUDef *cpu_b, bool failIncompatible) { - g_autoptr(qemuProcessQMP) proc =3D NULL; - g_autofree char *result =3D NULL; - - if (!(proc =3D qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps), - libDir, runUid, runGid, false))) - return VIR_CPU_COMPARE_ERROR; - - if (qemuProcessQMPStart(proc) < 0) - return VIR_CPU_COMPARE_ERROR; + qemuCPUModelCompatResult cmp =3D + qemuProcessCPUModelComparison(qemuCaps, libDir, runUid, runGid, + cpu_a, cpu_b, NULL); =20 - if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a, cpu_b, &result,= NULL) < 0) + if (cmp =3D=3D QEMU_CPU_COMPAT_ERROR) return VIR_CPU_COMPARE_ERROR; =20 - if (STREQ(result, "identical")) + if (cmp =3D=3D QEMU_CPU_COMPAT_IDENTICAL) return VIR_CPU_COMPARE_IDENTICAL; =20 - if (STREQ(result, "superset")) + if (cmp =3D=3D QEMU_CPU_COMPAT_SUPERSET) return VIR_CPU_COMPARE_SUPERSET; =20 + /* cpu_a is the host. SUBSET means the host lacks features the guest + * needs =E2=80=94 treat as incompatible, same as INCOMPATIBLE. */ if (failIncompatible) { virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL); return VIR_CPU_COMPARE_ERROR; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 57a3ed3720..90b8acc6c2 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -113,6 +113,14 @@ =20 VIR_LOG_INIT("qemu.qemu_process"); =20 +VIR_ENUM_IMPL(qemuCPUModelCompatResult, + QEMU_CPU_COMPAT_LAST, + "incompatible", + "identical", + "superset", + "subset", +); + /** * qemuProcessRemoveDomainStatus * @@ -10583,6 +10591,48 @@ qemuProcessQMPStart(qemuProcessQMP *proc) } =20 =20 +qemuCPUModelCompatResult +qemuProcessCPUModelComparison(virQEMUCaps *qemuCaps, + const char *libDir, + uid_t runUid, + gid_t runGid, + virCPUDef *cpu_a, + virCPUDef *cpu_b, + char ***responsibleProps) +{ + g_autoptr(qemuProcessQMP) proc =3D NULL; + g_autofree char *result =3D NULL; + qemuCPUModelCompatResult compatResult; + + if (!(proc =3D qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps), + libDir, runUid, runGid, false))) + return QEMU_CPU_COMPAT_ERROR; + + if (qemuProcessQMPStart(proc) < 0) + return QEMU_CPU_COMPAT_ERROR; + + if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a, cpu_b, &result, + responsibleProps) < 0) + return QEMU_CPU_COMPAT_ERROR; + + compatResult =3D qemuCPUModelCompatResultTypeFromString(result); + + switch (compatResult) { + case QEMU_CPU_COMPAT_INCOMPATIBLE: + case QEMU_CPU_COMPAT_IDENTICAL: + case QEMU_CPU_COMPAT_SUPERSET: + case QEMU_CPU_COMPAT_SUBSET: + return compatResult; + case QEMU_CPU_COMPAT_ERROR: + case QEMU_CPU_COMPAT_LAST: + default: + VIR_WARN("unknown query-cpu-model-comparison result '%s', treating= as incompatible", + result); + return QEMU_CPU_COMPAT_INCOMPATIBLE; + } +} + + void qemuProcessHandleNbdkitExit(qemuNbdkitProcess *nbdkit, virDomainObj *vm) diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 5d8f1f89d5..059966e0a7 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -258,6 +258,27 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuProcessQMP, qemuProc= essQMPFree); =20 int qemuProcessQMPStart(qemuProcessQMP *proc); =20 +typedef enum { + QEMU_CPU_COMPAT_ERROR =3D -1, + QEMU_CPU_COMPAT_INCOMPATIBLE =3D 0, + QEMU_CPU_COMPAT_IDENTICAL =3D 1, + QEMU_CPU_COMPAT_SUPERSET =3D 2, + QEMU_CPU_COMPAT_SUBSET =3D 3, + + QEMU_CPU_COMPAT_LAST, +} qemuCPUModelCompatResult; + +VIR_ENUM_DECL(qemuCPUModelCompatResult); + +qemuCPUModelCompatResult +qemuProcessCPUModelComparison(virQEMUCaps *qemuCaps, + const char *libDir, + uid_t runUid, + gid_t runGid, + virCPUDef *cpu_a, + virCPUDef *cpu_b, + char ***responsibleProps); + void qemuProcessCleanupMigrationJob(virQEMUDriver *driver, virDomainObj *vm); =20 --=20 2.48.1 From nobody Sat Oct 24 20:20:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1791197100; cv=none; d=zohomail.com; s=zohoarc; b=cv2sJmhRN1K8Bi1IlL8Px7bW7pslCJ6C+7Ukc0s4Bsyg8Ip1qCvNUvdAAF/XQtvq0ZS6c2By2S/eWFoakGgK6ZhVr+NgJKvyF2p2/+NQ0qCqArJLzyUgWl0kQ+UNZtrw1uKqQQqLx22VLVSMPUlLAgLK9pXdrScXxbuYA2m2rjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791197100; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=bnM998hRqwfOEbDPB49dcOxGsjUQeDl/9ofZsQzh3r4=; b=SPcVhng2q1hgwfqw2zfJ/dtAAhvhp7oqfUM/VY2O2hYeiffWF8PWW5IjpdpOR+9Ln9ApftiZPne1T0wBCWbZCR4YGZdRba3BLb2fIlSSG1SJyeSDrePYG20dC99xGd1bD/tGoZUfDWokm0vfvggy+e+wJi1LFuWKQeqVgUtQfdg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1791197100367218.78746154813803; Mon, 5 Oct 2026 03:45:00 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 28EEA419ED; Mon, 5 Oct 2026 06:44:59 -0400 (EDT) Received: from [172.19.199.16] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id E6A1D41CFB; Mon, 5 Oct 2026 06:36:25 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 32DC53F390; Thu, 1 Oct 2026 22:36:46 -0400 (EDT) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1DAA43F320 for ; Thu, 1 Oct 2026 22:36:45 -0400 (EDT) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6922ZPEo3509467 for ; Fri, 2 Oct 2026 02:36:44 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 4gx5s5q121-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Fri, 02 Oct 2026 02:36:43 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6922KAlt1897664 for ; Fri, 2 Oct 2026 02:36:42 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4h1aa7x2dd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Oct 2026 02:36:42 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6922af1c21562086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Oct 2026 02:36:41 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3085F5805A; Fri, 2 Oct 2026 02:36:41 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7C2655805D; Fri, 2 Oct 2026 02:36:40 +0000 (GMT) Received: from localhost.localdomain (unknown [9.61.240.230]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Fri, 2 Oct 2026 02:36:40 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 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=bnM998hRqwfOEbDPB 49dcOxGsjUQeDl/9ofZsQzh3r4=; b=G2laA8mBgGUMWpo/RUC6jR5nLNx1GU5pe 83QdnKHfEutJPYi8rmZFX9iUhHi4EFvkVe5a/r4IxGh1KfcQ6QdNqfCpAvia/mPX JhWiyFrWH1QM7jt5ikEkTsJFlv6qgCPwPHv3aWec7W51ZT7Ac69J8nwvOPhMmHcc +31rbRGvXGPZ5lV5XOIfjKFau3YSA9RKV1NFC9gCz1ZCouB+yHitpuTqp9+jPquO kFVJ7k3IndXwdZHJbkxsLvHeodBD8xJ7nz6HR5kVAZFFrQFpr6E7GpAhtOQKeifZ sFKI/Z3k5NSKB9Hgw2s6P/wnYMSwJiJ2xNsNhZNwJPXrkGI52ouoQ== From: Rorie Reyes To: devel@lists.libvirt.org Subject: [PATCH libvirt v1 4/4] qemu: check CPU model compatibility on s390x before incoming migration Date: Thu, 1 Oct 2026 22:36:26 -0400 Message-ID: <20261002023636.83991-5-rreyes@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20261002023636.83991-1-rreyes@linux.ibm.com> References: <20261002023636.83991-1-rreyes@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDAyMDAxMCBTYWx0ZWRfXzzkH9K4dkQYQ ClFx+y6oR0PbYpxcTnaT3lTydNGhHrwDwP7w1r6qOAPruYTqU7V4/5frem23nSc0D3lyMUfc12n BLIqxsnD48yKABnX6JEMZehGMTH+67g= X-Authority-Analysis: v=2.4 cv=HJ5WhYtv c=1 sm=1 tr=0 ts=6abf18bb cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=NfQj0Cft4Z81OieCabEA:9 X-Proofpoint-GUID: 8SBHqz5MqHUUO6liLioPIImu_sjGL51f X-Proofpoint-ORIG-GUID: 8SBHqz5MqHUUO6liLioPIImu_sjGL51f X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDAyMDAxMCBTYWx0ZWRfX+/2l4zwcqs2i 5qKiiUhboKQ0TBqbUErrVZkUOnKHBF3JKzK1v7rgI792scsyfrGegsanNcBj9gIzxU9+DBzo+yr SIXbmRxR4kyRuYktOV6FJwKBICATwt0DGj81Ph0mOlhV0gteKQI+XacJpc+6AGBnVwrUYp9lPLg Uk2GWjK9SGvMQA5bjwuSYKH+B/JeDzzuwBWoBUv0WcMZgDGkaVRI90qUsYDm7M45Vvnv2hGGGFh 28Z6SRDCF5bCnyh7Q/FUu6HkTzMSbpKuFo4U6v0XvNvWnXRU7GO2iprVXMzW13XEyzJ1J0XBvjB tIWVZraIWvcx/5syFvefRLCx4roosozHvhSK+BgRWXUq0AF5K0QylBtOYN7iSGV6xFx3avta7pm 89frg93+R6ODRIQwmTl9siz5ZQBISr5ESi1ArbM4VdWTzWBohl+7JsptaIofGuqINnsVJvvF0s9 7aPfFhDaBU0Ir8HbwdA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-10-02_01,2026-10-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 impostorscore=0 phishscore=0 priorityscore=1501 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2610020010 X-MailFrom: rreyes@linux.ibm.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation Message-ID-Hash: ELJMCL3YRF6IKQSJ3IRMCNOPMDAN7G3L X-Message-ID-Hash: ELJMCL3YRF6IKQSJ3IRMCNOPMDAN7G3L X-Mailman-Approved-At: Mon, 05 Oct 2026 10:34:58 +0000 CC: fiuczy@linux.ibm.com, walling@linux.ibm.com, rreyes@linux.ibm.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1791197101965158500 Content-Type: text/plain; charset="utf-8" When migrating an s390x guest to a target s390x host, it is possible the migration will fail ungracefully due to incompatible CPU models. Add a pre-migration check for the s390x architecture: when the guest uses a custom or host-model CPU, look up the QEMU capabilities from the driver cache and, if the QEMU_CAPS_QUERY_CPU_MODEL_COMPARISON capability is present, invoke a CPU model comparison between the guest and target hypervisor CPU models. The check runs before qemuProcessInit() so that the guest CPU from the migration cookie is compared before it can be resolved to the destination host model. The comparison result is distinguished by four cases: - IDENTICAL or SUBSET: guest CPU model is presumed to be compatible with target host's model. - SUPERSET: guest CPU model is newer than target host's model, or target host does not support features guest requires. - INCOMPATIBLE: guest CPU model cannot run on target host. Report the list of features the target is missing (if any). - Probe error: propagated as VIR_ERR_CPU_INCOMPATIBLE from the monitor layer. Signed-off-by: Rorie Reyes --- src/qemu/qemu_migration.c | 114 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 4a43ab83b0..b77bdd4370 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3308,6 +3308,90 @@ qemuMigrationDstPrepareAnyBlockDirtyBitmaps(virDomai= nObj *vm, } =20 =20 +/** + * qemuMigrationDstCheckCPUModelCompat: + * + * Run a short-lived QMP probe to compare @guestCPU against @hvCPU on the + * destination host. Returns 0 if the guest CPU is compatible (identical + * or a subset of what the host provides), -1 if incompatible. + * + * On incompatibility an error is reported via virReportError before retur= ning + * -1. Probe errors (e.g. the destination QEMU does not recognise a CPU + * property) are reported as VIR_ERR_CPU_INCOMPATIBLE by the monitor layer= and + * are propagated as-is. + */ +static int +qemuMigrationDstCheckCPUModelCompat(virQEMUCaps *qemuCaps, + const char *libDir, + uid_t runUid, + gid_t runGid, + virCPUDef *hvCPU, + virCPUDef *guestCPU) +{ + g_autofree char **responsibleProps =3D NULL; + qemuCPUModelCompatResult cmp =3D qemuProcessCPUModelComparison(qemuCap= s, libDir, + runUid, r= unGid, + guestCPU,= hvCPU, + &responsi= bleProps); + + switch (cmp) { + case QEMU_CPU_COMPAT_IDENTICAL: + case QEMU_CPU_COMPAT_SUBSET: + /* Guest CPU model is presumed to be compatible with target host's= model. */ + return 0; + + case QEMU_CPU_COMPAT_SUPERSET: + /* Either guest CPU model is newer than target host's model, or ta= rget + * host does not support features required by guest. */ + virReportError(VIR_ERR_CPU_INCOMPATIBLE, "%s", + _("guest CPU model is a newer generation than the d= estination host CPU model")); + return -1; + + case QEMU_CPU_COMPAT_INCOMPATIBLE: + /* Guest CPU model cannot run on target host. Report the list of + * features the target is missing (if any). + * + * s390x will report the property 'type' when CPU models are + * incompatible. Remove it from the responsibleProps list so it + * is not reported as a missing feature. */ + if (responsibleProps) { + size_t i =3D 0; + size_t j =3D 0; + + while (responsibleProps[i]) { + if (STREQ(responsibleProps[i], "type")) { + g_free(responsibleProps[i++]); + } else { + responsibleProps[j++] =3D responsibleProps[i++]; + } + } + responsibleProps[j] =3D NULL; + + if (responsibleProps[0]) { + g_autofree char *missing_str =3D g_strjoinv(", ", responsi= bleProps); + virReportError(VIR_ERR_CPU_INCOMPATIBLE, + _("destination host CPU model is missing fe= atures required by the guest CPU model: %1$s"), + missing_str); + return -1; + } + } + + virReportError(VIR_ERR_CPU_INCOMPATIBLE, + _("guest CPU model '%1$s' is not compatible with ho= st CPU model '%2$s'"), + guestCPU->model ? guestCPU->model : _("unknown"), + hvCPU->model ? hvCPU->model : _("unknown")); + return -1; + + case QEMU_CPU_COMPAT_ERROR: + case QEMU_CPU_COMPAT_LAST: + default: + break; + } + + return -1; +} + + static int qemuMigrationDstPrepareActive(virQEMUDriver *driver, virDomainObj *vm, @@ -3354,6 +3438,36 @@ qemuMigrationDstPrepareActive(virQEMUDriver *driver, =20 startFlags =3D VIR_QEMU_PROCESS_START_AUTODESTROY; =20 + /* Check CPU model compatibility before starting the guest. + * Snapshot the guest CPU from the migration cookie before qemuProcess= Init + * can resolve and replace it with the destination host CPU model. + * This allows libvirt to provide a clear error message and perform + * proper cleanup if the destination host doesn't support the required + * CPU features. + */ + if (ARCH_IS_S390(vm->def->os.arch) && + mig->cpu && + (mig->cpu->mode =3D=3D VIR_CPU_MODE_CUSTOM || + mig->cpu->mode =3D=3D VIR_CPU_MODE_HOST_MODEL) && + mig->cpu->model) { + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driv= er); + g_autoptr(virQEMUCaps) qemuCaps =3D virQEMUCapsCacheLookup(driver-= >qemuCapsCache, + vm->def->= emulator); + + if (qemuCaps && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_COMPARISON)= ) { + virCPUDef *hvCPU =3D virQEMUCapsGetHostModel(qemuCaps, + vm->def->virtType, + VIR_QEMU_CAPS_HOST_= CPU_REPORTED); + + if (hvCPU && + qemuMigrationDstCheckCPUModelCompat(qemuCaps, + cfg->libDir, cfg->user= , cfg->group, + hvCPU, mig->cpu) < 0) + goto error; + } + } + if (qemuProcessInit(driver, vm, mig->cpu, VIR_ASYNC_JOB_MIGRATION_IN, true, startFlags) < 0) goto error; --=20 2.48.1