From 95d5601018752ee523ca48e7dafdc3931dfd66b0 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 12 Jul 2017 14:10:34 +0200 Subject: [PATCH] qemu: domain: Store and restore autoCpuset to status XML Decouple them by storing them in the XML separately rather than regenerating them. This will simplify upcoming fixes. --- src/qemu/qemu_domain.c | 37 +++++++++++++++++++++++++++++-------- tests/qemuxml2xmltest.c | 2 +- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 23d4b20359..ede761e6ef 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1765,20 +1765,30 @@ qemuDomainObjPtrivateXMLFormatAutomaticPlacement(virBufferPtr buf, qemuDomainObjPrivatePtr priv) { char *nodeset = NULL; + char *cpuset = NULL; int ret = -1; - if (!priv->autoNodeset) + if (!priv->autoNodeset && !priv->autoCpuset) return 0; - if (!(nodeset = virBitmapFormat(priv->autoNodeset))) + if (priv->autoNodeset && + !((nodeset = virBitmapFormat(priv->autoNodeset)))) goto cleanup; - virBufferAsprintf(buf, "\n", nodeset); + if (priv->autoCpuset && + !((cpuset = virBitmapFormat(priv->autoCpuset)))) + goto cleanup; + + virBufferAddLit(buf, "\n"); ret = 0; cleanup: VIR_FREE(nodeset); + VIR_FREE(cpuset); return ret; } @@ -1958,28 +1968,39 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(xmlXPathContextPtr ctxt, { virCapsPtr caps = NULL; char *nodeset; + char *cpuset; int ret = -1; nodeset = virXPathString("string(./numad/@nodeset)", ctxt); + cpuset = virXPathString("string(./numad/@cpuset)", ctxt); - if (!nodeset) + if (!nodeset && !cpuset) return 0; if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virBitmapParse(nodeset, &priv->autoNodeset, caps->host.nnumaCell_max) < 0) + if (nodeset && + virBitmapParse(nodeset, &priv->autoNodeset, caps->host.nnumaCell_max) < 0) goto cleanup; - if (!(priv->autoCpuset = virCapabilitiesGetCpusForNodemask(caps, - priv->autoNodeset))) - goto cleanup; + if (cpuset) { + if (virBitmapParse(cpuset, &priv->autoCpuset, VIR_DOMAIN_CPUMASK_LEN) < 0) + goto cleanup; + } else { + /* autoNodeset is present in this case, since otherwise we wouldn't + * reach this code */ + if (!(priv->autoCpuset = virCapabilitiesGetCpusForNodemask(caps, + priv->autoNodeset))) + goto cleanup; + } ret = 0; cleanup: virObjectUnref(caps); VIR_FREE(nodeset); + VIR_FREE(cpuset); return ret; } diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 5e4b1d17f6..bc222cf793 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -95,7 +95,7 @@ static const char testStatusXMLPrefixFooter[] = " \n" " \n" " \n" -" \n" +" \n" " \n" " \n";