]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
testutilsqemu: Introduce ARG_QEMU_CAPS_DEL, to mask out flags from real caps
authorPeter Krempa <pkrempa@redhat.com>
Fri, 3 Mar 2023 12:11:51 +0000 (13:11 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 6 Mar 2023 19:55:50 +0000 (20:55 +0100)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/testutilsqemu.c
tests/testutilsqemu.h

index d3b5067f64799faa0bab75524573fa52cfe122da..08ee2f91f68c12ac84e25fece7a90c0377484a4f 100644 (file)
@@ -903,6 +903,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;
@@ -1052,6 +1060,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;
@@ -1069,6 +1080,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);
 }
 
index f272e6d41d4bc03a85fafbe7cb5ccee279411bec..11bdd2fd2f7300eeb0c52a48f89bc329cf2fa139 100644 (file)
@@ -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;