From: Eric Blake <eblake@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/2] vl: Table-based select_vgahw()
Date: Wed, 11 Nov 2015 15:05:07 -0700 [thread overview]
Message-ID: <5643BB93.6080305@redhat.com> (raw)
In-Reply-To: <1447277273-26151-2-git-send-email-ehabkost@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2099 bytes --]
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 <ehabkost@redhat.com>
> ---
> 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.
> 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.
> - } 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 <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2015-11-11 22:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-11 21:27 [Qemu-devel] [PATCH 0/2] vl: Simplify vga interface configuration code Eduardo Habkost
2015-11-11 21:27 ` [Qemu-devel] [PATCH 1/2] vl: Table-based select_vgahw() Eduardo Habkost
2015-11-11 22:05 ` Eric Blake [this message]
2015-11-12 15:08 ` Eduardo Habkost
2015-11-11 21:27 ` [Qemu-devel] [PATCH 2/2] vl: Replace *_vga_available() functions with class_names field Eduardo Habkost
2015-11-11 22:09 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5643BB93.6080305@redhat.com \
--to=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).