From cdf82cdb98aa1eb1f67c189251a2a54af38a92e0 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 3 Mar 2023 13:11:51 +0100 Subject: [PATCH] testutilsqemu: Introduce ARG_QEMU_CAPS_DEL, to mask out flags from real caps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- tests/testutilsqemu.c | 12 ++++++++++++ tests/testutilsqemu.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index d3b5067f64..08ee2f91f6 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -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); } 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;