From nobody Sun Feb 8 18:19:19 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 ARC-Seal: i=1; a=rsa-sha256; t=1554821596; cv=none; d=zoho.com; s=zohoarc; b=bfb6agn1KbL3VIL1TL717+KnGiaQJ7//FPQYasDV/MzjpZhbTjcFhlQfJU3o4uKwjFKOuego1KVMoZbQH8gjY9B0f8eASOgxPBpTFIfYWcxkQNgUAnVkzpBMBMA8o6egQAbJNp4sPixo5SIIs/Ez5U6fGayeLMld3fti21gg6sQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1554821596; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=DEA0gZUchePHIZ78+mQo8h1/BN3FBVX+tISW9UcEOpY=; b=dsD328pMSbrZRfcUDYN+X7xB1tksPC8YPP7lw0HO2zDVAjDA9Yj1+eMw8mjVq57B7q/qYX2t9WxVY3yndS3Mbjx3KP6sVKwP/YhfPlkZUBuSchpBkBNqpbRidB/Yy3zACKZt65TmdrrbAfN11U6Py9QPj4wJD8rybTaVgecJ350= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554821596835695.0767105334395; Tue, 9 Apr 2019 07:53:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D56F2306E171; Tue, 9 Apr 2019 14:53:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A743E600D4; Tue, 9 Apr 2019 14:53: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 71AEF41F3F; Tue, 9 Apr 2019 14:53:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x39Er5SQ029716 for ; Tue, 9 Apr 2019 10:53:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 71CA01001E92; Tue, 9 Apr 2019 14:53:05 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A15B31001E6B; Tue, 9 Apr 2019 14:53:04 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 9 Apr 2019 16:52:56 +0200 Message-Id: <2a6aeae154b70006e529263bc9523bea9099c0fc.1554821424.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: lersek@redhat.com, ptoscano@redhat.com Subject: [libvirt] [PATCH v2 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 09 Apr 2019 14:53:15 +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