From: Daniel P. Berrangé Date: Thu, 9 Dec 2021 14:57:05 +0000 (-0500) Subject: tests: allow setting extra capabilities on top of versioned caps X-Git-Tag: v8.0.0-rc1~126 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4efca76958df02c329ef54b714125c8883f0e50;p=thirdparty%2Flibvirt.git tests: allow setting extra capabilities on top of versioned caps In the QEMU tests a test can either use an explicitly listed set of capabilities, or can request those matching a particular QEMU version. Sometimes it is desirable to be able to list extra caps on top of those implied by a particular version. This is useful, for example, when QEMU won't report certain features unless it was run on particular hardware or kernels, and those were not used when a caps snapshot was imported to the libvirt source tree. Reviewed-by: Peter Krempa Signed-off-by: Daniel P. Berrangé --- diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 7b19575d8b..7fdb82daec 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -772,11 +772,6 @@ testQemuInfoInitArgs(struct testQemuInfo *info) bool stripmachinealiases = false; virQEMUCaps *cachedcaps = NULL; - if (info->args.fakeCapsUsed) { - fprintf(stderr, "ARG_QEMU_CAPS can not be combined with ARG_CAPS_ARCH or ARG_CAPS_VER\n"); - return -1; - } - info->arch = virArchFromString(info->args.capsarch); if (STREQ(info->args.capsver, "latest")) { @@ -805,6 +800,16 @@ testQemuInfoInitArgs(struct testQemuInfo *info) if (!(info->qemuCaps = virQEMUCapsNewCopy(cachedcaps))) return -1; + 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);