From 1a3de67001c00b689249b121b4c3413487ae68fe Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Fri, 14 Sep 2018 14:36:15 +0200 Subject: [PATCH] qemu: Prefer qemu-system-* binaries We already prefer them in capabilities, and domcapabilities should be consistent with that. This commit is best viewed with 'git show -w'. Signed-off-by: Andrea Bolognani --- src/qemu/qemu_capabilities.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e152868124..29e07d263d 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -583,6 +583,7 @@ struct _virQEMUCaps { struct virQEMUCapsSearchData { virArch arch; + const char *binaryFilter; }; @@ -4743,7 +4744,15 @@ virQEMUCapsCompareArch(const void *payload, struct virQEMUCapsSearchData *data = (struct virQEMUCapsSearchData *)opaque; const virQEMUCaps *qemuCaps = payload; - return qemuCaps->arch == data->arch; + if (qemuCaps->arch != data->arch) + return false; + + if (data->binaryFilter && + !strstr(qemuCaps->binary, data->binaryFilter)) { + return false; + } + + return true; } @@ -4752,20 +4761,28 @@ virQEMUCapsCacheLookupByArch(virFileCachePtr cache, virArch arch) { virQEMUCapsPtr ret = NULL; + const char *binaryFilters[] = { + "qemu-system-", + NULL, + }; virArch archs[] = { arch, virQEMUCapsFindTarget(virArchFromHost(), arch), }; + size_t i; size_t j; - for (j = 0; j < ARRAY_CARDINALITY(archs); j++) { - struct virQEMUCapsSearchData data = { - .arch = archs[j], - }; + for (i = 0; i < ARRAY_CARDINALITY(binaryFilters); i++) { + for (j = 0; j < ARRAY_CARDINALITY(archs); j++) { + struct virQEMUCapsSearchData data = { + .arch = archs[j], + .binaryFilter = binaryFilters[i], + }; - ret = virFileCacheLookupByFunc(cache, virQEMUCapsCompareArch, &data); - if (ret) - goto done; + ret = virFileCacheLookupByFunc(cache, virQEMUCapsCompareArch, &data); + if (ret) + goto done; + } } virReportError(VIR_ERR_INVALID_ARG,