All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
	"Max Reitz" <mreitz@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@gmail.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"Kevin Wolf" <kwolf@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v13 6/6] qom: support arbitrary non-scalar properties with -object
Date: Mon, 19 Sep 2016 14:40:01 +0200	[thread overview]
Message-ID: <c1451a7c-1524-9d12-fdeb-d0073746b2cc@redhat.com> (raw)
In-Reply-To: <20160919122951.GO15201@redhat.com>



On 19/09/2016 14:29, Daniel P. Berrange wrote:
> On Mon, Sep 19, 2016 at 02:19:19PM +0200, Paolo Bonzini wrote:
>>
>>
>> On 19/09/2016 14:12, Daniel P. Berrange wrote:
>>> On Mon, Sep 19, 2016 at 12:58:30PM +0100, Daniel P. Berrange wrote:
>>>> The current -object command line syntax only allows for
>>>> creation of objects with scalar properties, or a list
>>>> with a fixed scalar element type. Objects which have
>>>> properties that are represented as structs in the QAPI
>>>> schema cannot be created using -object.
>>>>
>>>> This is a design limitation of the way the OptsVisitor
>>>> is written. It simply iterates over the QemuOpts values
>>>> as a flat list. The support for lists is enabled by
>>>> allowing the same key to be repeated in the opts string.
>>>>
>>>> It is not practical to extend the OptsVisitor to support
>>>> more complex data structures while also maintaining
>>>> the existing list handling behaviour that is relied upon
>>>> by other areas of QEMU.
>>>>
>>>> Fortunately there is no existing object that implements
>>>> the UserCreatable interface that relies on the list
>>>> handling behaviour, so it is possible to swap out the
>>>> OptsVisitor for a different visitor implementation, so
>>>> -object supports non-scalar properties, thus leaving
>>>> other users of OptsVisitor unaffected.
>>>
>>> Urgh, I've just discovered that this is not in fact true.
>>>
>>> The 'memory-backend' object type uses uint16List which
>>> has the hacky list syntax
>>>
>>>   -object memory-backend-ram,\
>>>           id=ram-node2,size=24578621440,policy=bind,\
>>>           host-nodes=1-2,host-nodes=5,host-nodes=7,
>>>
>>> So I'll need to figure out a way to preserve this syntax...
>>
>> Is there a usecase for qdict_crumple without the following
>> de-stringification pass?  If not, qdict_crumple could use a
>> StringInputVisitor on the values directly.
> 
> I'm not sure I understand how that would help and in any case, the
> string-input-visitor itself is incapable of dealing with compound
> properties.

> It too could/should be ultimately replaced by the
> qobject-input-visitor combined with a pre-processing step to
> turn the input string into a qdict.
> 
> The problem I'm facing with the above scenario though occurs
> before we get anywhere near the visitors, or the crumple step.
> 
> When qemu_opts_to_qdict() turns QemuOpts into QDict, it looses
> repeated options.

Ouch, I thought the problem was only with "1-2", not with the repeated
host-nodes.  Wow, that does really work?!?

What might work is if you convert the repeated options to
"host-nodes=1-2,5,7".  Then StringInputVisitor is able to parse that
(but OptsVisitor isn't).

I'm not sure if there are other uses of repeated options.  Probably not
based on a limited inspection of callers of qemu_opt_foreach.

Paolo

> What I need to do is make qemu_opts_to_qdict more intelligent
> so that if it sees repeated strings, it inserts them into the
> qdict using list index style. eg, the QemuOpts -> QDict
> conversion should have at minimum given us
> 
>     type=memory-backend-ram
>     id=ram-node2
>     size=24578621440
>     policy=bind
>     host-nodes.0=1-2
>     host-nodes.1=5
>     host-nodes.2=7
> 
> although even then there's some magic in the range value seen there. I'm
> unclear on whether we should try to deal with the range "1-2" in the
> qemu_opts_to_qdict() method, the qdict_crumple() method or the qobject
> input visitor code for parsing ints.
> 
> Regards,
> Daniel
> 

  reply	other threads:[~2016-09-19 12:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-19 11:58 [Qemu-devel] [PATCH v13 0/6] QAPI/QOM work for non-scalar object properties Daniel P. Berrange
2016-09-19 11:58 ` [Qemu-devel] [PATCH v13 1/6] qdict: implement a qdict_crumple method for un-flattening a dict Daniel P. Berrange
2016-09-19 11:58 ` [Qemu-devel] [PATCH v13 2/6] option: make parse_option_bool/number non-static Daniel P. Berrange
2016-09-23 10:24   ` Kevin Wolf
2016-09-23 11:07     ` Daniel P. Berrange
2016-09-23 14:16       ` Eric Blake
2016-09-23 14:21         ` Daniel P. Berrange
2016-09-19 11:58 ` [Qemu-devel] [PATCH v13 3/6] qapi: rename QmpInputVisitor to QObjectInputVisitor Daniel P. Berrange
2016-09-19 11:58 ` [Qemu-devel] [PATCH v13 4/6] qapi: rename QmpOutputVisitor to QObjectOutputVisitor Daniel P. Berrange
2016-09-19 11:58 ` [Qemu-devel] [PATCH v13 5/6] qapi: add a QObjectInputVisitor that does string conversion Daniel P. Berrange
2016-09-19 11:58 ` [Qemu-devel] [PATCH v13 6/6] qom: support arbitrary non-scalar properties with -object Daniel P. Berrange
2016-09-19 12:12   ` Daniel P. Berrange
2016-09-19 12:19     ` Paolo Bonzini
2016-09-19 12:29       ` Daniel P. Berrange
2016-09-19 12:40         ` Paolo Bonzini [this message]
2016-09-23 10:29     ` Kevin Wolf
2016-09-23 11:07       ` Daniel P. Berrange
2016-09-23 11:12         ` Kevin Wolf

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=c1451a7c-1524-9d12-fdeb-d0073746b2cc@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=afaerber@suse.de \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=mreitz@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.