From nobody Sun Feb 8 11:26:05 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=1568924883; cv=none; d=zoho.com; s=zohoarc; b=SLaTv38VlDr2y9tw5b5wAaKnFE4LGK0bbdxTZwMT+EGTjsuI64h+rzKdKEfpsjFuM0RcbusL58M6656Oy1NtW2YQVNfgd6zPFSzFbjxBfs4V2oaizz6cgTnF6msNQzp9MfnaMDNZsp24gjHMBKdob/pMgYSbGVobrUAiHIQU1Vw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568924883; 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=mcMCsJGO/5YJ/vHOi+7SQGgptj2nxVX+yAmaLW7Eoas=; b=na6TCq40/tuYJ778lEmZF2DSVIh5MY35IM1mMfB4Qk2k65r/YkpIljnsh1xZ3xRPwVv6YKaC42WAitUCIg2CdOradU/iQCFQlMrcX5MwCslUBrv6JbYT5Z4IUopw0crM9ATLIu4BMQ/Fs5APRfOKRJGIc33DvwYe9IGFzdqJRCk= 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 156892488397068.99945503643005; Thu, 19 Sep 2019 13:28:03 -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 D5708308404E; Thu, 19 Sep 2019 20:28:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AC67D1001B00; Thu, 19 Sep 2019 20:28:01 +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 726EC4EE6E; Thu, 19 Sep 2019 20:28:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8JKPTfx018281 for ; Thu, 19 Sep 2019 16:25:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1AB6A6046B; Thu, 19 Sep 2019 20:25:29 +0000 (UTC) Received: from mx1.redhat.com (ext-mx27.extmail.prod.ext.phx2.redhat.com [10.5.110.68]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D16A56013A; Thu, 19 Sep 2019 20:25:25 +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 9863E875220; Thu, 19 Sep 2019 20:25:24 +0000 (UTC) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x8JKJ3fw039905; Thu, 19 Sep 2019 16:25:24 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2v4f6pk946-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Sep 2019 16:25:24 -0400 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x8JKNqtW084232; Thu, 19 Sep 2019 16:25:23 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 2v4f6pk93q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Sep 2019 16:25:23 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x8JKPJAg003525; Thu, 19 Sep 2019 20:25:22 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma02wdc.us.ibm.com with ESMTP id 2v3vbu09gh-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 b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x8JKPM7c44499272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Sep 2019 20:25:22 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1F89A2805E; Thu, 19 Sep 2019 20:25:22 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0FD2728059; Thu, 19 Sep 2019 20:25:22 +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:22 +0000 (GMT) From: Collin Walling To: libvir-list@redhat.com Date: Thu, 19 Sep 2019 16:25:06 -0400 Message-Id: <1568924706-2311-16-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=999 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.68]); Thu, 19 Sep 2019 20:25:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Thu, 19 Sep 2019 20:25:24 +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.68 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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 15/15] qemu_driver: improve comparison/baseline error reporting 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.40]); Thu, 19 Sep 2019 20:28:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Providing an erroneous CPU definition in the XML file provided to the hypervisor-cpu-compare/baseline command will result in a verbose internal error. Let's add some sanity checking before executing the QMP commands to provide a cleaner message if something is wrong with the CPU model or features. Signed-off-by: Collin Walling --- src/qemu/qemu_driver.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 62 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 153b2f2..6298c48 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13703,6 +13703,55 @@ qemuConnectCompareCPU(virConnectPtr conn, } =20 =20 +static int +qemuConnectCheckCPUModel(qemuMonitorPtr mon, + virCPUDefPtr cpu, + bool reportError) +{ + qemuMonitorCPUModelInfoPtr modelInfo =3D NULL; + qemuMonitorCPUModelExpansionType type; + size_t i, j; + int ret =3D -1; + + /* Collect CPU model name and features known by QEMU */ + type =3D QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL; + if (qemuMonitorGetCPUModelExpansion(mon, type, cpu, + true, false, &modelInfo) < 0) + goto cleanup; + + /* Sanity check CPU model */ + if (!modelInfo) { + if (reportError) + virReportError(VIR_ERR_CPU_INCOMPATIBLE, + _("Unknown CPU model: %s"), cpu->model); + goto cleanup; + } + + /* Sanity check CPU features */ + for (i =3D 0; i < cpu->nfeatures; i++) { + const char *feat =3D cpu->features[i].name; + + for (j =3D 0; j < modelInfo->nprops; j++) { + const char *prop =3D modelInfo->props[j].name; + if (STREQ(feat, prop)) + break; + } + + if (j =3D=3D modelInfo->nprops) { + if (reportError) + virReportError(VIR_ERR_CPU_INCOMPATIBLE, + _("Unknown CPU feature: %s"), feat); + goto cleanup; + } + } + ret =3D 0; + + cleanup: + qemuMonitorCPUModelInfoFree(modelInfo); + return ret; +} + + static virCPUCompareResult qemuConnectCPUModelComparison(virQEMUCapsPtr qemuCaps, const char *libDir, @@ -13723,6 +13772,13 @@ qemuConnectCPUModelComparison(virQEMUCapsPtr qemuC= aps, if (qemuProcessQMPStart(proc) < 0) goto cleanup; =20 + if (qemuConnectCheckCPUModel(proc->mon, cpu_a, failIncompatible) || + qemuConnectCheckCPUModel(proc->mon, cpu_b, failIncompatible)) { + if (!failIncompatible) + ret =3D VIR_CPU_COMPARE_INCOMPATIBLE; + goto cleanup; + } + if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a, cpu_b, &result)= < 0) goto cleanup; =20 @@ -13913,6 +13969,9 @@ qemuConnectCPUModelBaseline(virQEMUCapsPtr qemuCaps, if (qemuProcessQMPStart(proc) < 0) goto cleanup; =20 + if (qemuConnectCheckCPUModel(proc->mon, cpus[0], true)) + goto cleanup; + if (VIR_ALLOC(baseline) < 0) goto error; =20 @@ -13921,6 +13980,9 @@ qemuConnectCPUModelBaseline(virQEMUCapsPtr qemuCaps, =20 for (i =3D 1; i < ncpus; i++) { =20 + if (qemuConnectCheckCPUModel(proc->mon, cpus[i], true)) + goto error; + if (qemuMonitorGetCPUModelBaseline(proc->mon, baseline, cpus[i], &result) < 0) goto error; --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list