]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Move hypervisor specific nhugepage checks
authorJohn Ferlan <jferlan@redhat.com>
Tue, 11 Sep 2018 12:46:46 +0000 (08:46 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 12 Sep 2018 16:21:05 +0000 (12:21 -0400)
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 <jferlan@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
src/conf/domain_conf.c
src/qemu/qemu_domain.c

index b241b7ae771e95b71f5b6a31a979e24c5fb39ae0..409a2291ffa36de07685334f0316f4e978a5e340 100644 (file)
@@ -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;
index 15325aa4c1f67e7c471c8596cc09f776358689ef..e12f05f9d172dcabe98df8d542e95741f3defc22 100644 (file)
@@ -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;
     }