From nobody Thu May 15 12:46:51 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1507920409795132.95917025685412; Fri, 13 Oct 2017 11:46:49 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9C1B3820F0; Fri, 13 Oct 2017 18:46:48 +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 7930A612A2; Fri, 13 Oct 2017 18:46:48 +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 19689410B4; Fri, 13 Oct 2017 18:46:48 +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 v9DIF0mO014027 for ; Fri, 13 Oct 2017 14:15:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 84A155C543; Fri, 13 Oct 2017 18:15:00 +0000 (UTC) Received: from mamuti.net (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DBBF05C88B for ; Fri, 13 Oct 2017 18:14:57 +0000 (UTC) Received: by mamuti.net (Postfix, from userid 500) id 124F41006D0; Fri, 13 Oct 2017 20:14:56 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9C1B3820F0 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Fri, 13 Oct 2017 20:14:35 +0200 Message-Id: <2cc47e64c4e10f4efd4454de1215429edf41fff7.1507918307.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 03/22] qemu: Store CPU usability blockers in caps cache 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 13 Oct 2017 18:46:49 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: John Ferlan --- Notes: Version 2: - modified error message src/qemu/qemu_capabilities.c | 51 ++++++++++++++++++++++++++++++++++++++++= ++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7f4d019e9b..507c7651a1 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3729,6 +3729,10 @@ virQEMUCapsLoadCPUModels(virQEMUCapsPtr qemuCaps, size_t i; int n; int ret =3D -1; + xmlNodePtr node; + xmlNodePtr *blockerNodes =3D NULL; + char **blockers =3D NULL; + int nblockers; =20 if (type =3D=3D VIR_DOMAIN_VIRT_KVM) n =3D virXPathNodeSet("./cpu[@type=3D'kvm']", ctxt, &nodes); @@ -3771,7 +3775,34 @@ virQEMUCapsLoadCPUModels(virQEMUCapsPtr qemuCaps, goto cleanup; } =20 - if (virDomainCapsCPUModelsAddSteal(cpus, &str, usable, NULL) < 0) + node =3D ctxt->node; + ctxt->node =3D nodes[i]; + nblockers =3D virXPathNodeSet("./blocker", ctxt, &blockerNodes); + ctxt->node =3D node; + + if (nblockers < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to parse CPU blockers in QEMU capabil= ities")); + goto cleanup; + } + + if (nblockers > 0) { + size_t j; + + if (VIR_ALLOC_N(blockers, nblockers + 1) < 0) + goto cleanup; + + for (j =3D 0; j < nblockers; j++) { + if (!(blockers[j] =3D virXMLPropString(blockerNodes[j], "n= ame"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing blocker name in QEMU " + "capabilities cache")); + goto cleanup; + } + } + } + + if (virDomainCapsCPUModelsAddSteal(cpus, &str, usable, &blockers) = < 0) goto cleanup; } =20 @@ -3780,6 +3811,8 @@ virQEMUCapsLoadCPUModels(virQEMUCapsPtr qemuCaps, cleanup: VIR_FREE(nodes); VIR_FREE(str); + VIR_FREE(blockerNodes); + virStringListFree(blockers); return ret; } =20 @@ -4137,7 +4170,21 @@ virQEMUCapsFormatCPUModels(virQEMUCapsPtr qemuCaps, virBufferAsprintf(buf, " usable=3D'%s'", virDomainCapsCPUUsableTypeToString(cpu->usab= le)); } - virBufferAddLit(buf, "/>\n"); + + if (cpu->blockers) { + size_t j; + + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + + for (j =3D 0; cpu->blockers[j]; j++) + virBufferAsprintf(buf, "\n", cpu->bl= ockers[j]); + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } else { + virBufferAddLit(buf, "/>\n"); + } } } =20 --=20 2.14.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list