mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
qemu: Don't cache domCaps in virQEMUDriverGetDomainCapabilities()
Currently, whenever a domain capabilities is needed (fortunately, after cleanup done by previous commits it is now only in virConnectGetDomainCapabilities()), the object is stored in a cache. But there is no invalidation mechanism for the cache (except the implicit one - the cache is part of qemuCaps and thus share its lifetime, but that is not enough). Therefore, if something changes - for instance new firmware files are installed, or old are removed these changes are not reflected in the virConnectGetDomainCapabilities() output. Originally, the caching was there because domCaps were used during device XML validation and they were used a lot from our test suite. But this is no longer the case. And therefore, we don't need the cache and can construct fresh domCaps on each virConnectGetDomainCapabilities() call. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1807198 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
4b487e1052
commit
7db61843b0
@ -1428,11 +1428,8 @@ virCapsPtr virQEMUDriverGetCapabilities(virQEMUDriverPtr driver,
|
||||
/**
|
||||
* virQEMUDriverGetDomainCapabilities:
|
||||
*
|
||||
* Get a reference to the virDomainCapsPtr instance from the virQEMUCapsPtr
|
||||
* domCapsCache. If there's no domcaps in the cache, create a new instance,
|
||||
* add it to the cache, and return a reference.
|
||||
*
|
||||
* The caller must release the reference with virObjetUnref
|
||||
* Get a reference to the virDomainCapsPtr instance. The caller
|
||||
* must release the reference with virObjetUnref().
|
||||
*
|
||||
* Returns: a reference to a virDomainCapsPtr instance or NULL
|
||||
*/
|
||||
@ -1444,15 +1441,19 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr driver,
|
||||
virDomainVirtType virttype)
|
||||
{
|
||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||
g_autoptr(virDomainCaps) domCaps = NULL;
|
||||
const char *path = virQEMUCapsGetBinary(qemuCaps);
|
||||
|
||||
return virQEMUCapsGetDomainCapsCache(qemuCaps,
|
||||
machine,
|
||||
arch,
|
||||
virttype,
|
||||
driver->hostarch,
|
||||
driver->privileged,
|
||||
if (!(domCaps = virDomainCapsNew(path, machine, arch, virttype)))
|
||||
return NULL;
|
||||
|
||||
if (virQEMUCapsFillDomainCaps(qemuCaps, driver->hostarch,
|
||||
domCaps, driver->privileged,
|
||||
cfg->firmwares,
|
||||
cfg->nfirmwares);
|
||||
cfg->nfirmwares) < 0)
|
||||
return NULL;
|
||||
|
||||
return g_steal_pointer(&domCaps);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user