testutilsqemu: Introduce ARG_QEMU_CAPS_DEL, to mask out flags from real caps

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>
This commit is contained in:
Peter Krempa 2023-03-03 13:11:51 +01:00
parent ce79cf6ab4
commit cdf82cdb98
2 changed files with 14 additions and 0 deletions

View 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);
}

View 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;