[PATCH 20/31] qemuTestCapsCacheInsertImpl: Require that callers always pass capabilities

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There's just one case when we're populating the cache with empty caps so
that can allocate a dummy virQEMUCaps object rather than having the
logic inside qemuTestCapsCacheInsertImpl.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tests/testutilsqemu.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index b78634a436..18a9ca5ee1 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -492,7 +492,7 @@ qemuTestCapsCacheInsertImpl(virFileCache *cache,
 {
     size_t i;

-    if (caps && virQEMUCapsGetArch(caps) != VIR_ARCH_NONE) {
+    if (virQEMUCapsGetArch(caps) != VIR_ARCH_NONE) {
         /* all tests using real caps or arcitecture are expected to call:
          *
          *  virFileCacheClear(driver.qemuCapsCache);
@@ -531,10 +531,7 @@ qemuTestCapsCacheInsertImpl(virFileCache *cache,
             if (qemu_emulators[i] == NULL)
                 continue;

-            if (caps)
-                tmp = virQEMUCapsNewCopy(caps);
-            else
-                tmp = virQEMUCapsNew();
+            tmp = virQEMUCapsNewCopy(caps);

             qemuTestCapsPopulateFakeMachines(tmp, i, hostOS);

@@ -569,6 +566,7 @@ int qemuTestDriverInit(virQEMUDriver *driver)
     virSecurityManager *mgr = NULL;
     char statedir[] = STATEDIRTEMPLATE;
     char configdir[] = CONFIGDIRTEMPLATE;
+    g_autoptr(virQEMUCaps) emptyCaps = NULL;

     memset(driver, 0, sizeof(*driver));

@@ -625,7 +623,9 @@ int qemuTestDriverInit(virQEMUDriver *driver)
     if (!driver->xmlopt)
         goto error;

-    if (qemuTestCapsCacheInsert(driver->qemuCapsCache, NULL) < 0)
+    /* Populate the capabilities cache with fake empty caps */
+    emptyCaps = virQEMUCapsNew();
+    if (qemuTestCapsCacheInsert(driver->qemuCapsCache, emptyCaps) < 0)
         goto error;

     if (!(mgr = virSecurityManagerNew("none", "qemu",
-- 
2.39.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux