From f7fa1d4e11cbc7358c7023438bcfa53354544a7a Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 3 Mar 2023 12:42:05 +0100 Subject: [PATCH] qemuTestCapsCacheInsertImpl: Require that callers always pass capabilities MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- tests/testutilsqemu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index d88b21b987..7dd7caf509 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -495,7 +495,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); @@ -534,10 +534,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); @@ -573,6 +570,7 @@ int qemuTestDriverInit(virQEMUDriver *driver) virSecurityManager *mgr = NULL; char statedir[] = STATEDIRTEMPLATE; char configdir[] = CONFIGDIRTEMPLATE; + g_autoptr(virQEMUCaps) emptyCaps = NULL; memset(driver, 0, sizeof(*driver)); @@ -643,7 +641,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.47.2