From: Michal Privoznik Date: Thu, 4 Apr 2019 13:51:47 +0000 (+0200) Subject: qemu_firmware: Separate machine and arch matching into a function X-Git-Tag: v5.3.0-rc1~207 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2337309e04342ec244036e4957968bab0d9ca5b6;p=thirdparty%2Flibvirt.git qemu_firmware: Separate machine and arch matching into a function This part of the code will be reused later. Signed-off-by: Michal Privoznik Acked-by: Laszlo Ersek --- diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index c4e3155f28..bd68d964ac 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1056,6 +1056,29 @@ qemuFirmwareFetchConfigs(char ***firmwares, } +static bool +qemuFirmwareMatchesMachineArch(const qemuFirmware *fw, + const char *machine, + virArch arch) +{ + size_t i; + + for (i = 0; i < fw->ntargets; i++) { + size_t j; + + if (arch != fw->targets[i]->architecture) + continue; + + for (j = 0; j < fw->targets[i]->nmachines; j++) { + if (fnmatch(fw->targets[i]->machines[j], machine, 0) == 0) + return true; + } + } + + return false; +} + + static bool qemuFirmwareMatchDomain(const virDomainDef *def, const qemuFirmware *fw, @@ -1080,24 +1103,7 @@ qemuFirmwareMatchDomain(const virDomainDef *def, return false; } - for (i = 0; i < fw->ntargets; i++) { - size_t j; - - if (def->os.arch != fw->targets[i]->architecture) - continue; - - for (j = 0; j < fw->targets[i]->nmachines; j++) { - if (fnmatch(fw->targets[i]->machines[j], def->os.machine, 0) == 0) - break; - } - - if (j == fw->targets[i]->nmachines) - continue; - - break; - } - - if (i == fw->ntargets) { + if (!qemuFirmwareMatchesMachineArch(fw, def->os.machine, def->os.arch)) { VIR_DEBUG("No matching machine type in '%s'", path); return false; }