Now that the function was extracted we can get rid of some temp
variables. Additionally formatting of the bitmap string for the event
code should be checked.
---
src/qemu/qemu_driver.c | 39 +++++++++++++++++----------------------
1 file changed, 17 insertions(+), 22 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index cab69a5..b6c9ab3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4974,6 +4974,7 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
virQEMUDriverConfigPtr cfg,
virBitmapPtr cpumap)
{
+ virBitmapPtr tmpmap = NULL;
virDomainVcpuInfoPtr vcpuinfo;
qemuDomainObjPrivatePtr priv = vm->privateData;
virCgroupPtr cgroup_vcpu = NULL;
@@ -4998,6 +4999,12 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
goto cleanup;
}
+ if (!(tmpmap = virBitmapNewCopy(cpumap)))
+ goto cleanup;
+
+ if (!(str = virBitmapFormat(cpumap)))
+ goto cleanup;
+
if (vcpuinfo->online) {
/* Configure the corresponding cpuset cgroup before set affinity. */
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
@@ -5013,8 +5020,8 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
}
virBitmapFree(vcpuinfo->cpumask);
- vcpuinfo->cpumask = cpumap;
- cpumap = NULL;
+ vcpuinfo->cpumask = tmpmap;
+ tmpmap = NULL;
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps)
< 0)
goto cleanup;
@@ -5024,7 +5031,6 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
goto cleanup;
}
- str = virBitmapFormat(vcpuinfo->cpumask);
if (virTypedParamsAddString(&eventParams, &eventNparams,
&eventMaxparams, paramField, str) < 0)
goto cleanup;
@@ -5034,7 +5040,7 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
ret = 0;
cleanup:
- virBitmapFree(cpumap);
+ virBitmapFree(tmpmap);
virCgroupFree(&cgroup_vcpu);
VIR_FREE(str);
qemuDomainEventQueue(driver, event);
@@ -5056,9 +5062,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
virDomainDefPtr persistentDef;
int ret = -1;
virBitmapPtr pcpumap = NULL;
- virBitmapPtr pcpumaplive = NULL;
- virBitmapPtr pcpumappersist = NULL;
- virDomainVcpuInfoPtr vcpuinfopersist = NULL;
+ virDomainVcpuInfoPtr vcpuinfo = NULL;
virQEMUDriverConfigPtr cfg = NULL;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
@@ -5079,7 +5083,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
goto endjob;
if (persistentDef &&
- !(vcpuinfopersist = virDomainDefGetVcpu(persistentDef, vcpu))) {
+ !(vcpuinfo = virDomainDefGetVcpu(persistentDef, vcpu))) {
virReportError(VIR_ERR_INVALID_ARG,
_("vcpu %d is out of range of persistent cpu count
%d"),
vcpu, virDomainDefGetVcpus(persistentDef));
@@ -5095,21 +5099,14 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
goto endjob;
}
- if ((def && !(pcpumaplive = virBitmapNewCopy(pcpumap))) ||
- (persistentDef && !(pcpumappersist = virBitmapNewCopy(pcpumap))))
+ if (def &&
+ qemuDomainPinVcpuLive(vm, def, vcpu, driver, cfg, pcpumap) < 0)
goto endjob;
- if (def) {
- if (qemuDomainPinVcpuLive(vm, def, vcpu, driver, cfg, pcpumaplive) < 0)
- goto endjob;
-
- pcpumaplive = NULL;
- }
-
if (persistentDef) {
- virBitmapFree(vcpuinfopersist->cpumask);
- vcpuinfopersist->cpumask = pcpumappersist;
- pcpumappersist = NULL;
+ virBitmapFree(vcpuinfo->cpumask);
+ vcpuinfo->cpumask = pcpumap;
+ pcpumap = NULL;
ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef);
goto endjob;
@@ -5123,8 +5120,6 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
cleanup:
virDomainObjEndAPI(&vm);
virBitmapFree(pcpumap);
- virBitmapFree(pcpumaplive);
- virBitmapFree(pcpumappersist);
virObjectUnref(cfg);
return ret;
}
--
2.6.2