qemu: qemuDomainHotplugVcpus - separate out the del cgroup and pin

Future IOThread setting patches would copy the code anyway, so create
and generalize a delete cgroup and pindef for the vcpu into its own API.

Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
John Ferlan 2015-03-19 09:46:09 -04:00
parent 0ed8e47a7e
commit 97a1d94fa0
1 changed files with 22 additions and 9 deletions

View File

@ -4669,6 +4669,25 @@ qemuDomainAddCgroupForThread(virCgroupPtr cgroup,
return NULL;
}
static int
qemuDomainDelCgroupForThread(virCgroupPtr cgroup,
virCgroupThreadName nameval,
int index)
{
virCgroupPtr new_cgroup = NULL;
if (cgroup) {
if (virCgroupNewThread(cgroup, nameval, index, false, &new_cgroup) < 0)
return -1;
/* Remove the offlined cgroup */
virCgroupRemove(new_cgroup);
virCgroupFree(&new_cgroup);
}
return 0;
}
static int
qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
virDomainObjPtr vm,
@ -4823,16 +4842,10 @@ qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
}
} else {
for (i = oldvcpus - 1; i >= nvcpus; i--) {
if (priv->cgroup) {
if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_VCPU, i,
false, &cgroup_vcpu) < 0)
if (qemuDomainDelCgroupForThread(priv->cgroup,
VIR_CGROUP_THREAD_VCPU, i) < 0)
goto cleanup;
/* Remove cgroup for the offlined vcpu */
virCgroupRemove(cgroup_vcpu);
virCgroupFree(&cgroup_vcpu);
}
/* Free vcpupin setting */
virDomainPinDel(&vm->def->cputune.vcpupin,
&vm->def->cputune.nvcpupin,