Received: from eggs.gnu.org ([2001:4830:134:3::10]:57774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwtUC-0006R9-UG for qemu-devel@nongnu.org; Thu, 12 Nov 2015 10:08:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwtU9-0007us-JA for qemu-devel@nongnu.org; Thu, 12 Nov 2015 10:08:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59264) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwtU9-0007uo-Du for qemu-devel@nongnu.org; Thu, 12 Nov 2015 10:08:25 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id DCE5568F for ; Thu, 12 Nov 2015 15:08:24 +0000 (UTC) Date: Thu, 12 Nov 2015 13:08:22 -0200 From: Eduardo Habkost Message-ID: <20151112150822.GK4180@thinpad.lan.raisama.net> References: <1447277273-26151-1-git-send-email-ehabkost@redhat.com> <1447277273-26151-2-git-send-email-ehabkost@redhat.com> <5643BB93.6080305@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5643BB93.6080305@redhat.com> 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: Eric Blake Cc: Paolo Bonzini , qemu-devel@nongnu.org On Wed, Nov 11, 2015 at 03:05:07PM -0700, Eric Blake wrote: > 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. > > > > Signed-off-by: Eduardo Habkost > > --- > > include/sysemu/sysemu.h | 1 + > > vl.c | 114 ++++++++++++++++++++++++++---------------------- > > 2 files changed, 63 insertions(+), 52 deletions(-) > > > > 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. I don't know. Maybe not, if we have any plans to configure this using QOM classes somehow (like the CPU model stuff), not using enums. > > > static void select_vgahw (const char *p) > > Worth dropping the space before '(' while in the neighborhood? > > > { > > const char *opts; > > + int t; > > > > - assert(vga_interface_type == VGA_NONE); > > Are you intentionally dropping the assert? It protects us from > select_vgahw() being called more than once. That was not intentional. I will fix it in a new version. Thanks! > > > - } else if (strstart(p, "cg3", &opts)) { > > - if (cg3_vga_available()) { > > - vga_interface_type = VGA_CG3; > > - } else { > > - error_report("CG3 framebuffer not available"); > > - exit(1); > > + for (t = 0; t < VGA_TYPE_MAX; t++) { > > + VGAInterfaceInfo *ti = &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 = t; > > + break; > > Nice compression in code size. > > Reviewed-by: Eric Blake Thanks! -- Eduardo