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

[libvirt] [PATCH 09/35] libxl: Unbreak vcpu pinning



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


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