diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c5166852769d252fabec58dd64c683f35786f379..d2b028411582fc62e1be26bb5a7311440e1589e7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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) {