From nobody Sun Feb 8 19:59:00 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 1533818361277125.54758747080643; Thu, 9 Aug 2018 05:39:21 -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 A4C9C308212C; Thu, 9 Aug 2018 12:39:18 +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 705081001940; Thu, 9 Aug 2018 12:39:18 +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 238AC3F64F; Thu, 9 Aug 2018 12:39:18 +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 w79Cd4WU002938 for ; Thu, 9 Aug 2018 08:39:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id DBF852166BA2; Thu, 9 Aug 2018 12:39:04 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A6922166BA8 for ; Thu, 9 Aug 2018 12:39:04 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 14:38:49 +0200 Message-Id: <89ff71938344e13d5aa1eeae002208f765c9f7dd.1533818183.git.phrdina@redhat.com> 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 17/20] conf: Move hugepage XML validation check out of qemu_command 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.42]); Thu, 09 Aug 2018 12:39:20 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We can safely validate the hugepage nodeset attribute at a define time. This validation is not done for already existing domains when the daemon is restarted. All the changes to the tests are necessary because we move the error from domain start into XML parse. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 32 +++++++++++++++++ src/qemu/qemu_command.c | 34 ------------------- .../seclabel-dynamic-none-relabel.xml | 2 +- tests/qemuxml2argvtest.c | 18 +++++----- .../hugepages-default-1G-nodeset-2M.xml | 1 - .../qemuxml2xmloutdata/hugepages-nodeset.xml | 1 - .../hugepages-numa-nodeset-nonexist.xml | 1 - .../seclabel-dynamic-none-relabel.xml | 2 +- tests/qemuxml2xmltest.c | 3 -- 9 files changed, 43 insertions(+), 51 deletions(-) delete mode 120000 tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2= M.xml delete mode 120000 tests/qemuxml2xmloutdata/hugepages-nodeset.xml delete mode 120000 tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexis= t.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8fd774b531..be9c08626a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6184,6 +6184,35 @@ virDomainDefLifecycleActionValidate(const virDomainD= ef *def) } =20 =20 +static int +virDomainDefMemtuneValidate(const virDomainDef *def) +{ + const virDomainMemtune *mem =3D &(def->mem); + size_t i; + ssize_t pos =3D virDomainNumaGetNodeCount(def->numa) - 1; + + for (i =3D 0; i < mem->nhugepages; i++) { + ssize_t nextBit; + + if (!mem->hugepages[i].nodemask) { + /* This is the master hugepage to use. Skip it as it has no + * nodemask anyway. */ + continue; + } + + nextBit =3D virBitmapNextSetBit(mem->hugepages[i].nodemask, pos); + if (nextBit >=3D 0) { + virReportError(VIR_ERR_XML_DETAIL, + _("hugepages: node %zd not found"), + nextBit); + return -1; + } + } + + return 0; +} + + static int virDomainDefValidateInternal(const virDomainDef *def) { @@ -6219,6 +6248,9 @@ virDomainDefValidateInternal(const virDomainDef *def) if (virDomainDefLifecycleActionValidate(def) < 0) return -1; =20 + if (virDomainDefMemtuneValidate(def) < 0) + return -1; + return 0; } =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9e8f2f4c9c..dbeb3a54f6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7489,16 +7489,6 @@ qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg, if (!def->mem.nhugepages) return 0; =20 - if (def->mem.hugepages[0].nodemask) { - ssize_t next_bit =3D virBitmapNextSetBit(def->mem.hugepages[0].nod= emask, -1); - if (next_bit >=3D 0) { - virReportError(VIR_ERR_XML_DETAIL, - _("hugepages: node %zd not found"), - next_bit); - return -1; - } - } - /* There is one special case: if user specified "huge" * pages of regular system pages size. * And there is nothing to do in this case. @@ -7631,30 +7621,6 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg, if (!virDomainNumatuneNodesetIsAvailable(def->numa, priv->autoNodeset)) goto cleanup; =20 - for (i =3D 0; i < def->mem.nhugepages; i++) { - ssize_t next_bit, pos =3D 0; - - if (!def->mem.hugepages[i].nodemask) { - /* This is the master hugepage to use. Skip it as it has no - * nodemask anyway. */ - continue; - } - - if (ncells) { - /* Fortunately, we allow only guest NUMA nodes to be continuous - * starting from zero. */ - pos =3D ncells - 1; - } - - next_bit =3D virBitmapNextSetBit(def->mem.hugepages[i].nodemask, p= os); - if (next_bit >=3D 0) { - virReportError(VIR_ERR_XML_DETAIL, - _("hugepages: node %zd not found"), - next_bit); - goto cleanup; - } - } - if (VIR_ALLOC_N(nodeBackends, ncells) < 0) goto cleanup; =20 diff --git a/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml b/tes= ts/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml index 47f253b5f7..e954250009 100644 --- a/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml +++ b/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml @@ -5,7 +5,7 @@ 262144 - + 4 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 606f710f20..9e2e59ec44 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -974,12 +974,12 @@ mymain(void) DO_TEST("hugepages-default", NONE); DO_TEST("hugepages-default-2M", NONE); DO_TEST("hugepages-default-system-size", NONE); - DO_TEST("hugepages-default-1G-nodeset-2M", NONE); - DO_TEST_FAILURE("hugepages-nodeset", NONE); - DO_TEST_FAILURE("hugepages-nodeset-nonexist", - QEMU_CAPS_DEVICE_PC_DIMM, - QEMU_CAPS_OBJECT_MEMORY_FILE, - QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD); + DO_TEST_PARSE_ERROR("hugepages-default-1G-nodeset-2M", NONE); + DO_TEST_PARSE_ERROR("hugepages-nodeset", NONE); + DO_TEST_PARSE_ERROR("hugepages-nodeset-nonexist", + QEMU_CAPS_DEVICE_PC_DIMM, + QEMU_CAPS_OBJECT_MEMORY_FILE, + QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD); DO_TEST("hugepages-numa-default", QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST("hugepages-numa-default-2M", @@ -994,9 +994,9 @@ mymain(void) DO_TEST("hugepages-numa-nodeset-part", QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE); - DO_TEST_FAILURE("hugepages-numa-nodeset-nonexist", - QEMU_CAPS_OBJECT_MEMORY_RAM, - QEMU_CAPS_OBJECT_MEMORY_FILE); + DO_TEST_PARSE_ERROR("hugepages-numa-nodeset-nonexist", + QEMU_CAPS_OBJECT_MEMORY_RAM, + QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST("hugepages-shared", QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE); diff --git a/tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml b= /tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml deleted file mode 120000 index 3d8eb7616e..0000000000 --- a/tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml +++ /dev/null @@ -1 +0,0 @@ -../qemuxml2argvdata/hugepages-default-1G-nodeset-2M.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/hugepages-nodeset.xml b/tests/qemuxml= 2xmloutdata/hugepages-nodeset.xml deleted file mode 120000 index b55838b780..0000000000 --- a/tests/qemuxml2xmloutdata/hugepages-nodeset.xml +++ /dev/null @@ -1 +0,0 @@ -../qemuxml2argvdata/hugepages-nodeset.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml b= /tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml deleted file mode 120000 index d490edca69..0000000000 --- a/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml +++ /dev/null @@ -1 +0,0 @@ -../qemuxml2argvdata/hugepages-numa-nodeset-nonexist.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml b/t= ests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml index 050967b4ee..bfa66b8deb 100644 --- a/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml +++ b/tests/qemuxml2xmloutdata/seclabel-dynamic-none-relabel.xml @@ -5,7 +5,7 @@ 262144 - + 4 diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 8af023f6b7..92406c8eb8 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -335,13 +335,10 @@ mymain(void) DO_TEST("hugepages-default", NONE); DO_TEST("hugepages-default-2M", NONE); DO_TEST("hugepages-default-system-size", NONE); - DO_TEST("hugepages-default-1G-nodeset-2M", NONE); - DO_TEST("hugepages-nodeset", NONE); DO_TEST("hugepages-numa-default-2M", NONE); DO_TEST("hugepages-numa-default-dimm", NONE); DO_TEST("hugepages-numa-nodeset", NONE); DO_TEST("hugepages-numa-nodeset-part", NONE); - DO_TEST("hugepages-numa-nodeset-nonexist", NONE); DO_TEST("hugepages-shared", NONE); DO_TEST("hugepages-memaccess", NONE); DO_TEST("hugepages-memaccess2", NONE); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list