]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: don't pin all the cpus
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 4 Sep 2012 13:26:46 +0000 (15:26 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Wed, 5 Sep 2012 17:25:10 +0000 (19:25 +0200)
This is another fix for the emulator-pin series. When going through
the cputune pinning settings, the current code is trying to pin all
the CPUs, even when not all of them are specified. This causes error
in the subsequent function which, of course, cannot find the cpu to
pin. Since it's enough to pass the correct VCPU ID to the function,
the fix is trivial.

src/qemu/qemu_cgroup.c

index 7298e2872939a28aa245016d0025adc89f81d2c7..5b4279302f0259ae4579db1c80210a424f9a8a25 100644 (file)
@@ -542,7 +542,7 @@ int qemuSetupCgroupForVcpu(struct qemud_driver *driver, virDomainObjPtr vm)
     qemuDomainObjPrivatePtr priv = vm->privateData;
     virDomainDefPtr def = vm->def;
     int rc;
-    unsigned int i;
+    unsigned int i, j;
     unsigned long long period = vm->def->cputune.period;
     long long quota = vm->def->cputune.quota;
 
@@ -603,13 +603,22 @@ int qemuSetupCgroupForVcpu(struct qemud_driver *driver, virDomainObjPtr vm)
         }
 
         /* Set vcpupin in cgroup if vcpupin xml is provided */
-        if (def->cputune.nvcpupin &&
-            qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET) &&
-            qemuSetupCgroupVcpuPin(cgroup_vcpu,
-                                   def->cputune.vcpupin,
-                                   def->cputune.nvcpupin,
-                                   i) < 0)
-            goto cleanup;
+        if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET)) {
+            /* find the right CPU to pin, otherwise
+             * qemuSetupCgroupVcpuPin will fail. */
+            for (j = 0; j < def->cputune.nvcpupin; j++) {
+                if (def->cputune.vcpupin[j]->vcpuid != i)
+                    continue;
+
+                if (qemuSetupCgroupVcpuPin(cgroup_vcpu,
+                                           def->cputune.vcpupin,
+                                           def->cputune.nvcpupin,
+                                           i) < 0)
+                    goto cleanup;
+
+                break;
+            }
+        }
 
         virCgroupFree(&cgroup_vcpu);
     }