From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwdW2-0005Xq-4A for qemu-devel@nongnu.org; Wed, 11 Nov 2015 17:05:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwdVx-00010w-UA for qemu-devel@nongnu.org; Wed, 11 Nov 2015 17:05:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33743) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwdVx-00010r-Mq for qemu-devel@nongnu.org; Wed, 11 Nov 2015 17:05:13 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 5322780085 for ; Wed, 11 Nov 2015 22:05:13 +0000 (UTC) References: <1447277273-26151-1-git-send-email-ehabkost@redhat.com> <1447277273-26151-2-git-send-email-ehabkost@redhat.com> From: Eric Blake Message-ID: <5643BB93.6080305@redhat.com> Date: Wed, 11 Nov 2015 15:05:07 -0700 MIME-Version: 1.0 In-Reply-To: <1447277273-26151-2-git-send-email-ehabkost@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="26Sx16wQqeSguPsgOX9LsAG0qLxD5Gnbr" Subject: Re: [Qemu-devel] [PATCH 1/2] vl: Table-based select_vgahw() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost , qemu-devel@nongnu.org Cc: Paolo Bonzini This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --26Sx16wQqeSguPsgOX9LsAG0qLxD5Gnbr Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/11/2015 02:27 PM, Eduardo Habkost wrote: > Instead of implementing separate check functions for each vga > interface type, add a table enumerating the possible VGA > interfaces. >=20 > Signed-off-by: Eduardo Habkost > --- > include/sysemu/sysemu.h | 1 + > vl.c | 114 ++++++++++++++++++++++++++--------------= -------- > 2 files changed, 63 insertions(+), 52 deletions(-) >=20 > diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h > index f992494..6406906 100644 > --- a/include/sysemu/sysemu.h > +++ b/include/sysemu/sysemu.h > @@ -147,6 +147,7 @@ extern int autostart; > typedef enum { > VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL, > VGA_TCX, VGA_CG3, VGA_DEVICE, VGA_VIRTIO, > + VGA_TYPE_MAX, > } VGAInterfaceType; Would it be worth exposing this enum in qapi someday? But doesn't affect the correctness of this patch. > static void select_vgahw (const char *p) Worth dropping the space before '(' while in the neighborhood? > { > const char *opts; > + int t; > =20 > - assert(vga_interface_type =3D=3D VGA_NONE); Are you intentionally dropping the assert? It protects us from select_vgahw() being called more than once. > - } else if (strstart(p, "cg3", &opts)) { > - if (cg3_vga_available()) { > - vga_interface_type =3D VGA_CG3; > - } else { > - error_report("CG3 framebuffer not available"); > - exit(1); > + for (t =3D 0; t < VGA_TYPE_MAX; t++) { > + VGAInterfaceInfo *ti =3D &vga_interfaces[t]; > + if (ti->opt_name && strstart(p, ti->opt_name, &opts)) { > + if (ti->available && !ti->available()) { > + error_report("%s not available", ti->name); > + exit(1); > + } > + vga_interface_type =3D t; > + break; Nice compression in code size. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --26Sx16wQqeSguPsgOX9LsAG0qLxD5Gnbr Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWQ7uUAAoJEKeha0olJ0NqDv0H/3j/qBzSH9ZvuIQzJR7tDEjg wOSpx8GUOBbpeQHPPpLZkg26MmieNGRMVcdDhvDdOU8olZnCdKhQ5CyQ3tdmLKMf rmlnQtd7gvV2svSVcwRvN69lcyqmb+dPnwHlpuP3zjZezmodzFbJ5FQndj3RRsf8 PL5zKm9dDJ2fVfqJfZP8BWqjVf8xVwXGI5XkQCLdGETucW3Xq7t1Xrxf8bh86Frl TT0Q5v/Xmlx/tIVTMjRCrrz8AbMA4jzohgGBRbaBQlbucvnxNlk2f9hh3jGh4iku aXWPZqhiVhkAog9eFbi2qGEtRkB16jjXnZvzHgLMsk2x6xUVcDuh9XdTKG7vAc4= =tOcl -----END PGP SIGNATURE----- --26Sx16wQqeSguPsgOX9LsAG0qLxD5Gnbr--