From a4efca76958df02c329ef54b714125c8883f0e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Thu, 9 Dec 2021 09:57:05 -0500 Subject: [PATCH] tests: allow setting extra capabilities on top of versioned caps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é --- tests/testutilsqemu.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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);