scripts/qmp/qom-set: Allow setting integer value
PATCH v2 1/1 scripts/qmp/qom-set: Allow setting integer value
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
.. where sensor is a tmp105 device, and temperature is an integer property.
--- scripts/qmp/qom-set | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/qmp/qom-set +4 -1
@@ -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]) + except ValueError: + value = args[1] else: usage_error("not enough arguments")
Signature · 1 line
2.26.1
Hi Jonatan,
Quoted 5 lines · Jonatan Pålsson
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: integerQuoted 14 lines
.. where sensor is a tmp105 device, and temperature is an integer property.
Signed-off-by Jonatan Pålsson <[email protected]>--- scripts/qmp/qom-set | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)scripts/qmp/qom-set +0
-0
scripts/qmp/qom-set if len(args) > 1: · line 60
Quoted 6 lines
scripts/qmp/qom-set +2
-1@@ -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?
Quoted 6 lines
scripts/qmp/qom-set +2
-0+ except ValueError: + value = args[1] else: usage_error("not enough arguments")
Quoted 13 lines · Philippe Mathieu-Daudé
Hi Jonatan,
Quoted 5 lines · Jonatan Pålsson
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:
Quoted 9 lines
$ 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: integerNo, this is just relaying the error that QMP returned. QMP is telling you it doesn't want string data for this parameter. His diagnosis of the problem is accurate.
Quoted 9 lines
Quoted 9 lines
.. where sensor is a tmp105 device, and temperature is an integer property.
Signed-off-by Jonatan Pålsson <[email protected]>--- scripts/qmp/qom-set | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Quoted 14 lines
scripts/qmp/qom-set if len(args) > 1: · line 60
Quoted 11 lines
scripts/qmp/qom-set +2
-1@@ -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?
This is a Python patch, what's a "long"?
Quoted 7 lines
Quoted 6 lines
scripts/qmp/qom-set +2
-0+ except ValueError: + value = args[1] else: usage_error("not enough arguments")
Quoted 25 lines · John Snow
Quoted 13 lines · Philippe Mathieu-Daudé
Hi Jonatan,
Quoted 5 lines · Jonatan Pålsson
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:
Quoted 10 lines
$ 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
Quoted 3 lines
No, this is just relaying the error that QMP returned. QMP is telling you it doesn't want string data for this parameter. His diagnosis of the problem is accurate.
OK.
Quoted 25 lines
Quoted 10 lines
Quoted 10 lines
.. where sensor is a tmp105 device, and temperature is an integer property.
Signed-off-by Jonatan Pålsson <[email protected]>---
scripts/qmp/qom-set| 5 ++++-1 file changed, 4 insertions(+), 1 deletion(-)Quoted 14 lines
Quoted 11 lines
scripts/qmp/qom-set +0
-0@@ -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?
Quoted 1 line
This is a Python patch, what's a "long"?
I haven't finished the mental 2 -> 3 switch yet :/
Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
+ except ValueError:
+ value = args[1]
else:
usage_error("not enough arguments")