From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: "Jonatan Pålsson" <jonatan.p@gmail.com>
Cc: John Snow <jsnow@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH v2] scripts/qmp/qom-set: Allow setting integer value
Date: Sat, 3 Oct 2020 19:33:19 +0200 [thread overview]
Message-ID: <2f65b14a-7073-300f-df86-4df55675e1ca@redhat.com> (raw)
In-Reply-To: <20201002205200.276477-1-jonatan.p@gmail.com>
Hi Jonatan,
On 10/2/20 10:52 PM, Jonatan Pålsson wrote:
> If the value appears to be an integer, parse it as such.
>
> This allows the following:
>
> qmp/qom-set -s ~/qmp.sock sensor.temperature 20000
Maybe instead:
Fix the following error:
$ scripts/qmp/qom-set -s ~/qmp.sock sensor.temperature 20000
Traceback (most recent call last):
File "scripts/qmp/qom-set", line 66, in <module>
print(srv.command('qom-set', path=path, property=prop, value=value))
File "scripts/qmp/../../python/qemu/qmp.py", line 274, in command
raise QMPResponseError(ret)
qemu.qmp.QMPResponseError: Invalid parameter type for 'temperature',
expected: integer
>
> .. where sensor is a tmp105 device, and temperature is an integer
> property.
>
> Signed-off-by: Jonatan Pålsson <jonatan.p@gmail.com>
> ---
> scripts/qmp/qom-set | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/qmp/qom-set b/scripts/qmp/qom-set
> index 240a78187f..49eebe4924 100755
> --- a/scripts/qmp/qom-set
> +++ b/scripts/qmp/qom-set
> @@ -56,7 +56,10 @@ if len(args) > 1:
> path, prop = args[0].rsplit('.', 1)
> except:
> usage_error("invalid format for path/property/value")
> - value = args[1]
> + try:
> + value = int(args[1])
Maybe 'long' is safer?
> + except ValueError:
> + value = args[1]
> else:
> usage_error("not enough arguments")
>
>
next prev parent reply other threads:[~2020-10-03 17:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-02 20:52 [PATCH v2] scripts/qmp/qom-set: Allow setting integer value Jonatan Pålsson
2020-10-03 17:33 ` Philippe Mathieu-Daudé [this message]
2020-10-03 23:55 ` John Snow
2020-10-04 9:46 ` Philippe Mathieu-Daudé
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=2f65b14a-7073-300f-df86-4df55675e1ca@redhat.com \
--to=philmd@redhat.com \
--cc=jonatan.p@gmail.com \
--cc=jsnow@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).