qemuDomainHelperGetVcpus(virDomainObjPtr vm, virVcpuInfoPtr info, int maxinfo,
unsigned char *cpumaps, int maplen)
{
- int maxcpu, hostcpus;
+ int hostcpus;
size_t i, v;
qemuDomainObjPrivatePtr priv = vm->privateData;
return -1;
}
- maxcpu = maplen * 8;
- if (maxcpu > hostcpus)
- maxcpu = hostcpus;
-
/* Clamp to actual number of vcpus */
if (maxinfo > priv->nvcpupids)
maxinfo = priv->nvcpupids;
}
if (cpumaps != NULL) {
- memset(cpumaps, 0, maplen * maxinfo);
for (v = 0; v < maxinfo; v++) {
unsigned char *cpumap = VIR_GET_CPUMAP(cpumaps, maplen, v);
virBitmapPtr map = NULL;
- unsigned char *tmpmap = NULL;
- int tmpmapLen = 0;
if (virProcessGetAffinity(priv->vcpupids[v],
- &map, maxcpu) < 0)
+ &map, hostcpus) < 0)
return -1;
- if (virBitmapToData(map, &tmpmap, &tmpmapLen) < 0) {
- virBitmapFree(map);
- return -1;
- }
- if (tmpmapLen > maplen)
- tmpmapLen = maplen;
- memcpy(cpumap, tmpmap, tmpmapLen);
- VIR_FREE(tmpmap);
+ virBitmapToDataBuf(map, cpumap, maplen);
virBitmapFree(map);
}
}