[PATCH 11/24] conf: numa: Refactor logic in virDomainNumatuneParseXML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Shuffling around the logic will allow to simplify the code quite a bit.
As an additional bonus the change in the logic now reports an error if
automatic placement is selected and individual placement is configured.
---
 src/conf/numa_conf.c | 53 +++++++++++++++++++++-------------------------------
 1 file changed, 21 insertions(+), 32 deletions(-)

diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
index 18c21d5..d5ba27f 100644
--- a/src/conf/numa_conf.c
+++ b/src/conf/numa_conf.c
@@ -229,42 +229,31 @@ virDomainNumatuneParseXML(virDomainNumaPtr *numatunePtr,
         *numatunePtr = NULL;
     }

-    if (!node && placement_static) {
-        if (virDomainNumatuneNodeParseXML(numatunePtr, ncells, ctxt) < 0)
-            goto cleanup;
-        return 0;
-    }
+    if (!placement_static && !node)
+        placement = VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO;

-    if (!node) {
-        /* We know that placement_mode is "auto" if we're here */
-        ret = virDomainNumatuneSet(numatunePtr,
-                                   placement_static,
-                                   VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO,
-                                   -1,
-                                   NULL);
-        goto cleanup;
-    }
+    if (node) {
+        if ((tmp = virXMLPropString(node, "mode")) &&
+            (mode = virDomainNumatuneMemModeTypeFromString(tmp)) < 0) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("Unsupported NUMA memory tuning mode '%s'"), tmp);
+            goto cleanup;
+        }
+        VIR_FREE(tmp);

-    if ((tmp = virXMLPropString(node, "mode")) &&
-        (mode = virDomainNumatuneMemModeTypeFromString(tmp)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Unsupported NUMA memory tuning mode '%s'"), tmp);
-        goto cleanup;
-    }
-    VIR_FREE(tmp);
+        if ((tmp = virXMLPropString(node, "placement")) &&
+            (placement = virDomainNumatunePlacementTypeFromString(tmp)) < 0) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("Unsupported NUMA memory placement mode '%s'"), tmp);
+            goto cleanup;
+        }
+        VIR_FREE(tmp);

-    if ((tmp = virXMLPropString(node, "placement")) &&
-        (placement = virDomainNumatunePlacementTypeFromString(tmp)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Unsupported NUMA memory placement mode '%s'"), tmp);
-        goto cleanup;
+        if ((tmp = virXMLPropString(node, "nodeset")) &&
+            virBitmapParse(tmp, 0, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0)
+            goto cleanup;
+        VIR_FREE(tmp);
     }
-    VIR_FREE(tmp);
-
-    if ((tmp = virXMLPropString(node, "nodeset")) &&
-        virBitmapParse(tmp, 0, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0)
-        goto cleanup;
-    VIR_FREE(tmp);

     if (virDomainNumatuneSet(numatunePtr,
                              placement_static,
-- 
2.2.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]