[PATCH v2 04/17] add function bitmapFromBytemap() to convert bytemap to bitmap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 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 851284a..0dafb9e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10791,36 +10791,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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]