qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Eric Blake <eblake@redhat.com>,
	kwolf@redhat.com, pbonzini@redhat.com, el13635@mail.ntua.gr,
	qemu-devel@nongnu.org, f4bug@amsat.org
Subject: Re: [Qemu-devel] [PATCH v2 2/2] vl: Partial support for non-scalar properties with -object
Date: Mon, 16 Apr 2018 17:24:34 +0100	[thread overview]
Message-ID: <20180416162434.GB12819@redhat.com> (raw)
In-Reply-To: <87shgusnp9.fsf@dusky.pond.sub.org>

On Mon, Aug 14, 2017 at 07:49:54AM +0200, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
> 
> > On 08/11/2017 11:05 AM, Markus Armbruster wrote:
> >> We've wanted -object to support non-scalar properties for a while.
> >> Dan Berrange tried in "[PATCH v4 00/10]Provide a QOM-based
> >> authorization API".  Review led to the conclusion that we need to
> >> replace rather than add to QemuOpts.  Initial work towards that goal
> >> has been merged to provide -blockdev (commit 8746709), but there's
> >> substantial work left, mostly due to an bewildering array of
> >> compatibility problems.
> >> 
> >> Even if a full solution is still out of reach, we can have a partial
> >> solution now: accept -object argument in JSON syntax.  This should
> >> unblock development work that needs non-scalar properties with
> >> -object.
> >> 
> >> The implementation is similar to -blockdev, except we use the new
> >> infrastructure only for the new JSON case, and stick to QemuOpts for
> >> the existing KEY=VALUE,... case, to sidestep compatibility problems.
> >> 
> >> If we did this for more options, we'd have to factor out common code.
> >> But for one option, this will do.
> >> 
> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> >> ---
> >>  qapi-schema.json | 14 +++++++++++---
> >>  vl.c             | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
> >>  2 files changed, 62 insertions(+), 3 deletions(-)
> >> 
> >>  static void object_create(bool (*type_predicate)(const char *))
> >>  {
> >> +    ObjectOptionsQueueEntry *e, *next;
> >> +
> >> +    QSIMPLEQ_FOREACH_SAFE(e, &oo_queue, entry, next) {
> >> +        if (!type_predicate(e->oo->qom_type)) {
> >> +            continue;
> >> +        }
> >> +
> >> +        loc_push_restore(&e->loc);
> >> +        qmp_object_add(e->oo->qom_type, e->oo->id,
> >> +                       e->oo->has_props, e->oo->props, &error_fatal);
> >> +        loc_pop(&e->loc);
> >> +
> >> +        QSIMPLEQ_REMOVE(&oo_queue, e, ObjectOptionsQueueEntry, entry);
> >> +        qapi_free_ObjectOptions(e->oo);
> >> +    }
> >> +
> >>      if (qemu_opts_foreach(qemu_find_opts("object"),
> >
> > This handles all JSON forms prior to any QemuOpt forms (within the two
> > priority levels), such that a command line using:
> >
> >  -object type,id=1,oldstyle... -object '{'id':2, 'type':..., newstyle...}'
> >
> > processes the arguments in a different order than
> >
> >  -object type,id=1,oldstyle... -object type,id=2,oldstyle
> >
> > But I don't see that as too bad (ideally, someone using the {} JSON
> > style will use it consistently).
> 
> Yes, that's another restriction: if you need your -object evaluated in a
> certain order, you may have to stick to one of the two syntax variants.
> 
> Aside: there are two sane evaluation orders: (1) strictly left to right,
> and (2) order doesn't matter.  QEMU of course does (3) unpredicable for
> humans without referring back to the source code.

IIUC, to "fix" the ordering problem we need to be able to consider the
ordering of all QEMU args, not just -object.  

The horrible hack with the two stage setup of -object in vl.c is driven by
the fact that some objects are referenced by -device/-chardev args, while
objects are referencing -device/-chardev args etc. This is the big problem
to untangle, and understandable you don't want to tackle that for this
patch. Until we can figure out how to address the big problem, it would be
nice not to introduce yet another ordering though driven off usage of
json vs non-json syntax.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

  reply	other threads:[~2018-04-16 16:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-11 16:05 [Qemu-devel] [PATCH v2 0/2] vl: Partial support for non-scalar properties with -object Markus Armbruster
2017-08-11 16:05 ` [Qemu-devel] [PATCH v2 1/2] vl: Factor object_create() out of main() Markus Armbruster
2017-08-11 16:05 ` [Qemu-devel] [PATCH v2 2/2] vl: Partial support for non-scalar properties with -object Markus Armbruster
2017-08-11 17:47   ` Eric Blake
2017-08-14  5:49     ` Markus Armbruster
2018-04-16 16:24       ` Daniel P. Berrangé [this message]
2018-05-28  9:30         ` Markus Armbruster
2017-08-14  9:44     ` Daniel P. Berrange
2017-08-14 11:24       ` Markus Armbruster
2018-04-16 16:29         ` Daniel P. Berrangé
2018-05-28  9:14           ` Markus Armbruster
2018-04-16 16:17 ` [Qemu-devel] [PATCH v2 0/2] " Daniel P. Berrangé
2018-05-28  9:31   ` Markus Armbruster
2018-06-08 17:11     ` Daniel P. Berrangé

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=20180416162434.GB12819@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=el13635@mail.ntua.gr \
    --cc=f4bug@amsat.org \
    --cc=kwolf@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).