---
src/conf/domain_conf.c | 39 +++++++++++++++++++++++++--------------
1 file changed, 25 insertions(+), 14 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c9f5a3c..4e52177 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10893,36 +10893,47 @@ virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def,
return NULL;
}
-int
-virDomainVcpuPinAdd(virDomainDefPtr def,
- unsigned char *cpumap,
- int maplen,
- int vcpu)
+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) {
--
1.7.10.2