qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Wanpeng Li <liwp@linux.vnet.ibm.com>
Cc: "Gavin Shan" <shangw@linux.vnet.ibm.com>,
	"Stefan Hajnoczi" <stefanha@gmail.com>,
	"Anthony Liguori" <aliguori@us.ibm.com>,
	"Andreas Färber" <afaerber@suse.de>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] RFC: options parse in vl.c should be moduled
Date: Fri, 30 Mar 2012 13:53:14 +0100	[thread overview]
Message-ID: <20120330125313.GH10487@redhat.com> (raw)
In-Reply-To: <1333111003-28556-1-git-send-email-liwp@linux.vnet.ibm.com>

On Fri, Mar 30, 2012 at 08:36:43PM +0800, Wanpeng Li wrote:
> Consider of the options parse process in main function of vl.c is too
> long.It should be module into single function to clear ideas, strengthen
> the source code management, and increase code readability.So I module the 
> process of options parse as function options_parse, and expose some variables
> in order to not influence command-line invocations.
> 
> Signed-off-by: Wanpeng Li <liwp@linux.vnet.ibm.com>
> ---
>  vl.c |  159 ++++++++++++++++++++++++++++++++++-------------------------------
>  1 files changed, 83 insertions(+), 76 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index 0fccf50..fa4d0a9 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2251,84 +2251,40 @@ int qemu_init_main_loop(void)
>      return main_loop_init();
>  }
>  
> -int main(int argc, char **argv, char **envp)
> -{
> -    int i;
> -    int snapshot, linux_boot;
> -    const char *icount_option = NULL;
> -    const char *initrd_filename;
> -    const char *kernel_filename, *kernel_cmdline;
> -    char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */
> -    DisplayState *ds;
> -    DisplayChangeListener *dcl;
> -    int cyls, heads, secs, translation;
> -    QemuOpts *hda_opts = NULL, *opts, *machine_opts;
> -    QemuOptsList *olist;
> -    int optind;
> -    const char *optarg;
> -    const char *loadvm = NULL;
> -    QEMUMachine *machine;
> -    const char *cpu_model;
> -    const char *vga_model = NULL;
> -    const char *pid_file = NULL;
> -    const char *incoming = NULL;
> +int snapshot, linux_boot;
> +const char *icount_option;
> +const char *initrd_filename;
> +const char *kernel_filename, *kernel_cmdline;
> +char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */
> +DisplayState *ds;
> +DisplayChangeListener *dcl;
> +int cyls, heads, secs, translation;
> +QemuOpts *hda_opts , *opts, *machine_opts;
> +QemuOptsList *olist;
> +int optind;
> +const char *loadvm;
> +QEMUMachine *machine;
> +const char *cpu_model;
> +const char *vga_model;
> +const char *pid_file;
> +const char *incoming;
>  #ifdef CONFIG_VNC
> -    int show_vnc_port = 0;
> +int show_vnc_port;

[snip]

> +int defconfig = 1;
> +const char *log_mask;
> +const char *log_file;
> +GMemVTable mem_trace = {
> +    .malloc = malloc_and_trace,
> +    .realloc = realloc_and_trace,
> +    .free = free_and_trace,
> +};
> +const char *trace_events;
> +const char *trace_file;
>  
> +static void options_parse(int argc, char **argv)
> +{

While code modularization is a worthy goal, I don't think this patch is
really an improvement. QEMU already has far too many adhoc global variables,
without adding another 30 or more. The resulting code isn't even simplified
or more readable IMHO, it is merely different.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

  reply	other threads:[~2012-03-30 12:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-30 12:36 [Qemu-devel] [PATCH] RFC: options parse in vl.c should be moduled Wanpeng Li
2012-03-30 12:53 ` Daniel P. Berrange [this message]
2012-03-30 13:25   ` Wanpeng Li
     [not found]   ` <4f75b5f3.2235b60a.302d.ffffa586SMTPIN_ADDED@mx.google.com>
2012-03-30 15:55     ` Michael Roth
2012-03-30 13:10 ` Anthony Liguori
2012-03-30 15:59 ` Lluís Vilanova
2012-03-30 16:09   ` Anthony Liguori
2012-03-30 16:31     ` Anthony Liguori
2012-03-30 17:52       ` Lluís Vilanova

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=20120330125313.GH10487@redhat.com \
    --to=berrange@redhat.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=liwp@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=shangw@linux.vnet.ibm.com \
    --cc=stefanha@gmail.com \
    /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).