[libvirt] [PATCH 4/7] qemu: qemuDomainHotplugVcpus - separate out the del cgroup and pin

John Ferlan jferlan at redhat.com
Thu Mar 19 17:08:25 UTC 2015


Impending 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 at 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 b7ddca3..673b95e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4670,6 +4670,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)
@@ -4825,19 +4849,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




More information about the libvir-list mailing list