From nobody Sat Apr 20 13:10:47 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; 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 1531297380866232.5566901461906; Wed, 11 Jul 2018 01:23:00 -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 293E113A88; Wed, 11 Jul 2018 08:22:59 +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 D58985D9CA; Wed, 11 Jul 2018 08:22:58 +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 C99CA4A465; Wed, 11 Jul 2018 08:22:57 +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 w6B8Mt7R001130 for ; Wed, 11 Jul 2018 04:22:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id B21D72166BA2; Wed, 11 Jul 2018 08:22:55 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 395202156892 for ; Wed, 11 Jul 2018 08:22:55 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Wed, 11 Jul 2018 10:22: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 1/4] tests: Add additional hugepage tests to cover current state 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.29]); Wed, 11 Jul 2018 08:22:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Both of these cases were working before commit tried to fix the case were there is no guest NUMA configured but there is "nodeset=3D'0'" attribute. The case where "nodeset=3D'1'" without any guest NUMA topology is covered by "hugepage-pages8" test case. Signed-off-by: Pavel Hrdina --- tests/qemuxml2argvdata/hugepages-pages10.xml | 30 ++++++++++++++++++ tests/qemuxml2argvdata/hugepages-pages9.xml | 31 +++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ .../qemuxml2xmloutdata/hugepages-pages10.xml | 30 ++++++++++++++++++ tests/qemuxml2xmloutdata/hugepages-pages9.xml | 31 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 ++ 6 files changed, 126 insertions(+) create mode 100644 tests/qemuxml2argvdata/hugepages-pages10.xml create mode 100644 tests/qemuxml2argvdata/hugepages-pages9.xml create mode 100644 tests/qemuxml2xmloutdata/hugepages-pages10.xml create mode 100644 tests/qemuxml2xmloutdata/hugepages-pages9.xml diff --git a/tests/qemuxml2argvdata/hugepages-pages10.xml b/tests/qemuxml2a= rgvdata/hugepages-pages10.xml new file mode 100644 index 0000000000..4a85ddffad --- /dev/null +++ b/tests/qemuxml2argvdata/hugepages-pages10.xml @@ -0,0 +1,30 @@ + + SomeDummyHugepagesGuest + ef1bdff4-27f3-4e85-a807-5fb4d58463cc + 1048576 + 1048576 + + + + + + 2 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + +
+ + + + + + + diff --git a/tests/qemuxml2argvdata/hugepages-pages9.xml b/tests/qemuxml2ar= gvdata/hugepages-pages9.xml new file mode 100644 index 0000000000..8f380c46df --- /dev/null +++ b/tests/qemuxml2argvdata/hugepages-pages9.xml @@ -0,0 +1,31 @@ + + SomeDummyHugepagesGuest + ef1bdff4-27f3-4e85-a807-5fb4d58463cc + 1048576 + 1048576 + + + + + + + 2 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + +
+ + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a929e4314e..7236e184b8 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -978,6 +978,8 @@ mymain(void) DO_TEST_FAILURE("hugepages-pages8", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD); + DO_TEST_FAILURE("hugepages-pages9", NONE); + DO_TEST_FAILURE("hugepages-pages10", NONE); DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA); diff --git a/tests/qemuxml2xmloutdata/hugepages-pages10.xml b/tests/qemuxml= 2xmloutdata/hugepages-pages10.xml new file mode 100644 index 0000000000..4a85ddffad --- /dev/null +++ b/tests/qemuxml2xmloutdata/hugepages-pages10.xml @@ -0,0 +1,30 @@ + + SomeDummyHugepagesGuest + ef1bdff4-27f3-4e85-a807-5fb4d58463cc + 1048576 + 1048576 + + + + + + 2 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + +
+ + + + + + + diff --git a/tests/qemuxml2xmloutdata/hugepages-pages9.xml b/tests/qemuxml2= xmloutdata/hugepages-pages9.xml new file mode 100644 index 0000000000..8f380c46df --- /dev/null +++ b/tests/qemuxml2xmloutdata/hugepages-pages9.xml @@ -0,0 +1,31 @@ + + SomeDummyHugepagesGuest + ef1bdff4-27f3-4e85-a807-5fb4d58463cc + 1048576 + 1048576 + + + + + + + 2 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + +
+ + + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index c0b228515c..ae11fbe60c 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -338,6 +338,8 @@ mymain(void) DO_TEST("hugepages-pages5", NONE); DO_TEST("hugepages-pages6", NONE); DO_TEST("hugepages-pages7", NONE); + DO_TEST("hugepages-pages9", NONE); + DO_TEST("hugepages-pages10", 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 From nobody Sat Apr 20 13:10:47 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; 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 1531297391119255.92397875706286; Wed, 11 Jul 2018 01:23:11 -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 C1A93A7F1; Wed, 11 Jul 2018 08:23:09 +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 84D466016F; Wed, 11 Jul 2018 08:23:09 +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 2E75F18037F2; Wed, 11 Jul 2018 08:23:09 +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 w6B8MuPb001135 for ; Wed, 11 Jul 2018 04:22:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 55AFE2156892; Wed, 11 Jul 2018 08:22:56 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE1F42156891 for ; Wed, 11 Jul 2018 08:22:55 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Wed, 11 Jul 2018 10:22:51 +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 2/4] 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.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.29]); Wed, 11 Jul 2018 08:23:10 +0000 (UTC) X-ZohoMail: 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 | 16 +++++---- .../qemuxml2xmloutdata/hugepages-pages10.xml | 30 ---------------- tests/qemuxml2xmloutdata/hugepages-pages4.xml | 1 - tests/qemuxml2xmloutdata/hugepages-pages9.xml | 31 ----------------- .../seclabel-dynamic-none-relabel.xml | 2 +- tests/qemuxml2xmltest.c | 3 -- 9 files changed, 43 insertions(+), 108 deletions(-) delete mode 100644 tests/qemuxml2xmloutdata/hugepages-pages10.xml delete mode 120000 tests/qemuxml2xmloutdata/hugepages-pages4.xml delete mode 100644 tests/qemuxml2xmloutdata/hugepages-pages9.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7396616eda..20d67e7854 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6104,6 +6104,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) { @@ -6139,6 +6168,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 44ae8dcef7..a0b829628a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7470,16 +7470,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. @@ -7612,30 +7602,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 7236e184b8..15f9fb7b11 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -968,18 +968,20 @@ mymain(void) QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST_PARSE_ERROR("hugepages-memaccess-invalid", NONE); - DO_TEST_FAILURE("hugepages-pages4", - QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE); + DO_TEST_PARSE_ERROR("hugepages-pages4", + QEMU_CAPS_OBJECT_MEMORY_RAM, + QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST("hugepages-pages5", NONE); DO_TEST("hugepages-pages6", NONE); DO_TEST("hugepages-pages7", QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD); - DO_TEST_FAILURE("hugepages-pages8", - QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_OBJECT_MEMORY_FILE, - QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD); - DO_TEST_FAILURE("hugepages-pages9", NONE); - DO_TEST_FAILURE("hugepages-pages10", NONE); + DO_TEST_PARSE_ERROR("hugepages-pages8", + QEMU_CAPS_DEVICE_PC_DIMM, + QEMU_CAPS_OBJECT_MEMORY_FILE, + QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD); + DO_TEST_PARSE_ERROR("hugepages-pages9", NONE); + DO_TEST_PARSE_ERROR("hugepages-pages10", NONE); DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA); diff --git a/tests/qemuxml2xmloutdata/hugepages-pages10.xml b/tests/qemuxml= 2xmloutdata/hugepages-pages10.xml deleted file mode 100644 index 4a85ddffad..0000000000 --- a/tests/qemuxml2xmloutdata/hugepages-pages10.xml +++ /dev/null @@ -1,30 +0,0 @@ - - SomeDummyHugepagesGuest - ef1bdff4-27f3-4e85-a807-5fb4d58463cc - 1048576 - 1048576 - - - - - - 2 - - hvm - - - - destroy - restart - destroy - - /usr/bin/qemu-system-i686 - -
- - - - - - - diff --git a/tests/qemuxml2xmloutdata/hugepages-pages4.xml b/tests/qemuxml2= xmloutdata/hugepages-pages4.xml deleted file mode 120000 index 127e66e64f..0000000000 --- a/tests/qemuxml2xmloutdata/hugepages-pages4.xml +++ /dev/null @@ -1 +0,0 @@ -../qemuxml2argvdata/hugepages-pages4.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/hugepages-pages9.xml b/tests/qemuxml2= xmloutdata/hugepages-pages9.xml deleted file mode 100644 index 8f380c46df..0000000000 --- a/tests/qemuxml2xmloutdata/hugepages-pages9.xml +++ /dev/null @@ -1,31 +0,0 @@ - - SomeDummyHugepagesGuest - ef1bdff4-27f3-4e85-a807-5fb4d58463cc - 1048576 - 1048576 - - - - - - - 2 - - hvm - - - - destroy - restart - destroy - - /usr/bin/qemu-system-i686 - -
- - - - - - - 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 ae11fbe60c..a70516ada1 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -334,12 +334,9 @@ mymain(void) DO_TEST("hugepages-pages", NONE); DO_TEST("hugepages-pages2", NONE); DO_TEST("hugepages-pages3", NONE); - DO_TEST("hugepages-pages4", NONE); DO_TEST("hugepages-pages5", NONE); DO_TEST("hugepages-pages6", NONE); DO_TEST("hugepages-pages7", NONE); - DO_TEST("hugepages-pages9", NONE); - DO_TEST("hugepages-pages10", 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 From nobody Sat Apr 20 13:10:47 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; 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 1531297382334620.577039907947; Wed, 11 Jul 2018 01:23:02 -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 D6C4530832DE; Wed, 11 Jul 2018 08:23:00 +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 9FAD2600CD; Wed, 11 Jul 2018 08:23:00 +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 50D4918037ED; Wed, 11 Jul 2018 08:23:00 +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 w6B8MvVU001140 for ; Wed, 11 Jul 2018 04:22:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id EE4F92156891; Wed, 11 Jul 2018 08:22:56 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91EC82166BA2 for ; Wed, 11 Jul 2018 08:22:56 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Wed, 11 Jul 2018 10:22:52 +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 3/4] 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.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.44]); Wed, 11 Jul 2018 08:23:01 +0000 (UTC) X-ZohoMail: 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 20d67e7854..5249f59d1a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6111,9 +6111,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. */ @@ -19362,19 +19402,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")); @@ -19390,28 +19417,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 From nobody Sat Apr 20 13:10:47 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; 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 1531297391366176.53905292703507; Wed, 11 Jul 2018 01:23:11 -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 9148630001E7; Wed, 11 Jul 2018 08:23:09 +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 52FB8600CD; Wed, 11 Jul 2018 08:23:09 +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 F1B2F18037EC; Wed, 11 Jul 2018 08:23:08 +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 w6B8MvCc001148 for ; Wed, 11 Jul 2018 04:22:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 918AB2156891; Wed, 11 Jul 2018 08:22:57 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3564E2156892 for ; Wed, 11 Jul 2018 08:22:57 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Wed, 11 Jul 2018 10:22:53 +0200 Message-Id: <073ec8f77a0dca34de8236acf51cd2e6a51d3bd8.1531297333.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 4/4] conf: Introduce virDomainDefPostParseMemtune 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.46]); Wed, 11 Jul 2018 08:23:10 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Previously we were ignoring "nodeset" attribute for hugepage pages if there was no guest NUMA topology configured in the domain XML. Commit partially fixed that issue but it introduced a somehow valid regression. In case that there is no guest NUMA topology configured and the "nodeset" attribute is set to "0" it was accepted and was working properly even though it was not completely valid XML. This patch introduces a workaround that it will ignore the nodeset=3D"0" only in case that there is no guest NUMA topology in order not to hit the validation error. After this commit the following XML configuration is valid: but this configuration remains invalid: The issue with the second configuration is that it was originally working, however changing the order of the elements resolved into using different page size for the guest. The code is written in a way that it expect only one page configured and always uses only the first page in case that there is no guest NUMA topology configured. See qemuBuildMemPathStr() function for details. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1591235 Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 27 +++++++++++++++++ tests/qemuxml2argvdata/hugepages-pages10.args | 26 ++++++++++++++++ tests/qemuxml2argvtest.c | 2 +- .../qemuxml2xmloutdata/hugepages-pages10.xml | 30 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 5 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/hugepages-pages10.args create mode 100644 tests/qemuxml2xmloutdata/hugepages-pages10.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5249f59d1a..bf5000f7a2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4085,6 +4085,31 @@ virDomainDefPostParseMemory(virDomainDefPtr def, } =20 =20 +static void +virDomainDefPostParseMemtune(virDomainDefPtr def) +{ + size_t i; + + if (virDomainNumaGetNodeCount(def->numa) =3D=3D 0) { + /* If guest NUMA is not configured and any hugepage page has nodem= ask + * set to "0" free and clear that nodemas, otherwise we would rise + * an error that there is no guest NUMA node configured. */ + for (i =3D 0; i < def->mem.nhugepages; i++) { + ssize_t nextBit; + + if (!def->mem.hugepages[i].nodemask) + continue; + + nextBit =3D virBitmapNextSetBit(def->mem.hugepages[i].nodemask= , 0); + if (nextBit < 0) { + virBitmapFree(def->mem.hugepages[i].nodemask); + def->mem.hugepages[i].nodemask =3D NULL; + } + } + } +} + + static int virDomainDefAddConsoleCompat(virDomainDefPtr def) { @@ -5134,6 +5159,8 @@ virDomainDefPostParseCommon(virDomainDefPtr def, if (virDomainDefPostParseMemory(def, data->parseFlags) < 0) return -1; =20 + virDomainDefPostParseMemtune(def); + if (virDomainDefRejectDuplicateControllers(def) < 0) return -1; =20 diff --git a/tests/qemuxml2argvdata/hugepages-pages10.args b/tests/qemuxml2= argvdata/hugepages-pages10.args new file mode 100644 index 0000000000..d094be1252 --- /dev/null +++ b/tests/qemuxml2argvdata/hugepages-pages10.args @@ -0,0 +1,26 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i686 \ +-name SomeDummyHugepagesGuest \ +-S \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 1024 \ +-mem-prealloc \ +-mem-path /dev/hugepages2M/libvirt/qemu/-1-SomeDummyHugepagesGu \ +-smp 2,sockets=3D2,cores=3D1,threads=3D1 \ +-uuid ef1bdff4-27f3-4e85-a807-5fb4d58463cc \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,\ +path=3D/tmp/lib/domain--1-SomeDummyHugepagesGu/monitor.sock,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot c \ +-usb diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 15f9fb7b11..6a57c419d1 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -981,7 +981,7 @@ mymain(void) QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD); DO_TEST_PARSE_ERROR("hugepages-pages9", NONE); - DO_TEST_PARSE_ERROR("hugepages-pages10", NONE); + DO_TEST("hugepages-pages10", NONE); DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_NUMA); diff --git a/tests/qemuxml2xmloutdata/hugepages-pages10.xml b/tests/qemuxml= 2xmloutdata/hugepages-pages10.xml new file mode 100644 index 0000000000..ac219a7800 --- /dev/null +++ b/tests/qemuxml2xmloutdata/hugepages-pages10.xml @@ -0,0 +1,30 @@ + + SomeDummyHugepagesGuest + ef1bdff4-27f3-4e85-a807-5fb4d58463cc + 1048576 + 1048576 + + + + + + 2 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + +
+ + + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index a70516ada1..052c3fe387 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -337,6 +337,7 @@ mymain(void) DO_TEST("hugepages-pages5", NONE); DO_TEST("hugepages-pages6", NONE); DO_TEST("hugepages-pages7", NONE); + DO_TEST("hugepages-pages10", 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