diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2f2e88cb43..71d35b077f 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -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); diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index d44cf2c4d7..4e33ddaf87 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -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); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6a26549237..3517aa2be2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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' "