if (rc)
goto out;
- libxl_bitmap_copy(ctx, &hard, cpumap_hard);
+ libxl__bitmap_copy_best_effort(gc, &hard, cpumap_hard);
flags = XEN_VCPUAFFINITY_HARD;
}
if (cpumap_soft) {
if (rc)
goto out;
- libxl_bitmap_copy(ctx, &soft, cpumap_soft);
+ libxl__bitmap_copy_best_effort(gc, &soft, cpumap_soft);
flags |= XEN_VCPUAFFINITY_SOFT;
}
libxl_device_##type##_copy(CTX, DA_p, (dev)); \
})
+/* This function copies X bytes from source to destination bitmap,
+ * where X is the smaller of the two sizes.
+ *
+ * If destination's size is larger than source, the extra bytes are
+ * untouched.
+ *
+ * XXX This is introduced to fix a regression for 4.5. It shall
+ * be revisited in 4.6 time frame.
+ */
+void libxl__bitmap_copy_best_effort(libxl__gc *gc, libxl_bitmap *dptr,
+ const libxl_bitmap *sptr);
#endif
/*
memcpy(dptr->map, sptr->map, sz * sizeof(*dptr->map));
}
+/* This function copies X bytes from source to destination bitmap,
+ * where X is the smaller of the two sizes.
+ *
+ * If destination's size is larger than source, the extra bytes are
+ * untouched.
+ */
+void libxl__bitmap_copy_best_effort(libxl__gc *gc, libxl_bitmap *dptr,
+ const libxl_bitmap *sptr)
+{
+ int sz;
+
+ sz = dptr->size < sptr->size ? dptr->size : sptr->size;
+ memcpy(dptr->map, sptr->map, sz * sizeof(*dptr->map));
+}
+
void libxl_bitmap_copy_alloc(libxl_ctx *ctx,
libxl_bitmap *dptr,
const libxl_bitmap *sptr)