From 97a1d94fa0b6282ae88c77eb8b6b8c3bafaa6e22 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Thu, 19 Mar 2015 09:46:09 -0400 Subject: [PATCH] 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 --- src/qemu/qemu_driver.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 27616e21eb..7eb5a7d5d4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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,15 +4842,9 @@ 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) - goto cleanup; - - /* Remove cgroup for the offlined vcpu */ - virCgroupRemove(cgroup_vcpu); - virCgroupFree(&cgroup_vcpu); - } + if (qemuDomainDelCgroupForThread(priv->cgroup, + VIR_CGROUP_THREAD_VCPU, i) < 0) + goto cleanup; /* Free vcpupin setting */ virDomainPinDel(&vm->def->cputune.vcpupin,