]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: qemuDomainHotplugVcpus - separate out the del cgroup and pin
authorJohn Ferlan <jferlan@redhat.com>
Thu, 19 Mar 2015 13:46:09 +0000 (09:46 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 9 Apr 2015 23:27:08 +0000 (19:27 -0400)
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>
src/qemu/qemu_driver.c

index 27616e21eb06e20e3c0ca367e6f47d765dcfa5d3..7eb5a7d5d4b4f6f9426adae1de0a043c85cffe90 100644 (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,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,