[PATCH 21/31] testutilsqemu: Rework setting of fake capabilities

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

 



Rather that populate a virQEMUCaps object we now populate a bitmap with
the fake capabilities and transfer it into the virQEMUCaps later.

This unifies the code paths between the fully fake caps tests and real
caps + fake flags.

Also the same approach will be used in upcomming patch to add
possibility to mask out flags from real capabilities.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tests/testutilsqemu.c | 25 +++++++++----------------
 tests/testutilsqemu.h |  3 +--
 2 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 18a9ca5ee1..55de4bcdc6 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -837,8 +837,6 @@ testQemuInfoSetArgs(struct testQemuInfo *info,
     testQemuInfoArgName argname;
     int flag;

-    info->args.fakeCaps = virQEMUCapsNew();
-
     info->conf = conf;
     info->args.newargs = true;

@@ -846,10 +844,11 @@ testQemuInfoSetArgs(struct testQemuInfo *info,
     while ((argname = va_arg(argptr, testQemuInfoArgName)) != ARG_END) {
         switch (argname) {
         case ARG_QEMU_CAPS:
-            info->args.fakeCapsUsed = true;
+            if (!(info->args.fakeCapsAdd))
+                info->args.fakeCapsAdd = virBitmapNew(QEMU_CAPS_LAST);

             while ((flag = va_arg(argptr, int)) < QEMU_CAPS_LAST)
-                virQEMUCapsSet(info->args.fakeCaps, flag);
+                ignore_value(virBitmapSetBit(info->args.fakeCapsAdd, flag));
             break;

         case ARG_GIC:
@@ -938,6 +937,7 @@ int
 testQemuInfoInitArgs(struct testQemuInfo *info)
 {
     g_autofree char *capsfile = NULL;
+    ssize_t cap;

     if (!info->args.newargs)
         return 0;
@@ -985,16 +985,6 @@ testQemuInfoInitArgs(struct testQemuInfo *info)

         info->qemuCaps = virQEMUCapsNewCopy(cachedcaps);

-        if (info->args.fakeCapsUsed) {
-            size_t i;
-            for (i = 0; i < QEMU_CAPS_LAST; i++) {
-                if (virQEMUCapsGet(info->args.fakeCaps, i)) {
-                    virQEMUCapsSet(info->qemuCaps, i);
-                }
-            }
-        }
-
-
         if (stripmachinealiases)
             virQEMUCapsStripMachineAliases(info->qemuCaps);

@@ -1004,9 +994,12 @@ testQemuInfoInitArgs(struct testQemuInfo *info)
         capsfile[strlen(capsfile) - 3] = '\0';
         info->schemafile = g_strdup_printf("%sreplies", capsfile);
     } else {
-        info->qemuCaps = g_steal_pointer(&info->args.fakeCaps);
+        info->qemuCaps = virQEMUCapsNew();
     }

+    for (cap = -1; (cap = virBitmapNextSetBit(info->args.fakeCapsAdd, cap)) >= 0;)
+        virQEMUCapsSet(info->qemuCaps, cap);
+
     if (info->args.gic != GIC_NONE &&
         testQemuCapsSetGIC(info->qemuCaps, info->args.gic) < 0)
         return -1;
@@ -1023,7 +1016,7 @@ testQemuInfoClear(struct testQemuInfo *info)
     VIR_FREE(info->schemafile);
     VIR_FREE(info->errfile);
     virObjectUnref(info->qemuCaps);
-    g_clear_pointer(&info->args.fakeCaps, virObjectUnref);
+    g_clear_pointer(&info->args.fakeCapsAdd, virBitmapFree);
     g_clear_pointer(&info->args.fds, g_hash_table_unref);
 }

diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h
index 51c072cb13..f272e6d41d 100644
--- a/tests/testutilsqemu.h
+++ b/tests/testutilsqemu.h
@@ -81,8 +81,7 @@ typedef enum {

 struct testQemuArgs {
     bool newargs;
-    virQEMUCaps *fakeCaps;
-    bool fakeCapsUsed;
+    virBitmap *fakeCapsAdd;
     char *capsver;
     char *capsarch;
     qemuTestCPUDef capsHostCPUModel;
-- 
2.39.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