qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: clg@kaod.org, berrange@redhat.com, qemu-devel@nongnu.org,
	afaerber@suse.de, armbru@redhat.com
Subject: Re: [PATCH 2/2] hmp: Simplify qom_set
Date: Wed, 20 May 2020 20:03:44 +0100	[thread overview]
Message-ID: <20200520190344.GG2820@work-vm> (raw)
In-Reply-To: <1f627a6b-9c5f-09b3-8f75-64e95a4f5d02@redhat.com>

* Philippe Mathieu-Daudé (philmd@redhat.com) wrote:
> On 5/20/20 5:11 PM, Dr. David Alan Gilbert (git) wrote:
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> > 
> > Simplify qom_set by making it use qmp_qom_set and the JSON parser.
> > 
> > Note that qom-set likes JSON strings quoted with ' not ", e.g.:
> > 
> > (qemu) qom-get /machine smm
> > "auto"
> > (qemu) qom-set /machine smm 'auto'
> 
> Will I get this output using "?
> 
> (qemu) qom-set /machine smm "auto"
> Error: Expecting a JSON value

The error you get is:

(qemu) qom-set /machine smm "auto"
Error: JSON parse error, invalid keyword 'auto'

I think, having seen alphanumerics, it's expecting a keyword;
i.e. a true/false making a bool, or a null.

Dave

> > 
> > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> > ---
> >   qom/qom-hmp-cmds.c | 16 +++++-----------
> >   1 file changed, 5 insertions(+), 11 deletions(-)
> > 
> > diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c
> > index a8b0a080c7..f704b6949a 100644
> > --- a/qom/qom-hmp-cmds.c
> > +++ b/qom/qom-hmp-cmds.c
> > @@ -48,19 +48,13 @@ void hmp_qom_set(Monitor *mon, const QDict *qdict)
> >       const char *property = qdict_get_str(qdict, "property");
> >       const char *value = qdict_get_str(qdict, "value");
> >       Error *err = NULL;
> > -    bool ambiguous = false;
> > -    Object *obj;
> > +    QObject *obj;
> > -    obj = object_resolve_path(path, &ambiguous);
> > -    if (obj == NULL) {
> > -        error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
> > -                  "Device '%s' not found", path);
> > -    } else {
> > -        if (ambiguous) {
> > -            monitor_printf(mon, "Warning: Path '%s' is ambiguous\n", path);
> > -        }
> > -        object_property_parse(obj, value, property, &err);
> > +    obj = qobject_from_json(value, &err);
> > +    if (err == NULL) {
> > +        qmp_qom_set(path, property, obj, &err);
> >       }
> > +
> >       hmp_handle_error(mon, err);
> >   }
> > 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



  reply	other threads:[~2020-05-20 19:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-20 15:11 [PATCH 0/2] HMP: qom-get and set Dr. David Alan Gilbert (git)
2020-05-20 15:11 ` [PATCH 1/2] hmp: Implement qom-get HMP command Dr. David Alan Gilbert (git)
2020-05-20 16:44   ` Philippe Mathieu-Daudé
2020-05-25  9:02   ` Markus Armbruster
2020-05-29  6:59     ` Markus Armbruster
2020-05-20 15:11 ` [PATCH 2/2] hmp: Simplify qom_set Dr. David Alan Gilbert (git)
2020-05-20 16:47   ` Philippe Mathieu-Daudé
2020-05-20 19:03     ` Dr. David Alan Gilbert [this message]
2020-05-25  8:54       ` Markus Armbruster
2020-05-28 14:06         ` Dr. David Alan Gilbert
2020-05-28 15:12           ` Philippe Mathieu-Daudé
2020-05-29  6:20           ` Markus Armbruster
2020-05-29  9:07             ` Dr. David Alan Gilbert
2020-05-29 18:48 ` [PATCH 0/2] HMP: qom-get and set Dr. David Alan Gilbert

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=20200520190344.GG2820@work-vm \
    --to=dgilbert@redhat.com \
    --cc=afaerber@suse.de \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=clg@kaod.org \
    --cc=philmd@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).