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:
Jiri Denemark 2016-11-16 14:17:12 +01:00
parent 72e5aa4e1e
commit f9d57f2b57
3 changed files with 22 additions and 3 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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' "