From nobody Sun Feb 8 16:11:33 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=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1533818364664939.9870731557013; Thu, 9 Aug 2018 05:39:24 -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 B54903001FC6; Thu, 9 Aug 2018 12:39:22 +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 86AE81001903; Thu, 9 Aug 2018 12:39:22 +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 3C29718325B9; Thu, 9 Aug 2018 12:39:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w79Cd5Ib002950 for ; Thu, 9 Aug 2018 08:39:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8AE622166BA2; Thu, 9 Aug 2018 12:39:05 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 293EC2166BA8 for ; Thu, 9 Aug 2018 12:39:05 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 14:38:50 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 18/20] conf: Move hugepages validation out of XML parser 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.43]); Thu, 09 Aug 2018 12:39:23 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 75 ++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index be9c08626a..f88576b5cc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6191,9 +6191,49 @@ virDomainDefMemtuneValidate(const virDomainDef *def) size_t i; ssize_t pos =3D virDomainNumaGetNodeCount(def->numa) - 1; =20 + if (mem->nhugepages =3D=3D 0) + return 0; + + if (mem->allocation =3D=3D VIR_DOMAIN_MEMORY_ALLOCATION_ONDEMAND) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("hugepages are not allowed with memory " + "allocation ondemand")); + return -1; + } + + if (mem->source =3D=3D VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("hugepages are not allowed with anonymous " + "memory source")); + return -1; + } + for (i =3D 0; i < mem->nhugepages; i++) { + size_t j; ssize_t nextBit; =20 + for (j =3D 0; j < i; j++) { + if (mem->hugepages[i].nodemask && + mem->hugepages[j].nodemask && + virBitmapOverlaps(mem->hugepages[i].nodemask, + mem->hugepages[j].nodemask)) { + virReportError(VIR_ERR_XML_DETAIL, + _("nodeset attribute of hugepages " + "of sizes %llu and %llu intersect"), + mem->hugepages[i].size, + mem->hugepages[j].size); + return -1; + } else if (!mem->hugepages[i].nodemask && + !mem->hugepages[j].nodemask) { + virReportError(VIR_ERR_XML_DETAIL, + _("two master hugepages detected: " + "%llu and %llu"), + mem->hugepages[i].size, + mem->hugepages[j].size); + return -1; + } + } + if (!mem->hugepages[i].nodemask) { /* This is the master hugepage to use. Skip it as it has no * nodemask anyway. */ @@ -19466,19 +19506,6 @@ virDomainDefParseXML(xmlDocPtr xml, =20 if (virXPathNode("./memoryBacking/hugepages", ctxt)) { /* hugepages will be used */ - - if (def->mem.allocation =3D=3D VIR_DOMAIN_MEMORY_ALLOCATION_ONDEMA= ND) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("hugepages are not allowed with memory alloca= tion ondemand")); - goto error; - } - - if (def->mem.source =3D=3D VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("hugepages are not allowed with anonymous mem= ory source")); - goto error; - } - if ((n =3D virXPathNodeSet("./memoryBacking/hugepages/page", ctxt,= &nodes)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot extract hugepages nodes")); @@ -19494,28 +19521,6 @@ virDomainDefParseXML(xmlDocPtr xml, &def->mem.hugepages[i]) < 0) goto error; def->mem.nhugepages++; - - for (j =3D 0; j < i; j++) { - if (def->mem.hugepages[i].nodemask && - def->mem.hugepages[j].nodemask && - virBitmapOverlaps(def->mem.hugepages[i].nodemask, - def->mem.hugepages[j].nodemask))= { - virReportError(VIR_ERR_XML_DETAIL, - _("nodeset attribute of hugepages " - "of sizes %llu and %llu intersect= "), - def->mem.hugepages[i].size, - def->mem.hugepages[j].size); - goto error; - } else if (!def->mem.hugepages[i].nodemask && - !def->mem.hugepages[j].nodemask) { - virReportError(VIR_ERR_XML_DETAIL, - _("two master hugepages detected: " - "%llu and %llu"), - def->mem.hugepages[i].size, - def->mem.hugepages[j].size); - goto error; - } - } } =20 VIR_FREE(nodes); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list