From nobody Sun Feb 8 11:26:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1568924908; cv=none; d=zoho.com; s=zohoarc; b=Nyk/9I0rsxzYcWdA2yWQzBrmCOogHDPedmqchdJ672AzgMLdEcVRCUxDnXu+1cR6f7OmTUwOGJu2AMuzjw6rDfISI9JkTSfu7ar5kQf0potATOB7lzA4vsNONWkBW26yr4Qwg+ecOdNHLx2JAda+6fzrY2qA+UqkZT2WL56GJL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568924908; 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:ARC-Authentication-Results; bh=QnJ2LWmYDaLioW1XD74n92NMlaHQmpg9nCrbz7ZCF60=; b=ak7sgckwyOkSPsSNj9HxVvTsx8pCflhsiyg7AzRoPb3IEGgi5/hFotR408d5kGX3Od9wjT5lMx+/WjgBMlTAm8ootWkPBjkxHwaZhKEL9onCTrRqoOoic+kUen5kaanjCPwhu9SIxa5yVrRKTb1wZ5v+k67SpqOp16O1GxGLnRg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568924908121352.88882110162285; Thu, 19 Sep 2019 13:28:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7BD307FDFC; Thu, 19 Sep 2019 20:28:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53AA11001B23; Thu, 19 Sep 2019 20:28:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0F448180B780; Thu, 19 Sep 2019 20:28:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8JKPVPZ018348 for ; Thu, 19 Sep 2019 16:25:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id E8A555C207; Thu, 19 Sep 2019 20:25:31 +0000 (UTC) Received: from mx1.redhat.com (ext-mx25.extmail.prod.ext.phx2.redhat.com [10.5.110.66]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7766A5C1B5; Thu, 19 Sep 2019 20:25:27 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5A1C510F2E86; Thu, 19 Sep 2019 20:25:26 +0000 (UTC) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x8JKIJth051973; Thu, 19 Sep 2019 16:25:26 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2v3vdfvnv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Sep 2019 16:25:25 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x8JKIUAP052355; Thu, 19 Sep 2019 16:25:24 -0400 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 2v3vdfvnub-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Sep 2019 16:25:24 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x8JKPIBu001190; Thu, 19 Sep 2019 20:25:22 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma04dal.us.ibm.com with ESMTP id 2v3vbujc3r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Sep 2019 20:25:22 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x8JKPLA342139954 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Sep 2019 20:25:21 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4F33F28060; Thu, 19 Sep 2019 20:25:21 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 401C728064; Thu, 19 Sep 2019 20:25:21 +0000 (GMT) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.76]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 19 Sep 2019 20:25:21 +0000 (GMT) From: Collin Walling To: libvir-list@redhat.com Date: Thu, 19 Sep 2019 16:24:56 -0400 Message-Id: <1568924706-2311-6-git-send-email-walling@linux.ibm.com> In-Reply-To: <1568924706-2311-1-git-send-email-walling@linux.ibm.com> References: <1568924706-2311-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-09-19_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=995 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909190172 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Thu, 19 Sep 2019 20:25:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Thu, 19 Sep 2019 20:25:26 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'walling@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.66 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: fiuczy@linux.ibm.com, bwalk@linux.ibm.com, jdenemar@redhat.com, danielhb413@gmail.com, david@redhat.com Subject: [libvirt] [PATCH v5 05/15] qemu_monitor: allow cpu props to be optional X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 19 Sep 2019 20:28:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Some older s390 CPU models (e.g. z900) will not report props as a response from query-cpu-model-expansion. As such, we should make the props field optional when parsing the return data from the QMP response. Signed-off-by: Collin Walling Reviewed-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 10 ++++++++-- src/qemu/qemu_monitor.c | 4 +++- src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 24 ++++++++++++++++-------- src/qemu/qemu_monitor_json.h | 3 ++- tests/cputest.c | 6 +++++- 6 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index bc0ac3d..3020530 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2500,6 +2500,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, virCPUDefPtr cpu; qemuMonitorCPUModelExpansionType type; virDomainVirtType virtType; + bool fail_no_props =3D true; int ret =3D -1; =20 if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION)) @@ -2529,12 +2530,17 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, else type =3D QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC; =20 - if (qemuMonitorGetCPUModelExpansion(mon, type, cpu, true, &modelInfo) = < 0) + /* Older s390 models do not report a feature set */ + if (ARCH_IS_S390(qemuCaps->arch)) + fail_no_props =3D false; + + if (qemuMonitorGetCPUModelExpansion(mon, type, cpu, true, fail_no_prop= s, + &modelInfo) < 0) goto cleanup; =20 /* Try to check migratability of each feature. */ if (modelInfo && - qemuMonitorGetCPUModelExpansion(mon, type, cpu, false, + qemuMonitorGetCPUModelExpansion(mon, type, cpu, false, fail_no_pro= ps, &nonMigratable) < 0) goto cleanup; =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 7b454c2..6bda620 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3718,6 +3718,7 @@ qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon, qemuMonitorCPUModelExpansionType type, virCPUDefPtr cpu, bool migratable, + bool fail_no_props, qemuMonitorCPUModelInfoPtr *model_info) { VIR_DEBUG("type=3D%d cpu=3D%p migratable=3D%d", type, cpu, migratable); @@ -3725,7 +3726,8 @@ qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon, QEMU_CHECK_MONITOR(mon); =20 return qemuMonitorJSONGetCPUModelExpansion(mon, type, cpu, - migratable, model_info); + migratable, fail_no_props, + model_info); } =20 =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 672b4f9..c9cb3bd 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1159,6 +1159,7 @@ int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mo= n, qemuMonitorCPUModelExpansionType type, virCPUDefPtr cpu, bool migratable, + bool fail_no_props, qemuMonitorCPUModelInfoPtr *model_info= ); =20 void qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 77113c0..ddcf425 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5833,6 +5833,7 @@ qemuMonitorJSONMakeCPUModel(virCPUDefPtr cpu, =20 static int qemuMonitorJSONParseCPUModelData(virJSONValuePtr data, + bool fail_no_props, virJSONValuePtr *cpu_model, virJSONValuePtr *cpu_props, const char **cpu_name) @@ -5849,7 +5850,8 @@ qemuMonitorJSONParseCPUModelData(virJSONValuePtr data, return -1; } =20 - if (!(*cpu_props =3D virJSONValueObjectGetObject(*cpu_model, "props"))= ) { + if (!(*cpu_props =3D virJSONValueObjectGetObject(*cpu_model, "props"))= && + fail_no_props) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("query-cpu-model-expansion reply data was missing= 'props'")); return -1; @@ -5873,13 +5875,17 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name, if (VIR_STRDUP(machine_model->name, cpu_name) < 0) goto cleanup; =20 - if (VIR_ALLOC_N(machine_model->props, virJSONValueObjectKeysNumber(cpu= _props)) < 0) - goto cleanup; + if (cpu_props) { + size_t nprops =3D virJSONValueObjectKeysNumber(cpu_props); =20 - if (virJSONValueObjectForeachKeyValue(cpu_props, - qemuMonitorJSONParseCPUModelProp= erty, - machine_model) < 0) - goto cleanup; + if (VIR_ALLOC_N(machine_model->props, nprops) < 0) + goto cleanup; + + if (virJSONValueObjectForeachKeyValue(cpu_props, + qemuMonitorJSONParseCPUModel= Property, + machine_model) < 0) + goto cleanup; + } =20 VIR_STEAL_PTR(*model_info, machine_model); ret =3D 0; @@ -5895,6 +5901,7 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mo= n, qemuMonitorCPUModelExpansionType type, virCPUDefPtr cpu, bool migratable, + bool fail_no_props, qemuMonitorCPUModelInfoPtr *model_info) { VIR_AUTOPTR(virJSONValue) model =3D NULL; @@ -5945,7 +5952,8 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mo= n, data =3D virJSONValueObjectGetObject(reply, "return"); =20 if (qemuMonitorJSONParseCPUModelData(data, - &cpu_model, &cpu_props, &cpu_name= ) < 0) + fail_no_props, &cpu_model, &cpu_p= rops, + &cpu_name) < 0) return -1; =20 /* QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL requests "full" expans= ion diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index bdccd36..682710f 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -392,8 +392,9 @@ int qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr = mon, qemuMonitorCPUModelExpansionType t= ype, virCPUDefPtr cpu, bool migratable, + bool fail_no_props, qemuMonitorCPUModelInfoPtr *model_= info) - ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(5); + ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(6); =20 int qemuMonitorJSONGetCommands(qemuMonitorPtr mon, char ***commands) diff --git a/tests/cputest.c b/tests/cputest.c index 3c17ed4..e3937c6 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -482,6 +482,7 @@ cpuTestMakeQEMUCaps(const struct data *data) qemuMonitorTestPtr testMon =3D NULL; qemuMonitorCPUModelInfoPtr model =3D NULL; virCPUDefPtr cpu =3D NULL; + bool fail_no_props =3D true; char *json =3D NULL; =20 if (virAsprintf(&json, "%s/cputestdata/%s-cpuid-%s.json", @@ -494,9 +495,12 @@ cpuTestMakeQEMUCaps(const struct data *data) if (VIR_ALLOC(cpu) < 0 || VIR_STRDUP(cpu->model, "host") < 0) goto cleanup; =20 + if (ARCH_IS_S390(data->arch)) + fail_no_props =3D false; + if (qemuMonitorGetCPUModelExpansion(qemuMonitorTestGetMonitor(testMon), QEMU_MONITOR_CPU_MODEL_EXPANSION_S= TATIC, - cpu, true, &model) < 0) + cpu, true, fail_no_props, &model) = < 0) goto error; =20 if (!(qemuCaps =3D virQEMUCapsNew())) --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list