]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: numa: Format <numatune> XML only if necessary
authorPeter Krempa <pkrempa@redhat.com>
Mon, 16 Feb 2015 13:17:41 +0000 (14:17 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 20 Feb 2015 16:43:04 +0000 (17:43 +0100)
Do a content-aware check if formatting of the <numatune> element is
necessary. Later on the def->numa structure will be always present so we
cannot decide only on the basis whether it's allocated.

src/conf/numa_conf.c

index d86ac99a677eb25a6bc21f0db7b00b8fe9ec28e7..9b48fb87eaa6826bc312ce78a7813868b7d7e641 100644 (file)
@@ -278,11 +278,22 @@ virDomainNumatuneFormatXML(virBufferPtr buf,
 {
     const char *tmp = NULL;
     char *nodeset = NULL;
+    bool nodesetSpecified = false;
     size_t i = 0;
 
     if (!numatune)
         return 0;
 
+    for (i = 0; i < numatune->nmem_nodes; i++) {
+        if (numatune->mem_nodes[i].nodeset) {
+            nodesetSpecified = true;
+            break;
+        }
+    }
+
+    if (!nodesetSpecified && !numatune->memory.specified)
+        return 0;
+
     virBufferAddLit(buf, "<numatune>\n");
     virBufferAdjustIndent(buf, 2);