|
|
51d9a2 |
From d81b31dc2ad17c7ba790c7cfbc29b82b6c8c198c Mon Sep 17 00:00:00 2001
|
|
|
51d9a2 |
Message-Id: <d81b31dc2ad17c7ba790c7cfbc29b82b6c8c198c@dist-git>
|
|
|
51d9a2 |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
51d9a2 |
Date: Mon, 13 Aug 2018 18:16:21 +0200
|
|
|
51d9a2 |
Subject: [PATCH] conf: Move hugepages validation out of XML parser
|
|
|
51d9a2 |
MIME-Version: 1.0
|
|
|
51d9a2 |
Content-Type: text/plain; charset=UTF-8
|
|
|
51d9a2 |
Content-Transfer-Encoding: 8bit
|
|
|
51d9a2 |
|
|
|
51d9a2 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
51d9a2 |
(cherry picked from commit 82327038390bfae117dc6e1d9062e38901cd4c97)
|
|
|
51d9a2 |
|
|
|
51d9a2 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1591235
|
|
|
51d9a2 |
|
|
|
51d9a2 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
51d9a2 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
51d9a2 |
---
|
|
|
51d9a2 |
src/conf/domain_conf.c | 75 ++++++++++++++++++++++--------------------
|
|
|
51d9a2 |
1 file changed, 40 insertions(+), 35 deletions(-)
|
|
|
51d9a2 |
|
|
|
51d9a2 |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
51d9a2 |
index 280bbdf35c..98e833c5bb 100644
|
|
|
51d9a2 |
--- a/src/conf/domain_conf.c
|
|
|
51d9a2 |
+++ b/src/conf/domain_conf.c
|
|
|
51d9a2 |
@@ -6149,9 +6149,49 @@ virDomainDefMemtuneValidate(const virDomainDef *def)
|
|
|
51d9a2 |
size_t i;
|
|
|
51d9a2 |
ssize_t pos = virDomainNumaGetNodeCount(def->numa) - 1;
|
|
|
51d9a2 |
|
|
|
51d9a2 |
+ if (mem->nhugepages == 0)
|
|
|
51d9a2 |
+ return 0;
|
|
|
51d9a2 |
+
|
|
|
51d9a2 |
+ if (mem->allocation == VIR_DOMAIN_MEMORY_ALLOCATION_ONDEMAND) {
|
|
|
51d9a2 |
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
51d9a2 |
+ _("hugepages are not allowed with memory "
|
|
|
51d9a2 |
+ "allocation ondemand"));
|
|
|
51d9a2 |
+ return -1;
|
|
|
51d9a2 |
+ }
|
|
|
51d9a2 |
+
|
|
|
51d9a2 |
+ if (mem->source == VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) {
|
|
|
51d9a2 |
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
51d9a2 |
+ _("hugepages are not allowed with anonymous "
|
|
|
51d9a2 |
+ "memory source"));
|
|
|
51d9a2 |
+ return -1;
|
|
|
51d9a2 |
+ }
|
|
|
51d9a2 |
+
|
|
|
51d9a2 |
for (i = 0; i < mem->nhugepages; i++) {
|
|
|
51d9a2 |
+ size_t j;
|
|
|
51d9a2 |
ssize_t nextBit;
|
|
|
51d9a2 |
|
|
|
51d9a2 |
+ for (j = 0; j < i; j++) {
|
|
|
51d9a2 |
+ if (mem->hugepages[i].nodemask &&
|
|
|
51d9a2 |
+ mem->hugepages[j].nodemask &&
|
|
|
51d9a2 |
+ virBitmapOverlaps(mem->hugepages[i].nodemask,
|
|
|
51d9a2 |
+ mem->hugepages[j].nodemask)) {
|
|
|
51d9a2 |
+ virReportError(VIR_ERR_XML_DETAIL,
|
|
|
51d9a2 |
+ _("nodeset attribute of hugepages "
|
|
|
51d9a2 |
+ "of sizes %llu and %llu intersect"),
|
|
|
51d9a2 |
+ mem->hugepages[i].size,
|
|
|
51d9a2 |
+ mem->hugepages[j].size);
|
|
|
51d9a2 |
+ return -1;
|
|
|
51d9a2 |
+ } else if (!mem->hugepages[i].nodemask &&
|
|
|
51d9a2 |
+ !mem->hugepages[j].nodemask) {
|
|
|
51d9a2 |
+ virReportError(VIR_ERR_XML_DETAIL,
|
|
|
51d9a2 |
+ _("two master hugepages detected: "
|
|
|
51d9a2 |
+ "%llu and %llu"),
|
|
|
51d9a2 |
+ mem->hugepages[i].size,
|
|
|
51d9a2 |
+ mem->hugepages[j].size);
|
|
|
51d9a2 |
+ return -1;
|
|
|
51d9a2 |
+ }
|
|
|
51d9a2 |
+ }
|
|
|
51d9a2 |
+
|
|
|
51d9a2 |
if (!mem->hugepages[i].nodemask) {
|
|
|
51d9a2 |
/* This is the master hugepage to use. Skip it as it has no
|
|
|
51d9a2 |
* nodemask anyway. */
|
|
|
51d9a2 |
@@ -19414,19 +19454,6 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|
|
51d9a2 |
|
|
|
51d9a2 |
if (virXPathNode("./memoryBacking/hugepages", ctxt)) {
|
|
|
51d9a2 |
/* hugepages will be used */
|
|
|
51d9a2 |
-
|
|
|
51d9a2 |
- if (def->mem.allocation == VIR_DOMAIN_MEMORY_ALLOCATION_ONDEMAND) {
|
|
|
51d9a2 |
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
51d9a2 |
- _("hugepages are not allowed with memory allocation ondemand"));
|
|
|
51d9a2 |
- goto error;
|
|
|
51d9a2 |
- }
|
|
|
51d9a2 |
-
|
|
|
51d9a2 |
- if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) {
|
|
|
51d9a2 |
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
51d9a2 |
- _("hugepages are not allowed with anonymous memory source"));
|
|
|
51d9a2 |
- goto error;
|
|
|
51d9a2 |
- }
|
|
|
51d9a2 |
-
|
|
|
51d9a2 |
if ((n = virXPathNodeSet("./memoryBacking/hugepages/page", ctxt, &nodes)) < 0) {
|
|
|
51d9a2 |
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
51d9a2 |
_("cannot extract hugepages nodes"));
|
|
|
51d9a2 |
@@ -19442,28 +19469,6 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|
|
51d9a2 |
&def->mem.hugepages[i]) < 0)
|
|
|
51d9a2 |
goto error;
|
|
|
51d9a2 |
def->mem.nhugepages++;
|
|
|
51d9a2 |
-
|
|
|
51d9a2 |
- for (j = 0; j < i; j++) {
|
|
|
51d9a2 |
- if (def->mem.hugepages[i].nodemask &&
|
|
|
51d9a2 |
- def->mem.hugepages[j].nodemask &&
|
|
|
51d9a2 |
- virBitmapOverlaps(def->mem.hugepages[i].nodemask,
|
|
|
51d9a2 |
- def->mem.hugepages[j].nodemask)) {
|
|
|
51d9a2 |
- virReportError(VIR_ERR_XML_DETAIL,
|
|
|
51d9a2 |
- _("nodeset attribute of hugepages "
|
|
|
51d9a2 |
- "of sizes %llu and %llu intersect"),
|
|
|
51d9a2 |
- def->mem.hugepages[i].size,
|
|
|
51d9a2 |
- def->mem.hugepages[j].size);
|
|
|
51d9a2 |
- goto error;
|
|
|
51d9a2 |
- } else if (!def->mem.hugepages[i].nodemask &&
|
|
|
51d9a2 |
- !def->mem.hugepages[j].nodemask) {
|
|
|
51d9a2 |
- virReportError(VIR_ERR_XML_DETAIL,
|
|
|
51d9a2 |
- _("two master hugepages detected: "
|
|
|
51d9a2 |
- "%llu and %llu"),
|
|
|
51d9a2 |
- def->mem.hugepages[i].size,
|
|
|
51d9a2 |
- def->mem.hugepages[j].size);
|
|
|
51d9a2 |
- goto error;
|
|
|
51d9a2 |
- }
|
|
|
51d9a2 |
- }
|
|
|
51d9a2 |
}
|
|
|
51d9a2 |
|
|
|
51d9a2 |
VIR_FREE(nodes);
|
|
|
51d9a2 |
--
|
|
|
51d9a2 |
2.18.0
|
|
|
51d9a2 |
|