From nobody Sun Feb 8 10:33:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554448828714847.7238379906842; Fri, 5 Apr 2019 00:20:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2793D3004E6C; Fri, 5 Apr 2019 07:20:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E97CC5D9CD; Fri, 5 Apr 2019 07:20:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 912B8181AC47; Fri, 5 Apr 2019 07:20:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x357Jvc2027671 for ; Fri, 5 Apr 2019 03:19:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 00CCB5D735; Fri, 5 Apr 2019 07:19:57 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 468EB5D705; Fri, 5 Apr 2019 07:19:56 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 5 Apr 2019 09:19:46 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: lersek@redhat.com Subject: [libvirt] [PATCH v1 2/4] qemu_firmware: Separate machine and arch matching into a function X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 05 Apr 2019 07:20:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This part of the code will be reused later. Signed-off-by: Michal Privoznik --- src/qemu/qemu_firmware.c | 47 +++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 065e0d11aa..8e9a225982 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1054,6 +1054,34 @@ qemuFirmwareFetchConfigs(char ***firmwares, } =20 =20 +static bool +qemuFirmwareMatchesMachineArch(const qemuFirmware *fw, + const char *machine, + virArch arch) +{ + size_t i; + + for (i =3D 0; i < fw->ntargets; i++) { + size_t j; + + if (arch !=3D fw->targets[i]->architecture) + continue; + + for (j =3D 0; j < fw->targets[i]->nmachines; j++) { + if (fnmatch(fw->targets[i]->machines[j], machine, 0) =3D=3D 0) + break; + } + + if (j =3D=3D fw->targets[i]->nmachines) + continue; + + break; + } + + return i !=3D fw->ntargets; +} + + static bool qemuFirmwareMatchDomain(const virDomainDef *def, const qemuFirmware *fw, @@ -1078,24 +1106,7 @@ qemuFirmwareMatchDomain(const virDomainDef *def, return false; } =20 - for (i =3D 0; i < fw->ntargets; i++) { - size_t j; - - if (def->os.arch !=3D fw->targets[i]->architecture) - continue; - - for (j =3D 0; j < fw->targets[i]->nmachines; j++) { - if (fnmatch(fw->targets[i]->machines[j], def->os.machine, 0) = =3D=3D 0) - break; - } - - if (j =3D=3D fw->targets[i]->nmachines) - continue; - - break; - } - - if (i =3D=3D fw->ntargets) { + if (!qemuFirmwareMatchesMachineArch(fw, def->os.machine, def->os.arch)= ) { VIR_DEBUG("No matching machine type in '%s'", path); return false; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list