[PATCH 09/35] libxl: Unbreak vcpu pinning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Libxl's vcpu pinning would work only if the vcpu array was ordered and
was not sparse. Remove the condition and iterate the pinning array
properly.
---
 src/libxl/libxl_domain.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 89782c3..632e5aa 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -794,28 +794,26 @@ int
 libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
 {
     libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
-    virDomainDefPtr def = vm->def;
+    virDomainPinDefPtr pin;
     libxl_bitmap map;
     virBitmapPtr cpumask = NULL;
     virNodeInfo nodeinfo;
-    int vcpu;
+    size_t i;
     int ret = -1;

     if (libxlDriverNodeGetInfo(driver, &nodeinfo) < 0)
         goto cleanup;

-    for (vcpu = 0; vcpu < def->cputune.nvcpupin; ++vcpu) {
-        if (vcpu != def->cputune.vcpupin[vcpu]->id)
-            continue;
-
-        cpumask = def->cputune.vcpupin[vcpu]->cpumask;
+    for (i = 0; i < vm->def->cputune.nvcpupin; ++i) {
+        pin = vm->def->cputune.vcpupin[i];
+        cpumask = pin->cpumask;

         if (virBitmapToData(cpumask, &map.map, (int *)&map.size) < 0)
             goto cleanup;

-        if (libxl_set_vcpuaffinity(cfg->ctx, def->id, vcpu, &map) != 0) {
+        if (libxl_set_vcpuaffinity(cfg->ctx, vm->def->id, pin->id, &map) != 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Failed to pin vcpu '%d' with libxenlight"), vcpu);
+                           _("Failed to pin vcpu '%d' with libxenlight"), pin->id);
             goto cleanup;
         }

-- 
2.4.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]