提交 f9d57f2b 编写于 作者: J Jiri Denemark

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: NJiri Denemark <jdenemar@redhat.com>
上级 72e5aa4e
......@@ -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' "
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册