- unsigned char *cpumaps = calloc(nr_virt_cpu, cpu_map_len);
- if (cpumaps == NULL) {
- ERROR(PLUGIN_NAME " plugin: calloc failed.");
- sfree(vinfo);
- return -1;
+ int cpu_map_len = 0;
+ unsigned char *cpumaps = NULL;
+ if (extra_stats & ex_stats_vcpupin) {
+ cpu_map_len = VIR_CPU_MAPLEN(max_cpus);
+ cpumaps = calloc(nr_virt_cpu, cpu_map_len);
+
+ if (cpumaps == NULL) {
+ ERROR(PLUGIN_NAME " plugin: calloc failed.");
+ sfree(vinfo);
+ return -1;
+ }