[PATCH 1/3] tools/libxl: don't rely on xc_vcpu_setaffinity() returned cpumaps

Juergen Gross posted 3 patches 1 month, 1 week ago
[PATCH 1/3] tools/libxl: don't rely on xc_vcpu_setaffinity() returned cpumaps
Posted by Juergen Gross 1 month, 1 week ago
In order to prepare for XEN_DOMCTL_setvcpuaffinity no longer returning
the effective affinity settings, use xc_vcpu_getaffinity() for getting
the effective affinities after having set them.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/libs/light/libxl_sched.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/libs/light/libxl_sched.c b/tools/libs/light/libxl_sched.c
index 2d6635dae7..2f6a70aef5 100644
--- a/tools/libs/light/libxl_sched.c
+++ b/tools/libs/light/libxl_sched.c
@@ -69,6 +69,15 @@ static int libxl__set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid,
      * is possible that Xen will use something different from what we asked
      * for various reasons. If that's the case, report it.
      */
+    if ((cpumap_hard || cpumap_soft) &&
+        xc_vcpu_getaffinity(ctx->xch, domid, vcpuid,
+                            cpumap_hard ? hard.map : NULL,
+                            cpumap_soft ? soft.map : NULL,
+                            flags & ~XEN_VCPUAFFINITY_FORCE)) {
+        LOGED(ERROR, domid, "Checking vcpu affinity");
+        rc = ERROR_FAIL;
+        goto out;
+    }
     if (cpumap_hard &&
         !libxl_bitmap_equal(cpumap_hard, &hard, 0))
         LOGD(DEBUG, domid, "New hard affinity for vcpu %d has unreachable cpus", vcpuid);
-- 
2.54.0