From nobody Sat May 4 13:41:50 2024 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 15350434570111018.8148355033802; Thu, 23 Aug 2018 09:57:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7F51C04F4B1; Thu, 23 Aug 2018 16:57:34 +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 BF761308BE72; Thu, 23 Aug 2018 16:57:32 +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 1244A4BB75; Thu, 23 Aug 2018 16:57:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7NGvTqA005675 for ; Thu, 23 Aug 2018 12:57:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 65D5E10073CA; Thu, 23 Aug 2018 16:57:29 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.40.205.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0104810D18F3 for ; Thu, 23 Aug 2018 16:57:27 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 23 Aug 2018 18:57:24 +0200 Message-Id: <20180823165724.4871-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Make sure preferredMachines is not missing any entry 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.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 23 Aug 2018 16:57:35 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" With the current implementation, adding a new architecture and not updating preferredMachines accordingly will not cause a build failure, making it very likely that subtle bugs will be introduced in the process. Rework the code so that such issues will be caught by the compiler. Signed-off-by: Andrea Bolognani Reviewed-by: Erik Skultety --- src/qemu/qemu_capabilities.c | 84 ++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 8a44d32c59..230beeab8c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2266,49 +2266,51 @@ virQEMUCapsProbeQMPDevices(virQEMUCapsPtr qemuCaps, * that we're not vulnerable to changes in QEMU defaults or machine * list ordering. */ -static const char *preferredMachines[VIR_ARCH_LAST] =3D +static const char *preferredMachines[] =3D { - [VIR_ARCH_ALPHA] =3D "clipper", - [VIR_ARCH_ARMV6L] =3D NULL, /* No QEMU impl */ - [VIR_ARCH_ARMV7L] =3D "integratorcp", - [VIR_ARCH_ARMV7B] =3D "integratorcp", - - [VIR_ARCH_AARCH64] =3D "integratorcp", - [VIR_ARCH_CRIS] =3D "axis-dev88", - [VIR_ARCH_I686] =3D "pc", - [VIR_ARCH_ITANIUM] =3D NULL, /* doesn't exist in QEMU any more */ - [VIR_ARCH_LM32] =3D "lm32-evr", - - [VIR_ARCH_M68K] =3D "mcf5208evb", - [VIR_ARCH_MICROBLAZE] =3D "petalogix-s3adsp1800", - [VIR_ARCH_MICROBLAZEEL] =3D "petalogix-s3adsp1800", - [VIR_ARCH_MIPS] =3D "malta", - [VIR_ARCH_MIPSEL] =3D "malta", - - [VIR_ARCH_MIPS64] =3D "malta", - [VIR_ARCH_MIPS64EL] =3D "malta", - [VIR_ARCH_OR32] =3D "or1k-sim", - [VIR_ARCH_PARISC] =3D NULL, /* No QEMU impl */ - [VIR_ARCH_PARISC64] =3D NULL, /* No QEMU impl */ - - [VIR_ARCH_PPC] =3D "g3beige", - [VIR_ARCH_PPCLE] =3D "g3beige", - [VIR_ARCH_PPC64] =3D "pseries", - [VIR_ARCH_PPC64LE] =3D "pseries", - [VIR_ARCH_PPCEMB] =3D "bamboo", - - [VIR_ARCH_S390] =3D NULL, /* No QEMU impl*/ - [VIR_ARCH_S390X] =3D "s390-ccw-virtio", - [VIR_ARCH_SH4] =3D "shix", - [VIR_ARCH_SH4EB] =3D "shix", - [VIR_ARCH_SPARC] =3D "SS-5", - - [VIR_ARCH_SPARC64] =3D "sun4u", - [VIR_ARCH_UNICORE32] =3D "puv3", - [VIR_ARCH_X86_64] =3D "pc", - [VIR_ARCH_XTENSA] =3D "sim", - [VIR_ARCH_XTENSAEB] =3D "sim", + NULL, /* VIR_ARCH_NONE (not a real arch :) */ + "clipper", /* VIR_ARCH_ALPHA */ + NULL, /* VIR_ARCH_ARMV6L (no QEMU impl) */ + "integratorcp", /* VIR_ARCH_ARMV7L */ + "integratorcp", /* VIR_ARCH_ARMV7B */ + + "integratorcp", /* VIR_ARCH_AARCH64 */ + "axis-dev88", /* VIR_ARCH_CRIS */ + "pc", /* VIR_ARCH_I686 */ + NULL, /* VIR_ARCH_ITANIUM (doesn't exist in QEMU any more) */ + "lm32-evr", /* VIR_ARCH_LM32 */ + + "mcf5208evb", /* VIR_ARCH_M68K */ + "petalogix-s3adsp1800", /* VIR_ARCH_MICROBLAZE */ + "petalogix-s3adsp1800", /* VIR_ARCH_MICROBLAZEEL */ + "malta", /* VIR_ARCH_MIPS */ + "malta", /* VIR_ARCH_MIPSEL */ + + "malta", /* VIR_ARCH_MIPS64 */ + "malta", /* VIR_ARCH_MIPS64EL */ + "or1k-sim", /* VIR_ARCH_OR32 */ + NULL, /* VIR_ARCH_PARISC (no QEMU impl) */ + NULL, /* VIR_ARCH_PARISC64 (no QEMU impl) */ + + "g3beige", /* VIR_ARCH_PPC */ + "g3beige", /* VIR_ARCH_PPCLE */ + "pseries", /* VIR_ARCH_PPC64 */ + "pseries", /* VIR_ARCH_PPC64LE */ + "bamboo", /* VIR_ARCH_PPCEMB */ + + NULL, /* VIR_ARCH_S390 (no QEMU impl) */ + "s390-ccw-virtio", /* VIR_ARCH_S390X */ + "shix", /* VIR_ARCH_SH4 */ + "shix", /* VIR_ARCH_SH4EB */ + "SS-5", /* VIR_ARCH_SPARC */ + + "sun4u", /* VIR_ARCH_SPARC64 */ + "puv3", /* VIR_ARCH_UNICORE32 */ + "pc", /* VIR_ARCH_X86_64 */ + "sim", /* VIR_ARCH_XTENSA */ + "sim", /* VIR_ARCH_XTENSAEB */ }; +verify(ARRAY_CARDINALITY(preferredMachines) =3D=3D VIR_ARCH_LAST); =20 =20 static int --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list