[PATCH 22/31] testutilsqemu: Introduce ARG_QEMU_CAPS_DEL, to mask out flags from real caps

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

 



In certain cases we want to use as-real capabilities as possible but
that doesn't allow testing certain fallback scenarios of features that
can be complied out of QEMU.

ARG_QEMU_CAPS_DEL can be used similarly to ARG_QEMU_CAPS but the flag
arguments are actually masked out of the resulting caps.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tests/testutilsqemu.c | 12 ++++++++++++
 tests/testutilsqemu.h |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 55de4bcdc6..54fa347d18 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -851,6 +851,14 @@ testQemuInfoSetArgs(struct testQemuInfo *info,
                 ignore_value(virBitmapSetBit(info->args.fakeCapsAdd, flag));
             break;

+        case ARG_QEMU_CAPS_DEL:
+            if (!(info->args.fakeCapsDel))
+                info->args.fakeCapsDel = virBitmapNew(QEMU_CAPS_LAST);
+
+            while ((flag = va_arg(argptr, int)) < QEMU_CAPS_LAST)
+                ignore_value(virBitmapSetBit(info->args.fakeCapsDel, flag));
+            break;
+
         case ARG_GIC:
             info->args.gic = va_arg(argptr, int);
             break;
@@ -1000,6 +1008,9 @@ testQemuInfoInitArgs(struct testQemuInfo *info)
     for (cap = -1; (cap = virBitmapNextSetBit(info->args.fakeCapsAdd, cap)) >= 0;)
         virQEMUCapsSet(info->qemuCaps, cap);

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

diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h
index f272e6d41d..11bdd2fd2f 100644
--- a/tests/testutilsqemu.h
+++ b/tests/testutilsqemu.h
@@ -43,6 +43,7 @@ typedef enum {

 typedef enum {
     ARG_QEMU_CAPS = QEMU_CAPS_LAST + 1,
+    ARG_QEMU_CAPS_DEL,
     ARG_GIC,
     ARG_MIGRATE_FROM,
     ARG_MIGRATE_FD,
@@ -82,6 +83,7 @@ typedef enum {
 struct testQemuArgs {
     bool newargs;
     virBitmap *fakeCapsAdd;
+    virBitmap *fakeCapsDel;
     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