qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: Kevin Wolf <kwolf@redhat.com>, Chris Wright <chrisw@redhat.com>,
	Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
	Markus Armbruster <armbru@redhat.com>,
	Adam Litke <agl@us.ibm.com>
Subject: [Qemu-devel] [RFC] QCFG: a new mechanism to replace QemuOpts and option handling
Date: Mon, 14 Mar 2011 12:48:55 -0500	[thread overview]
Message-ID: <4D7E5507.8010205@codemonkey.ws> (raw)

As I've been waiting for QAPI review, I've been working on the design of 
a new mechanism to replace our current command line option handling 
(QemuOpts) with something that reuses the QAPI infrastructure.

The 'QemuOpts' syntax is just a way to encode complex data structures.  
'nic,model=virtio,macaddress=00:01:02:03:04:05' can be mapped directly 
to a C data structure.  This is exactly what QCFG does using the same 
JSON schema mechanism that QMP uses.

The effect is that you describe a command line argument in JSON like so:

{ 'type': 'VncConfig',
   'data': { 'address': 'str', '*password': 'bool', '*reverse': 'bool',
             '*no-lock-key-sync': 'bool', '*sasl': 'bool', '*tls': 'bool',
             '*x509': 'str', '*x509verify': 'str', '*acl': 'bool',
             '*lossy': 'bool' } }


You then just implement a C function that gets called for each -vnc 
option specified:

void qcfg_handle_vnc(VncConfig *option, Error **errp)
{
}

And that's it.  You can squirrel away the option such that they all can 
be processed later, you can perform additional validation and return an 
error, or you can implement the appropriate logic.

The VncConfig structure is a proper C data structure.  The advantages of 
this approach compared to QemuOpts are similar to QAPI:

1) Strong typing means less bugs with lack of command line validation.  
In many cases, a bad command line results in a SEGV today.

2) Every option is formally specified and documented in a way that is 
both rigorous and machine readable.  This means we can generate high 
quality documentation in a variety of formats.

3) The command line parameters support full introspection.  This should 
provide the same functionality as Dan's earlier introspection patches.

4) The 'VncConfig' structure also has JSON marshallers and the 
qcfg_handle_vnc() function can be trivially bridged to QMP.  This means 
command line oriented interfaces (like device_add) are better integrated 
with QMP.

5) Very complex data types can be implemented.  We had some discussion 
of supporting nested structures with -blockdev.  This wouldn't work with 
QemuOpts but I've already implemented it with QCFG (blockdev syntax is 
my test case right now).  The syntax I'm currently using is -blockdev 
cache=none,id=foo,format.qcow.protocol.nbd.hostname=localhost where '.' 
is used to reference sub structures.

6) Unions are supported which means complex options like -net can be 
specified in the schema and don't require hand validation.

I've got a spec written up at http://wiki.qemu.org/Features/QCFG.  
Initial code is in my QAPI tree.

I'm not going to start converting things until we get closer to the end 
of 0.15 and QAPI is fully merged.  My plan is to focus on this for 0.16 
and do a full conversion for the 0.16 time frame using the same approach 
as QAPI.  That means that for 0.16, we would be able to set all command 
line options via QMP in a programmatic fashion with full support for 
introspection.

I'm haven't yet closed on how to bridge this to qdev.  qdev is a big 
consumer of QemuOpts today.  I have some general ideas about what I'd 
like to do but so far, I haven't written anything down.

I wanted to share these plans early hoping to get some feedback and also 
to maybe interest some folks in helping out.

Regards,

Anthony Liguori

             reply	other threads:[~2011-03-14 17:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-14 17:48 Anthony Liguori [this message]
2011-03-14 19:52 ` [Qemu-devel] [RFC] QCFG: a new mechanism to replace QemuOpts and option handling Lluís
2011-03-14 20:04   ` Anthony Liguori
2011-03-15 10:09 ` Kevin Wolf
2011-03-15 13:27   ` Anthony Liguori
2011-03-15 13:45     ` Kevin Wolf
2011-03-15 13:56       ` Anthony Liguori
2011-03-18 18:12     ` Stefan Hajnoczi
2011-03-15 11:21 ` [Qemu-devel] " Kevin Wolf
2011-03-15 13:37   ` Anthony Liguori
2011-03-15 13:51     ` Kevin Wolf
2011-03-17 15:26       ` Markus Armbruster
2011-03-18  4:12         ` Anthony Liguori
2011-03-18 13:07           ` Markus Armbruster
2011-03-17 15:22 ` [Qemu-devel] " Markus Armbruster
2011-03-17 18:28   ` Anthony Liguori
2011-03-18  9:44     ` Kevin Wolf
2011-03-18 14:04     ` Markus Armbruster
2011-03-18 22:39       ` Anthony Liguori
2011-03-22 13:01         ` Markus Armbruster
2011-03-22 15:49           ` Anthony Liguori
2011-03-24  8:32             ` Markus Armbruster

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=4D7E5507.8010205@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=agl@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=chrisw@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.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).