From nobody Tue Feb 10 01:05:47 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499867080662703.4907318895987; Wed, 12 Jul 2017 06:44:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 330484E33B; Wed, 12 Jul 2017 13:44:38 +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 0AC9770461; Wed, 12 Jul 2017 13:44:38 +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 BC01D1800C94; Wed, 12 Jul 2017 13:44:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6CDiBll032548 for ; Wed, 12 Jul 2017 09:44:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9ABF86DB73; Wed, 12 Jul 2017 13:44:11 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD4816DA86; Wed, 12 Jul 2017 13:44:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 330484E33B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 330484E33B From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 12 Jul 2017 15:44:03 +0200 Message-Id: <7bb71e9d3d269ad8d11ad4d289721e31ddf9623f.1499866398.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Peter Krempa , Nitesh Konkar Subject: [libvirt] [PATCH 2/5] qemu: domain: Extract parsing and formatting of priv->autoNodeset 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 12 Jul 2017 13:44:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the code to separate functions to avoid complicating the existing ones with changes. Reviewed-by: Andrea Bolognani --- src/qemu/qemu_domain.c | 84 +++++++++++++++++++++++++++++++++++-----------= ---- 1 file changed, 60 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6772f1ae2..92e5609ad 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1761,6 +1761,29 @@ qemuDomainObjPrivateXMLFormatVcpus(virBufferPtr buf, static int +qemuDomainObjPtrivateXMLFormatAutomaticPlacement(virBufferPtr buf, + qemuDomainObjPrivatePtr p= riv) +{ + char *nodeset =3D NULL; + int ret =3D -1; + + if (!priv->autoNodeset) + return 0; + + if (!(nodeset =3D virBitmapFormat(priv->autoNodeset))) + goto cleanup; + + virBufferAsprintf(buf, "\n", nodeset); + + ret =3D 0; + + cleanup: + VIR_FREE(nodeset); + return ret; +} + + +static int qemuDomainObjPrivateXMLFormat(virBufferPtr buf, virDomainObjPtr vm) { @@ -1869,15 +1892,8 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, virBufferAddLit(buf, "\n"); } - if (priv->autoNodeset) { - char *nodeset =3D virBitmapFormat(priv->autoNodeset); - - if (!nodeset) - return -1; - - virBufferAsprintf(buf, "\n", nodeset); - VIR_FREE(nodeset); - } + if (qemuDomainObjPtrivateXMLFormatAutomaticPlacement(buf, priv) < 0) + return -1; /* Various per-domain paths */ virBufferEscapeString(buf, "\n", priv->libDir); @@ -1936,6 +1952,40 @@ qemuDomainObjPrivateXMLParseVcpu(xmlNodePtr node, static int +qemuDomainObjPrivateXMLParseAutomaticPlacement(virQEMUDriverPtr driver, + qemuDomainObjPrivatePtr pri= v, + xmlXPathContextPtr ctxt) +{ + virCapsPtr caps =3D NULL; + char *nodeset; + int ret =3D -1; + + nodeset =3D virXPathString("string(./numad/@nodeset)", ctxt); + + if (!nodeset) + return 0; + + if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) + goto cleanup; + + if (virBitmapParse(nodeset, &priv->autoNodeset, caps->host.nnumaCell_m= ax) < 0) + goto cleanup; + + if (!(priv->autoCpuset =3D virCapabilitiesGetCpusForNodemask(caps, + priv->autoN= odeset))) + goto cleanup; + + ret =3D 0; + + cleanup: + virObjectUnref(caps); + VIR_FREE(nodeset); + + return ret; +} + + +static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, virDomainObjPtr vm, virDomainDefParserConfigPtr config) @@ -1949,7 +1999,6 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, xmlNodePtr *nodes =3D NULL; xmlNodePtr node =3D NULL; virQEMUCapsPtr qemuCaps =3D NULL; - virCapsPtr caps =3D NULL; if (VIR_ALLOC(priv->monConfig) < 0) goto error; @@ -2133,21 +2182,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, } VIR_FREE(nodes); - if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) + if (qemuDomainObjPrivateXMLParseAutomaticPlacement(driver, priv, ctxt)= < 0) goto error; - if ((tmp =3D virXPathString("string(./numad/@nodeset)", ctxt))) { - if (virBitmapParse(tmp, &priv->autoNodeset, - caps->host.nnumaCell_max) < 0) - goto error; - - if (!(priv->autoCpuset =3D virCapabilitiesGetCpusForNodemask(caps, - priv->a= utoNodeset))) - goto error; - } - virObjectUnref(caps); - VIR_FREE(tmp); - if ((tmp =3D virXPathString("string(./libDir/@path)", ctxt))) priv->libDir =3D tmp; if ((tmp =3D virXPathString("string(./channelTargetDir/@path)", ctxt))) @@ -2175,7 +2212,6 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, virStringListFree(priv->qemuDevices); priv->qemuDevices =3D NULL; virObjectUnref(qemuCaps); - virObjectUnref(caps); return -1; } --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list