From: Peter Krempa Date: Fri, 3 Mar 2023 11:42:05 +0000 (+0100) Subject: qemuTestCapsCacheInsertImpl: Require that callers always pass capabilities X-Git-Tag: v9.2.0-rc1~164 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7fa1d4e11cbc7358c7023438bcfa53354544a7a;p=thirdparty%2Flibvirt.git qemuTestCapsCacheInsertImpl: Require that callers always pass capabilities 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 --- 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",