]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuTestCapsCacheInsert*: Drop the file cache rather than poisoning it
authorPeter Krempa <pkrempa@redhat.com>
Thu, 2 Mar 2023 16:44:21 +0000 (17:44 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 6 Mar 2023 19:55:50 +0000 (20:55 +0100)
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>
tests/qemusecuritytest.c
tests/qemustatusxml2xmltest.c
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c
tests/testutilsqemu.c

index 0596783b6c9c275dd2fe1e828c1670fed13cef37..e2989c05aafe2a70dfe87edba08f8c0ff4e1dc79 100644 (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;
 
index 408955a8f570d8e4a8d136374ce48bca460ca6ea..c689ab3b031f17918d3bb1d097e3b8a34bece396 100644 (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;
 
index 6f2ac9ee2a167f436d8199a5868ac7f40177c440..fc0f7830a976d9da94654ccbf5f806ff124fda94 100644 (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
index 05a94dbf4f6bc86d2b7d52d1f09181db2d96a2a7..28ece103493734650a45e12d9c1417cd80a2a80c 100644 (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
index d715252aee65a08db8f5c4bb26a8f4002ffdac68..e15130492e18fa77ae6ce46853d97ff1e91aa984 100644 (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 */