提交 1fea5667 编写于 作者: H Hu Tao 提交者: Daniel Veillard

add function bitmapFromBytemap() to convert bytemap to bitmap

上级 4b03d591
......@@ -10935,36 +10935,47 @@ virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def,
return NULL;
}
int
virDomainVcpuPinAdd(virDomainDefPtr def,
unsigned char *cpumap,
int maplen,
int vcpu)
static char *bitmapFromBytemap(unsigned char *bytemap, int maplen)
{
virDomainVcpuPinDefPtr *vcpupin_list = NULL;
virDomainVcpuPinDefPtr vcpupin = NULL;
char *cpumask = NULL;
char *bitmap = NULL;
int i;
if (VIR_ALLOC_N(cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) {
if (VIR_ALLOC_N(bitmap, VIR_DOMAIN_CPUMASK_LEN) < 0) {
virReportOOMError();
goto cleanup;
}
/* Reset cpumask to all 0s. */
/* Reset bitmap to all 0s. */
for (i = 0; i < VIR_DOMAIN_CPUMASK_LEN; i++)
cpumask[i] = 0;
bitmap[i] = 0;
/* Convert bitmap (cpumap) to cpumask, which is byte map? */
/* Convert bitmap (bytemap) to bitmap, which is byte map? */
for (i = 0; i < maplen; i++) {
int cur;
for (cur = 0; cur < 8; cur++) {
if (cpumap[i] & (1 << cur))
cpumask[i * 8 + cur] = 1;
if (bytemap[i] & (1 << cur))
bitmap[i * 8 + cur] = 1;
}
}
cleanup:
return bitmap;
}
int
virDomainVcpuPinAdd(virDomainDefPtr def,
unsigned char *cpumap,
int maplen,
int vcpu)
{
virDomainVcpuPinDefPtr *vcpupin_list = NULL;
virDomainVcpuPinDefPtr vcpupin = NULL;
char *cpumask = NULL;
if ((cpumask = bitmapFromBytemap(cpumap, maplen)) == NULL)
goto cleanup;
/* No vcpupin exists yet. */
if (!def->cputune.nvcpupin) {
if (VIR_ALLOC(vcpupin) < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册