From 5810eb97ad5845d0df9dbfbd91799e2c7614e064 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 2 Mar 2023 17:59:09 +0100 Subject: [PATCH] qemuTestCapsCacheInsert*: Directly insert real capabilities MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Real capabilities populate the binary name, while fake don't. We can directly insert the capabilities using the real binary name. This will allow to remove 'qemu_emulators' entries once all tests are converted to real capabilties. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- tests/testutilsqemu.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index e15130492e..8738b69c84 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -533,24 +533,30 @@ qemuTestCapsCacheInsertImpl(virFileCache *cache, * * before populating the cache; */ - virArch arch = virQEMUCapsGetArch(caps); - g_autoptr(virQEMUCaps) copyCaps = NULL; - virQEMUCaps *effCaps = caps; - - if (arch_alias[arch] != VIR_ARCH_NONE) - arch = arch_alias[arch]; - - if (qemu_emulators[arch]) { - /* if we are dealing with fake caps we need to populate machine types */ - if (!virQEMUCapsHasMachines(caps)) { - if (!(copyCaps = effCaps = virQEMUCapsNewCopy(caps))) - return -1; - - qemuTestCapsPopulateFakeMachines(copyCaps, arch, hostOS); - } - - if (qemuTestCapsCacheInsertData(cache, qemu_emulators[arch], effCaps) < 0) + /* caps->binary is populated only for real capabilities */ + if (virQEMUCapsGetBinary(caps)) { + if (qemuTestCapsCacheInsertData(cache, virQEMUCapsGetBinary(caps), caps) < 0) return -1; + } else { + virArch arch = virQEMUCapsGetArch(caps); + g_autoptr(virQEMUCaps) copyCaps = NULL; + virQEMUCaps *effCaps = caps; + + if (arch_alias[arch] != VIR_ARCH_NONE) + arch = arch_alias[arch]; + + if (qemu_emulators[arch]) { + /* if we are dealing with fake caps we need to populate machine types */ + if (!virQEMUCapsHasMachines(caps)) { + if (!(copyCaps = effCaps = virQEMUCapsNewCopy(caps))) + return -1; + + qemuTestCapsPopulateFakeMachines(copyCaps, arch, hostOS); + } + + if (qemuTestCapsCacheInsertData(cache, qemu_emulators[arch], effCaps) < 0) + return -1; + } } } else { /* in case when caps are missing or are missing architecture, we populate