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(a)redhat.com>
---
src/qemu/qemu_driver.c | 40 ++++++++++++++++++++++++++++------------
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fa880b7..5dc1ad4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4675,6 +4675,30 @@ qemuDomainHotplugAddCgroup(virCgroupPtr cgroup,
}
static int
+qemuDomainHotplugDelCgroupPin(virCgroupPtr cgroup,
+ cgroupNewFunc func,
+ int index,
+ virDomainPinDefPtr **pindef_list,
+ size_t *npin)
+{
+ virCgroupPtr new_cgroup = NULL;
+
+ if (cgroup) {
+ if (func(cgroup, index, false, &new_cgroup) < 0)
+ return -1;
+
+ /* Remove the offlined cgroup */
+ virCgroupRemove(new_cgroup);
+ virCgroupFree(&new_cgroup);
+ }
+
+ /* Free pindef setting */
+ virDomainPinDel(pindef_list, npin, index);
+
+ return 0;
+}
+
+static int
qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
virDomainObjPtr vm,
unsigned int nvcpus)
@@ -4827,19 +4851,11 @@ qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
}
} else {
for (i = oldvcpus - 1; i >= nvcpus; i--) {
- if (priv->cgroup) {
- if (virCgroupNewVcpu(priv->cgroup, i, false, &cgroup_vcpu) <
0)
- goto cleanup;
-
- /* Remove cgroup for the offlined vcpu */
- virCgroupRemove(cgroup_vcpu);
- virCgroupFree(&cgroup_vcpu);
- }
+ if (qemuDomainHotplugDelCgroupPin(priv->cgroup, virCgroupNewVcpu, i,
+ &vm->def->cputune.vcpupin,
+ &vm->def->cputune.nvcpupin) <
0)
+ goto cleanup;
- /* Free vcpupin setting */
- virDomainPinDel(&vm->def->cputune.vcpupin,
- &vm->def->cputune.nvcpupin,
- i);
}
}
--
2.1.0