From: Paolo Bonzini <pbonzini@redhat.com>
To: arei.gonglei@huawei.com, qemu-devel@nongnu.org
Cc: weidong.huang@huawei.com, lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qmp: using genneric string paring function for 'qom-set'
Date: Thu, 28 Aug 2014 13:05:56 +0200 [thread overview]
Message-ID: <53FF0D14.4030405@redhat.com> (raw)
In-Reply-To: <1409203145-5976-1-git-send-email-arei.gonglei@huawei.com>
Il 28/08/2014 07:19, arei.gonglei@huawei.com ha scritto:
> From: Gonglei <arei.gonglei@huawei.com>
>
> At present, 'qom-set' only can set string type property,
> which will restrict this qmp command's function.
> Using genneric string paring function can handle different
> types, such as int/bool/string etc.
Actually, that's not true. You can pass JSON integers or booleans to
qom-set; they will work and, most important, will be type safe!
It's a bug in qom-set that it doesn't let you pass integers or booleans.
Perhaps qom-set could have a -j option where the value argument is not
treated as a string, but rather as a JSON value? Or it could special
case numbers and true/false itself?
Paolo
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> Example:
> # ./scripts/qmp/qom-set nic1.realized false
> Traceback (most recent call last):
> File "./scripts/qmp/qom-set", line 64, in <module>
> print srv.command('qom-set', path=path, property=prop, value=sys.argv[2])
> File "/mnt/sdb/gonglei/qemu.git/qemu/scripts/qmp/qmp.py", line 136, in command
> raise Exception(ret['error']['desc'])
> Exception: Invalid parameter type for 'realized', expected: boolean
> ---
> qmp.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/qmp.c b/qmp.c
> index c6767c4..0a67c01 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -219,7 +219,7 @@ int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret)
> {
> const char *path = qdict_get_str(qdict, "path");
> const char *property = qdict_get_str(qdict, "property");
> - QObject *value = qdict_get(qdict, "value");
> + const char *value = qdict_get_str(qdict, "value");
> Error *local_err = NULL;
> Object *obj;
>
> @@ -229,7 +229,7 @@ int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret)
> goto out;
> }
>
> - object_property_set_qobject(obj, value, property, &local_err);
> + object_property_parse(obj, value, property, &local_err);
>
> out:
> if (local_err) {
>
next prev parent reply other threads:[~2014-08-28 11:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-28 5:19 [Qemu-devel] [PATCH] qmp: using genneric string paring function for 'qom-set' arei.gonglei
2014-08-28 11:05 ` Paolo Bonzini [this message]
2014-08-28 14:09 ` Gonglei (Arei)
2014-08-28 11:14 ` Eric Blake
2014-08-28 14:12 ` Gonglei (Arei)
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=53FF0D14.4030405@redhat.com \
--to=pbonzini@redhat.com \
--cc=arei.gonglei@huawei.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=weidong.huang@huawei.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 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.