mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
qemu: Refresh caps in virQEMUCapsCacheLookupByArch
The function just returned cached capabilities without checking whether they are still valid. We should check that and refresh the capabilities to make sure we don't return stale data. In other words, we should do what all other lookup functions do. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
72e5aa4e1e
commit
f9d57f2b57
@ -4631,7 +4631,8 @@ virQEMUCapsCompareArch(const void *payload,
|
||||
|
||||
|
||||
virQEMUCapsPtr
|
||||
virQEMUCapsCacheLookupByArch(virQEMUCapsCachePtr cache,
|
||||
virQEMUCapsCacheLookupByArch(virCapsPtr caps,
|
||||
virQEMUCapsCachePtr cache,
|
||||
virArch arch)
|
||||
{
|
||||
virQEMUCapsPtr ret = NULL;
|
||||
@ -4649,6 +4650,22 @@ virQEMUCapsCacheLookupByArch(virQEMUCapsCachePtr cache,
|
||||
ret = virHashSearch(cache->binaries, virQEMUCapsCompareArch, &data);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
char *binary;
|
||||
|
||||
if (VIR_STRDUP(binary, ret->binary) < 0) {
|
||||
ret = NULL;
|
||||
} else {
|
||||
virQEMUCapsCacheValidate(cache, binary, caps, &ret);
|
||||
VIR_FREE(binary);
|
||||
}
|
||||
} else {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("unable to find any emulator to serve '%s' "
|
||||
"architecture"), virArchToString(arch));
|
||||
}
|
||||
|
||||
virObjectRef(ret);
|
||||
virMutexUnlock(&cache->lock);
|
||||
|
||||
|
@ -474,7 +474,8 @@ virQEMUCapsPtr virQEMUCapsCacheLookupCopy(virCapsPtr caps,
|
||||
virQEMUCapsCachePtr cache,
|
||||
const char *binary,
|
||||
const char *machineType);
|
||||
virQEMUCapsPtr virQEMUCapsCacheLookupByArch(virQEMUCapsCachePtr cache,
|
||||
virQEMUCapsPtr virQEMUCapsCacheLookupByArch(virCapsPtr caps,
|
||||
virQEMUCapsCachePtr cache,
|
||||
virArch arch);
|
||||
void virQEMUCapsCacheFree(virQEMUCapsCachePtr cache);
|
||||
|
||||
|
@ -18773,7 +18773,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
if (!(qemuCaps = virQEMUCapsCacheLookupByArch(driver->qemuCapsCache,
|
||||
if (!(qemuCaps = virQEMUCapsCacheLookupByArch(caps,
|
||||
driver->qemuCapsCache,
|
||||
arch))) {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("unable to find any emulator to serve '%s' "
|
||||
|
Loading…
Reference in New Issue
Block a user