From nobody Sun Apr 28 04:17:07 2024 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 1499867076300765.9340963153151; Wed, 12 Jul 2017 06:44:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B7B774870; Wed, 12 Jul 2017 13:44:33 +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 175466E514; Wed, 12 Jul 2017 13:44:33 +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 8BA393FAE5; Wed, 12 Jul 2017 13:44:32 +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 v6CDi9NQ032537 for ; Wed, 12 Jul 2017 09:44:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7211B5D9CE; Wed, 12 Jul 2017 13:44:09 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B54E61B72; Wed, 12 Jul 2017 13:44:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4B7B774870 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4B7B774870 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 12 Jul 2017 15:44:02 +0200 Message-Id: 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 1/5] util: bitmap: Modify virBitmapSubtract to virBitmapIntersect 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 12 Jul 2017 13:44:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since virBitmapSubtract is unused modify it to perform bitmap intersection. Reviewed-by: Andrea Bolognani --- src/libvirt_private.syms | 2 +- src/util/virbitmap.c | 14 +++++++------- src/util/virbitmap.h | 2 +- tests/virbitmaptest.c | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3f94521df..4ad1f7a60 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1295,6 +1295,7 @@ virBitmapEqual; virBitmapFormat; virBitmapFree; virBitmapGetBit; +virBitmapIntersect; virBitmapIsAllClear; virBitmapIsAllSet; virBitmapIsBitSet; @@ -1315,7 +1316,6 @@ virBitmapSetBit; virBitmapSetBitExpand; virBitmapSize; virBitmapString; -virBitmapSubtract; virBitmapToData; virBitmapToDataBuf; diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index eac63d997..a5077fe7c 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -1091,15 +1091,15 @@ virBitmapOverlaps(virBitmapPtr b1, } /** - * virBitmapSubtract: - * @a: minuend/result - * @b: subtrahend + * virBitmapIntersect: + * @a: bitmap, modified to contain result + * @b: bitmap * - * Performs bitwise subtraction: a =3D a - b + * Performs intersection of two bitmaps: a =3D intersect(a, b) */ void -virBitmapSubtract(virBitmapPtr a, - virBitmapPtr b) +virBitmapIntersect(virBitmapPtr a, + virBitmapPtr b) { size_t i; size_t max =3D a->map_len; @@ -1108,5 +1108,5 @@ virBitmapSubtract(virBitmapPtr a, max =3D b->map_len; for (i =3D 0; i < max; i++) - a->map[i] &=3D ~b->map[i]; + a->map[i] &=3D b->map[i]; } diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index 36282af1c..ffa3c42d7 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -143,7 +143,7 @@ bool virBitmapOverlaps(virBitmapPtr b1, virBitmapPtr b2) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -void virBitmapSubtract(virBitmapPtr a, virBitmapPtr b) +void virBitmapIntersect(virBitmapPtr a, virBitmapPtr b) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); #endif diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index e5305d022..882c71544 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -589,7 +589,7 @@ test11(const void *opaque) virBitmapParse(data->res, &resmap, 256) < 0) goto cleanup; - virBitmapSubtract(amap, bmap); + virBitmapIntersect(amap, bmap); if (!virBitmapEqual(amap, resmap)) { fprintf(stderr, "\n bitmap subtraction failed: '%s'-'%s'!=3D'%s'\n= ", @@ -700,13 +700,13 @@ mymain(void) ret =3D -1; virTestCounterReset("test11-"); - TESTBINARYOP("0", "0", "0,^0", test11); - TESTBINARYOP("0-3", "0", "1-3", test11); - TESTBINARYOP("0-3", "0,3", "1-2", test11); + TESTBINARYOP("0", "0", "0", test11); + TESTBINARYOP("0-3", "0", "0", test11); + TESTBINARYOP("0-3", "0,3", "0,3", test11); TESTBINARYOP("0,^0", "0", "0,^0", test11); - TESTBINARYOP("0-3", "0-3", "0,^0", test11); - TESTBINARYOP("0-3", "0,^0", "0-3", test11); - TESTBINARYOP("0,2", "1,3", "0,2", test11); + TESTBINARYOP("0-3", "0-3", "0-3", test11); + TESTBINARYOP("0-3", "0,^0", "0,^0", test11); + TESTBINARYOP("0,2", "1,3", "0,^0", test11); if (virTestRun("test12", test12, NULL) < 0) ret =3D -1; --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 04:17:07 2024 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 From nobody Sun Apr 28 04:17:07 2024 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 1499867056777446.55033679268524; Wed, 12 Jul 2017 06:44:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3BEF63A18D; Wed, 12 Jul 2017 13:44:15 +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 BC7E76E8DE; Wed, 12 Jul 2017 13:44:14 +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 4AD593FAE1; Wed, 12 Jul 2017 13:44:14 +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 v6CDiC83032557 for ; Wed, 12 Jul 2017 09:44:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id CF8FE6DAD4; Wed, 12 Jul 2017 13:44:12 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09A916DA86; Wed, 12 Jul 2017 13:44:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3BEF63A18D 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 3BEF63A18D From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 12 Jul 2017 15:44:04 +0200 Message-Id: <3603cbaad5f8d28600d8b6055c65d2daaea95544.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 3/5] qemu: domain: Store and restore autoCpuset to status XML 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.15 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:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Decouple them by storing them in the XML separately rather than regenerating them. This will simplify upcoming fixes. Reviewed-by: Andrea Bolognani --- src/qemu/qemu_domain.c | 32 +++++++++++++++++++++++++------- tests/qemuxml2xmltest.c | 2 +- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 92e5609ad..8c29db15f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1765,20 +1765,30 @@ qemuDomainObjPtrivateXMLFormatAutomaticPlacement(vi= rBufferPtr buf, qemuDomainObjPrivatePtr p= riv) { char *nodeset =3D NULL; + char *cpuset =3D NULL; int ret =3D -1; - if (!priv->autoNodeset) + if (!priv->autoNodeset && !priv->autoCpuset) return 0; - if (!(nodeset =3D virBitmapFormat(priv->autoNodeset))) + if (priv->autoNodeset && + !((nodeset =3D virBitmapFormat(priv->autoNodeset)))) goto cleanup; - virBufferAsprintf(buf, "\n", nodeset); + if (priv->autoCpuset && + !((cpuset =3D virBitmapFormat(priv->autoCpuset)))) + goto cleanup; + + virBufferAddLit(buf, "\n"); ret =3D 0; cleanup: VIR_FREE(nodeset); + VIR_FREE(cpuset); return ret; } @@ -1958,11 +1968,13 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(virQ= EMUDriverPtr driver, { virCapsPtr caps =3D NULL; char *nodeset; + char *cpuset; int ret =3D -1; nodeset =3D virXPathString("string(./numad/@nodeset)", ctxt); + cpuset =3D virXPathString("string(./numad/@cpuset)", ctxt); - if (!nodeset) + if (!nodeset && !cpuset) return 0; if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) @@ -1971,15 +1983,21 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(virQ= EMUDriverPtr driver, if (virBitmapParse(nodeset, &priv->autoNodeset, caps->host.nnumaCell_m= ax) < 0) goto cleanup; - if (!(priv->autoCpuset =3D virCapabilitiesGetCpusForNodemask(caps, - priv->autoN= odeset))) - goto cleanup; + if (cpuset) { + if (virBitmapParse(cpuset, &priv->autoCpuset, VIR_DOMAIN_CPUMASK_L= EN) < 0) + goto cleanup; + } else { + if (!(priv->autoCpuset =3D virCapabilitiesGetCpusForNodemask(caps, + priv->a= utoNodeset))) + goto cleanup; + } ret =3D 0; cleanup: virObjectUnref(caps); VIR_FREE(nodeset); + VIR_FREE(cpuset); return ret; } diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 79347671f..24d1eb33c 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -95,7 +95,7 @@ static const char testStatusXMLPrefixFooter[] =3D " \n" " \n" " \n" -" \n" +" \n" " \n" " \n"; --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 04:17:07 2024 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 1499867086926504.03242868319876; Wed, 12 Jul 2017 06:44:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2782381243; Wed, 12 Jul 2017 13:44:43 +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 E8FFB4D745; Wed, 12 Jul 2017 13:44:42 +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 80FFD1853E33; Wed, 12 Jul 2017 13:44:42 +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 v6CDiE1u032569 for ; Wed, 12 Jul 2017 09:44:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id BC6CB5DA60; Wed, 12 Jul 2017 13:44:14 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8D6C6DB6A; Wed, 12 Jul 2017 13:44:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2782381243 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.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 2782381243 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 12 Jul 2017 15:44:05 +0200 Message-Id: <99280395408b305b26e999938abe9ccd3dfcf220.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 4/5] qemu: process: Extract gathering of 'numad' placement into a function 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 12 Jul 2017 13:44:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Remove the code from qemuProcessPrepareDomain so that it won't get even more bloated. Reviewed-by: Andrea Bolognani --- src/qemu/qemu_process.c | 61 ++++++++++++++++++++++++++++++++-------------= ---- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e6522a294..01fe33c92 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5410,6 +5410,44 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, } +static int +qemuProcessPrepareDomainNUMAPlacement(virDomainObjPtr vm, + virCapsPtr caps) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + char *nodesetstr =3D NULL; + int ret =3D -1; + + /* Get the advisory nodeset from numad if 'placement' of + * either or is 'auto'. + */ + if (!virDomainDefNeedsPlacementAdvice(vm->def)) + return 0; + + nodesetstr =3D virNumaGetAutoPlacementAdvice(virDomainDefGetVcpus(vm->= def), + virDomainDefGetMemoryTotal(= vm->def)); + + if (!nodesetstr) + goto cleanup; + + VIR_DEBUG("Nodeset returned from numad: %s", nodesetstr); + + if (virBitmapParse(nodesetstr, &priv->autoNodeset, + VIR_DOMAIN_CPUMASK_LEN) < 0) + goto cleanup; + + if (!(priv->autoCpuset =3D virCapabilitiesGetCpusForNodemask(caps, + priv->autoN= odeset))) + goto cleanup; + + ret =3D 0; + + cleanup: + VIR_FREE(nodesetstr); + return ret; +} + + /** * qemuProcessPrepareDomain * @@ -5430,7 +5468,6 @@ qemuProcessPrepareDomain(virConnectPtr conn, { int ret =3D -1; size_t i; - char *nodeset =3D NULL; qemuDomainObjPrivatePtr priv =3D vm->privateData; virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); virCapsPtr caps; @@ -5448,25 +5485,8 @@ qemuProcessPrepareDomain(virConnectPtr conn, } virDomainAuditSecurityLabel(vm, true); - /* Get the advisory nodeset from numad if 'placement' of - * either or is 'auto'. - */ - if (virDomainDefNeedsPlacementAdvice(vm->def)) { - nodeset =3D virNumaGetAutoPlacementAdvice(virDomainDefGetVcpus= (vm->def), - virDomainDefGetMemoryT= otal(vm->def)); - if (!nodeset) - goto cleanup; - - VIR_DEBUG("Nodeset returned from numad: %s", nodeset); - - if (virBitmapParse(nodeset, &priv->autoNodeset, - VIR_DOMAIN_CPUMASK_LEN) < 0) - goto cleanup; - - if (!(priv->autoCpuset =3D virCapabilitiesGetCpusForNodemask(c= aps, - pri= v->autoNodeset))) - goto cleanup; - } + if (qemuProcessPrepareDomainNUMAPlacement(vm, caps) < 0) + goto cleanup; } /* Whether we should use virtlogd as stdio handler for character @@ -5537,7 +5557,6 @@ qemuProcessPrepareDomain(virConnectPtr conn, ret =3D 0; cleanup: - VIR_FREE(nodeset); virObjectUnref(caps); virObjectUnref(cfg); return ret; --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 04:17:07 2024 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 1499867071117431.33736734673437; Wed, 12 Jul 2017 06:44:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CE7A580082; Wed, 12 Jul 2017 13:44: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 9B7186E512; Wed, 12 Jul 2017 13:44: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 40BF21853E30; Wed, 12 Jul 2017 13:44:26 +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 v6CDiPEv032580 for ; Wed, 12 Jul 2017 09:44:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6C6BF6DACA; Wed, 12 Jul 2017 13:44:25 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 996866DA86; Wed, 12 Jul 2017 13:44:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CE7A580082 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.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 CE7A580082 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 12 Jul 2017 15:44:06 +0200 Message-Id: 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 5/5] qemu: process: Don't put memoryless NUMA nodes into 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 12 Jul 2017 13:44:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 'numad' may return a nodeset which contains NUMA nodes without memory for certain configurations. Since cgroups code will not be happy using nodes without memory we need to store only numa nodes with memory in autoNodeset. On the other hand autoCpuset should contain cpus also for nodes which do not have any memory. Reviewed-by: Andrea Bolognani --- src/qemu/qemu_process.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 01fe33c92..78c5692a0 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5416,6 +5416,8 @@ qemuProcessPrepareDomainNUMAPlacement(virDomainObjPtr= vm, { qemuDomainObjPrivatePtr priv =3D vm->privateData; char *nodesetstr =3D NULL; + virBitmapPtr numadNodeset =3D NULL; + virBitmapPtr hostMemoryNodeset =3D NULL; int ret =3D -1; /* Get the advisory nodeset from numad if 'placement' of @@ -5430,20 +5432,30 @@ qemuProcessPrepareDomainNUMAPlacement(virDomainObjP= tr vm, if (!nodesetstr) goto cleanup; + if (!(hostMemoryNodeset =3D virNumaGetHostMemoryNodeset())) + goto cleanup; + VIR_DEBUG("Nodeset returned from numad: %s", nodesetstr); - if (virBitmapParse(nodesetstr, &priv->autoNodeset, - VIR_DOMAIN_CPUMASK_LEN) < 0) + if (virBitmapParse(nodesetstr, &numadNodeset, VIR_DOMAIN_CPUMASK_LEN) = < 0) goto cleanup; - if (!(priv->autoCpuset =3D virCapabilitiesGetCpusForNodemask(caps, - priv->autoN= odeset))) + /* numad may return a nodeset that only contains cpus but cgroups don'= t play + * well with that. Set the autoCpuset from all cpus from that nodeset,= but + * assign autoNodeset only with nodes containing memory. */ + if (!(priv->autoCpuset =3D virCapabilitiesGetCpusForNodemask(caps, num= adNodeset))) goto cleanup; + virBitmapIntersect(numadNodeset, hostMemoryNodeset); + + VIR_STEAL_PTR(priv->autoNodeset, numadNodeset); + ret =3D 0; cleanup: VIR_FREE(nodesetstr); + virBitmapFree(numadNodeset); + virBitmapFree(hostMemoryNodeset); return ret; } --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list