From: Peter Krempa Date: Mon, 16 Feb 2015 13:17:41 +0000 (+0100) Subject: conf: numa: Format XML only if necessary X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=121cde472640cddcc64d2c06a607bb35bf9ae032;p=people%2Fliuw%2Flibxenctrl-split%2Flibvirt.git conf: numa: Format XML only if necessary Do a content-aware check if formatting of the 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. --- diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index d86ac99a6..9b48fb87e 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -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, "\n"); virBufferAdjustIndent(buf, 2);