From: Anthony Liguori <anthony@codemonkey.ws>
To: "Lluís Vilanova" <vilanova@ac.upc.edu>
Cc: "Anthony Liguori" <aliguori@us.ibm.com>,
"Wanpeng Li" <liwp@linux.vnet.ibm.com>,
"Stefan Hajnoczi" <stefanha@gmail.com>,
qemu-devel <qemu-devel@nongnu.org>,
"Andreas Färber" <afaerber@suse.de>,
"Gavin Shan" <shangw@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH] RFC: options parse in vl.c should be moduled
Date: Fri, 30 Mar 2012 11:09:29 -0500 [thread overview]
Message-ID: <4F75DAB9.9020802@codemonkey.ws> (raw)
In-Reply-To: <87bonet6zk.fsf@ginnungagap.bsc.es>
On 03/30/2012 10:59 AM, Lluís Vilanova wrote:
> Wanpeng Li writes:
>
>> 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.
>
> Another approach would be to use something similar to QOM type registration.
>
> In order to keep code to a minimum, you can define an array of pointers to
> QParameter structures, instead of an array of function pointers (what
> __attribute__((constructors)) does).
>
> So, for example:
>
> static void opt_icount_handler(const char *args)
> {
> if (kvm_enabled() || xen_enabled()) {
> fprintf(stderr, "-icount is not allowed with kvm or xen\n");
> exit(1);
> }
> /* ... contents of configure_icount ... */
> }
>
> static QEMUOption opt_icount = {
> .name = "icount",
> .signature = "[N|auto]",
> .help = "enable virtual instruction counter with 2^N clock ticks per instruction",
> .mode = QEMU_MODE_SYSTEM,
> .priority = QEMU_OPT_PRIO_BEFORE_DEVICES,
> .section = QEMU_OPT_SECTION_DEBUG,
> .handler = opt_icount_handler
> };
>
> param_register(opt_icount);
>
>
> Here, param_register would define an array of pointers to QEMUOption structures,
> although I'm not sure how this can be handled on formats other than ELF.
My plan is to have a -query-capabilities so we can change the help text, then
use GOptionContext.
It would take a small function that goes through and promotes any option in the
format '-foo' to '--foo'. But that's not too hard.
Then we can completely rip out the option parsing, qemu-options.hx, and all of
that other junk.
Regards,
Anthony Liguori
next prev parent reply other threads:[~2012-03-30 16:09 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
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 [this message]
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=4F75DAB9.9020802@codemonkey.ws \
--to=anthony@codemonkey.ws \
--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 \
--cc=vilanova@ac.upc.edu \
/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).