mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
qemu: Refactor bitmap handling in qemuDomainPinVcpuFlags
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.
This commit is contained in:
parent
475c530cd3
commit
4a39149b69
@ -4980,6 +4980,7 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
|
|||||||
virQEMUDriverConfigPtr cfg,
|
virQEMUDriverConfigPtr cfg,
|
||||||
virBitmapPtr cpumap)
|
virBitmapPtr cpumap)
|
||||||
{
|
{
|
||||||
|
virBitmapPtr tmpmap = NULL;
|
||||||
virDomainVcpuInfoPtr vcpuinfo;
|
virDomainVcpuInfoPtr vcpuinfo;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virCgroupPtr cgroup_vcpu = NULL;
|
virCgroupPtr cgroup_vcpu = NULL;
|
||||||
@ -5004,6 +5005,12 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(tmpmap = virBitmapNewCopy(cpumap)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (!(str = virBitmapFormat(cpumap)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (vcpuinfo->online) {
|
if (vcpuinfo->online) {
|
||||||
/* Configure the corresponding cpuset cgroup before set affinity. */
|
/* Configure the corresponding cpuset cgroup before set affinity. */
|
||||||
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
|
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
|
||||||
@ -5019,8 +5026,8 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virBitmapFree(vcpuinfo->cpumask);
|
virBitmapFree(vcpuinfo->cpumask);
|
||||||
vcpuinfo->cpumask = cpumap;
|
vcpuinfo->cpumask = tmpmap;
|
||||||
cpumap = NULL;
|
tmpmap = NULL;
|
||||||
|
|
||||||
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
|
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -5030,7 +5037,6 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
str = virBitmapFormat(vcpuinfo->cpumask);
|
|
||||||
if (virTypedParamsAddString(&eventParams, &eventNparams,
|
if (virTypedParamsAddString(&eventParams, &eventNparams,
|
||||||
&eventMaxparams, paramField, str) < 0)
|
&eventMaxparams, paramField, str) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -5040,7 +5046,7 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virBitmapFree(cpumap);
|
virBitmapFree(tmpmap);
|
||||||
virCgroupFree(&cgroup_vcpu);
|
virCgroupFree(&cgroup_vcpu);
|
||||||
VIR_FREE(str);
|
VIR_FREE(str);
|
||||||
qemuDomainEventQueue(driver, event);
|
qemuDomainEventQueue(driver, event);
|
||||||
@ -5062,9 +5068,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
|||||||
virDomainDefPtr persistentDef;
|
virDomainDefPtr persistentDef;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virBitmapPtr pcpumap = NULL;
|
virBitmapPtr pcpumap = NULL;
|
||||||
virBitmapPtr pcpumaplive = NULL;
|
virDomainVcpuInfoPtr vcpuinfo = NULL;
|
||||||
virBitmapPtr pcpumappersist = NULL;
|
|
||||||
virDomainVcpuInfoPtr vcpuinfopersist = NULL;
|
|
||||||
virQEMUDriverConfigPtr cfg = NULL;
|
virQEMUDriverConfigPtr cfg = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
|
||||||
@ -5085,7 +5089,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (persistentDef &&
|
if (persistentDef &&
|
||||||
!(vcpuinfopersist = virDomainDefGetVcpu(persistentDef, vcpu))) {
|
!(vcpuinfo = virDomainDefGetVcpu(persistentDef, vcpu))) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("vcpu %d is out of range of persistent cpu count %d"),
|
_("vcpu %d is out of range of persistent cpu count %d"),
|
||||||
vcpu, virDomainDefGetVcpus(persistentDef));
|
vcpu, virDomainDefGetVcpus(persistentDef));
|
||||||
@ -5101,23 +5105,14 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((def && !(pcpumaplive = virBitmapNewCopy(pcpumap))) ||
|
if (def &&
|
||||||
(persistentDef && !(pcpumappersist = virBitmapNewCopy(pcpumap))))
|
qemuDomainPinVcpuLive(vm, def, vcpu, driver, cfg, pcpumap) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (def) {
|
|
||||||
if (qemuDomainPinVcpuLive(vm, def, vcpu, driver, cfg, pcpumaplive) < 0) {
|
|
||||||
pcpumaplive = NULL;
|
|
||||||
goto endjob;
|
|
||||||
}
|
|
||||||
|
|
||||||
pcpumaplive = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (persistentDef) {
|
if (persistentDef) {
|
||||||
virBitmapFree(vcpuinfopersist->cpumask);
|
virBitmapFree(vcpuinfo->cpumask);
|
||||||
vcpuinfopersist->cpumask = pcpumappersist;
|
vcpuinfo->cpumask = pcpumap;
|
||||||
pcpumappersist = NULL;
|
pcpumap = NULL;
|
||||||
|
|
||||||
ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef);
|
ret = virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef);
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -5131,8 +5126,6 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
|||||||
cleanup:
|
cleanup:
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
virBitmapFree(pcpumap);
|
virBitmapFree(pcpumap);
|
||||||
virBitmapFree(pcpumaplive);
|
|
||||||
virBitmapFree(pcpumappersist);
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user