[libvirt] [PATCH 2/2] conf: Forbid hugepages and <allocation mode="ondemand"/>

Michal Privoznik mprivozn at redhat.com
Mon Oct 15 12:39:27 UTC 2018


https://bugzilla.redhat.com/show_bug.cgi?id=1633562

Under <memoryBacking/> we allow users to configure various memory
backing related knobs. However, there are some combinations that
make no sense. For instance, requesting hugepages and 'ondemand'
allocation at the same time. Forbid this configuration then.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/conf/domain_conf.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ef1d5caa1c..53cb4209d4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4064,13 +4064,22 @@ virDomainDefPostParseMemtune(virDomainDefPtr def)
         }
     }
 
-    if (def->mem.nhugepages &&
-        def->mem.source != VIR_DOMAIN_MEMORY_SOURCE_NONE &&
-        def->mem.source != VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       _("unsupported combination of hugepages and source type %s"),
-                       virDomainMemorySourceTypeToString(def->mem.source));
-        return -1;
+    if (def->mem.nhugepages) {
+        if (def->mem.source != VIR_DOMAIN_MEMORY_SOURCE_NONE &&
+            def->mem.source != VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("unsupported combination of hugepages and source type %s"),
+                           virDomainMemorySourceTypeToString(def->mem.source));
+            return -1;
+        }
+
+        if (def->mem.allocation != VIR_DOMAIN_MEMORY_ALLOCATION_NONE &&
+            def->mem.allocation != VIR_DOMAIN_MEMORY_ALLOCATION_IMMEDIATE) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("unsupported combination of hugepages and allocation %s"),
+                           virDomainMemoryAllocationTypeToString(def->mem.allocation));
+            return -1;
+        }
     }
 
     return 0;
-- 
2.18.1




More information about the libvir-list mailing list