qemuTestCapsCacheInsert*: Drop the file cache rather than poisoning it

Make callers use virFileCacheClear to clear the cache before populating
it rather than trying to overwrite what's in it.

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-02 17:44:21 +01:00
parent 856166a268
commit f0fec72e3f
5 changed files with 14 additions and 19 deletions

View File

@ -64,6 +64,8 @@ prepareObjects(virQEMUDriver *driver,
if (!(priv->qemuCaps = qemuTestParseCapabilitiesArch(VIR_ARCH_X86_64, latestCapsFile)))
return -1;
virFileCacheClear(driver->qemuCapsCache);
if (qemuTestCapsCacheInsert(driver->qemuCapsCache, priv->qemuCaps) < 0)
return -1;

View File

@ -26,6 +26,8 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
if (testQemuInfoInitArgs((struct testQemuInfo *) data) < 0)
return -1;
virFileCacheClear(driver.qemuCapsCache);
if (qemuTestCapsCacheInsert(driver.qemuCapsCache, data->qemuCaps) < 0)
return -1;

View File

@ -664,6 +664,8 @@ testCompareXMLToArgv(const void *data)
goto cleanup;
}
virFileCacheClear(driver.qemuCapsCache);
if (info->args.hostOS == HOST_OS_MACOS)
rc = qemuTestCapsCacheInsertMacOS(driver.qemuCapsCache, info->qemuCaps);
else

View File

@ -44,6 +44,8 @@ testXML2XMLCommon(const struct testQemuInfo *info)
if (!(info->flags & FLAG_REAL_CAPS))
virQEMUCapsInitQMPBasicArch(info->qemuCaps);
virFileCacheClear(driver.qemuCapsCache);
if (info->args.hostOS == HOST_OS_MACOS)
rc = qemuTestCapsCacheInsertMacOS(driver.qemuCapsCache, info->qemuCaps);
else

View File

@ -527,17 +527,16 @@ qemuTestCapsCacheInsertImpl(virFileCache *cache,
size_t i;
if (caps && virQEMUCapsGetArch(caps) != VIR_ARCH_NONE) {
/* for capabilities which have architecture set we populate only the
* given architecture and poison all other so that the test doesn't
* accidentally test a weird combination */
/* all tests using real caps or arcitecture are expected to call:
*
* virFileCacheClear(driver.qemuCapsCache);
*
* before populating the cache;
*/
virArch arch = virQEMUCapsGetArch(caps);
g_autoptr(virQEMUCaps) emptyCaps = virQEMUCapsNew();
g_autoptr(virQEMUCaps) copyCaps = NULL;
virQEMUCaps *effCaps = caps;
if (!emptyCaps)
return -1;
if (arch_alias[arch] != VIR_ARCH_NONE)
arch = arch_alias[arch];
@ -553,18 +552,6 @@ qemuTestCapsCacheInsertImpl(virFileCache *cache,
if (qemuTestCapsCacheInsertData(cache, qemu_emulators[arch], effCaps) < 0)
return -1;
}
for (i = 0; i < G_N_ELEMENTS(qemu_emulators); i++) {
if (!qemu_emulators[i])
continue;
if (i == arch)
continue;
if (qemuTestCapsCacheInsertData(cache, qemu_emulators[i], emptyCaps) < 0)
return -1;
}
} else {
/* in case when caps are missing or are missing architecture, we populate
* everything */