/* Number of vcpus able to run on the cpus of the various nodes
* (reported by filling the array vcpus_on_node[]). */
static int nr_vcpus_on_nodes(libxl__gc *gc, libxl_cputopology *tinfo,
+ size_t tinfo_elements,
const libxl_bitmap *suitable_cpumap,
int vcpus_on_node[])
{
*/
libxl_bitmap_set_none(&nodes_counted);
libxl_for_each_set_bit(k, vinfo[j].cpumap) {
+ if (k >= tinfo_elements)
+ break;
int node = tinfo[k].node;
if (libxl_bitmap_test(suitable_cpumap, k) &&
* all we have to do later is summing up the right elements of the
* vcpus_on_node array.
*/
- rc = nr_vcpus_on_nodes(gc, tinfo, suitable_cpumap, vcpus_on_node);
+ rc = nr_vcpus_on_nodes(gc, tinfo, nr_cpus, suitable_cpumap, vcpus_on_node);
if (rc)
goto out;
}
libxl_bitmap_set_none(nodemap);
- libxl_for_each_set_bit(i, *cpumap)
+ libxl_for_each_set_bit(i, *cpumap) {
+ if (i >= nr_cpus)
+ break;
libxl_bitmap_set(nodemap, tinfo[i].node);
+ }
out:
libxl_cputopology_list_free(tinfo, nr_cpus);
return rc;