conf: numa: Format <numatune> XML only if necessary

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.
This commit is contained in:
Peter Krempa 2015-02-16 14:17:41 +01:00
parent 638e3d270f
commit 121cde4726

View 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);