From nobody Mon Feb 9 10:25:43 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 1537457263661541.0882516823916; Thu, 20 Sep 2018 08:27:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2955330024F1; Thu, 20 Sep 2018 15:27:41 +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 D66947E6B5; Thu, 20 Sep 2018 15:27:40 +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 8BE334A46C; Thu, 20 Sep 2018 15:27:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8KFPiq9022241 for ; Thu, 20 Sep 2018 11:25:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C2922010D04; Thu, 20 Sep 2018 15:25:44 +0000 (UTC) Received: from kinshicho.brq.redhat.com (unknown [10.43.2.74]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3F082010D02 for ; Thu, 20 Sep 2018 15:25:43 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 20 Sep 2018 17:25:28 +0200 Message-Id: <20180920152529.25973-11-abologna@redhat.com> In-Reply-To: <20180920152529.25973-1-abologna@redhat.com> References: <20180920152529.25973-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/11] qemu: Refactor virQEMUCapsCacheLookupByArch() 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: , MIME-Version: 1.0 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 20 Sep 2018 15:27:42 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The new implementation contains less duplicated code and is easier to extend. This commit is best viewed with 'git show -w'. Signed-off-by: Andrea Bolognani --- src/qemu/qemu_capabilities.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b78b935404..b621f39a82 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4752,26 +4752,27 @@ virQEMUCapsCacheLookupByArch(virFileCachePtr cache, virArch arch) { virQEMUCapsPtr ret =3D NULL; - virArch target; - struct virQEMUCapsSearchData data =3D { .arch =3D arch }; - - ret =3D virFileCacheLookupByFunc(cache, virQEMUCapsCompareArch, &data); - if (!ret) { - /* If the first attempt at finding capabilities has failed, try - * again using the QEMU target as lookup key instead */ - target =3D virQEMUCapsFindTarget(virArchFromHost(), data.arch); - if (target !=3D data.arch) { - data.arch =3D target; - ret =3D virFileCacheLookupByFunc(cache, virQEMUCapsCompareArch= , &data); - } - } + virArch archs[] =3D { + arch, + virQEMUCapsFindTarget(virArchFromHost(), arch), + }; + size_t j; =20 - if (!ret) { - virReportError(VIR_ERR_INVALID_ARG, - _("unable to find any emulator to serve '%s' " - "architecture"), virArchToString(arch)); + for (j =3D 0; j < ARRAY_CARDINALITY(archs); j++) { + struct virQEMUCapsSearchData data =3D { + .arch =3D archs[j], + }; + + ret =3D virFileCacheLookupByFunc(cache, virQEMUCapsCompareArch, &d= ata); + if (ret) + goto done; } =20 + virReportError(VIR_ERR_INVALID_ARG, + _("unable to find any emulator to serve '%s' " + "architecture"), virArchToString(arch)); + + done: VIR_DEBUG("Returning caps %p for arch %s", ret, virArchToString(arch)); =20 return ret; --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list