qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] hmp: Simplify qom_set


From: Dr. David Alan Gilbert
Subject: Re: [PATCH 2/2] hmp: Simplify qom_set
Date: Wed, 20 May 2020 20:03:44 +0100
User-agent: Mutt/1.13.4 (2020-02-15)

* Philippe Mathieu-Daudé (address@hidden) wrote:
> On 5/20/20 5:11 PM, Dr. David Alan Gilbert (git) wrote:
> > From: "Dr. David Alan Gilbert" <address@hidden>
> > 
> > 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 <address@hidden>
> > ---
> >   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 / address@hidden / Manchester, UK




reply via email to

[Prev in Thread] Current Thread [Next in Thread]