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