[PATCH 1/3] virQEMUBuildCommandLineJSONArrayBitmap: Open code bitmap conversion

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

 



Add a simpler algorithm converting the JSON array to bitmap so that
virJSONValueGetArrayAsBitmap can be removed in next step.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/util/virqemu.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/util/virqemu.c b/src/util/virqemu.c
index a1f57dea66..4d432651ee 100644
--- a/src/util/virqemu.c
+++ b/src/util/virqemu.c
@@ -28,6 +28,7 @@
 #include "virqemu.h"
 #include "virstring.h"
 #include "viralloc.h"
+#include "virbitmap.h"

 #define VIR_FROM_THIS VIR_FROM_NONE

@@ -59,10 +60,19 @@ virQEMUBuildCommandLineJSONArrayBitmap(const char *key,
 {
     ssize_t pos = -1;
     ssize_t end;
-    g_autoptr(virBitmap) bitmap = NULL;
+    g_autoptr(virBitmap) bitmap = virBitmapNew(0);
+    size_t i;

-    if (virJSONValueGetArrayAsBitmap(array, &bitmap) < 0)
-        return -1;
+    for (i = 0; i < virJSONValueArraySize(array); i++) {
+        virJSONValue *member = virJSONValueArrayGet(array, i);
+        unsigned long long value;
+
+        if (virJSONValueGetNumberUlong(member, &value) < 0)
+            return -1;
+
+        if (virBitmapSetBitExpand(bitmap, value) < 0)
+            return -1;
+    }

     while ((pos = virBitmapNextSetBit(bitmap, pos)) > -1) {
         if ((end = virBitmapNextClearBit(bitmap, pos)) < 0)
-- 
2.30.2




[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]

  Powered by Linux