From 61d340a27d781bcb4af0c9e63101e8ad5b5e3588 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Tue, 11 Sep 2018 08:46:46 -0400 Subject: [PATCH] conf: Move hypervisor specific nhugepage checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 82327038 moved a couple of checks out of the XML parser into the domain validation; however, those checks seem to be more useful as hypervisor specific checks rather than the more general domain conf checks (nothing in the docs indicate a specific error). Fortunately only QEMU was processing the memoryBacking, thus add the changes to qemuDomainDefValidateMemory and change the code a bit to make usage of the similar deref to def->mem and the mem->nhugepages filter. Signed-off-by: John Ferlan Reviewed-by: Marc-André Lureau --- src/conf/domain_conf.c | 17 ----------------- src/qemu/qemu_domain.c | 27 ++++++++++++++++++++++----- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b241b7ae77..409a2291ff 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6187,23 +6187,6 @@ virDomainDefMemtuneValidate(const virDomainDef *def) size_t i; ssize_t pos = virDomainNumaGetNodeCount(def->numa) - 1; - if (mem->nhugepages == 0) - return 0; - - if (mem->allocation == VIR_DOMAIN_MEMORY_ALLOCATION_ONDEMAND) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("hugepages are not allowed with memory " - "allocation ondemand")); - return -1; - } - - if (mem->source == VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("hugepages are not allowed with anonymous " - "memory source")); - return -1; - } - for (i = 0; i < mem->nhugepages; i++) { size_t j; ssize_t nextBit; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 15325aa4c1..e12f05f9d1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3953,18 +3953,35 @@ static int qemuDomainDefValidateMemory(const virDomainDef *def) { const long system_page_size = virGetSystemPageSizeKB(); + const virDomainMemtune *mem = &def->mem; + + if (mem->nhugepages == 0) + return 0; + + if (mem->allocation == VIR_DOMAIN_MEMORY_ALLOCATION_ONDEMAND) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("hugepages are not allowed with memory " + "allocation ondemand")); + return -1; + } + + if (mem->source == VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("hugepages are not allowed with anonymous " + "memory source")); + return -1; + } /* We can't guarantee any other mem.access * if no guest NUMA nodes are defined. */ - if (def->mem.nhugepages != 0 && - def->mem.hugepages[0].size != system_page_size && + if (mem->hugepages[0].size != system_page_size && virDomainNumaGetNodeCount(def->numa) == 0 && - def->mem.access != VIR_DOMAIN_MEMORY_ACCESS_DEFAULT && - def->mem.access != VIR_DOMAIN_MEMORY_ACCESS_PRIVATE) { + mem->access != VIR_DOMAIN_MEMORY_ACCESS_DEFAULT && + mem->access != VIR_DOMAIN_MEMORY_ACCESS_PRIVATE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("memory access mode '%s' not supported " "without guest numa node"), - virDomainMemoryAccessTypeToString(def->mem.access)); + virDomainMemoryAccessTypeToString(mem->access)); return -1; }