qmp: allow setting properties to empty string in qmp-shell
PATCH 1/1 qmp: allow setting properties to empty string in qmp-shell
The qmp-shell property parser currently rejects attempts to set string properties to the empty string eg
(QEMU) migrate-set-parameters tls-hostname=
Error while parsing command line: Expected a key=value pair, got 'tls-hostname='
command format: <command-name> [arg-name1=arg1] ... [arg-nameN=argN]
This is caused by checking the wrong condition after splitting the parameter on '='. The "partition" method will return "" for the separator field, if the seperator was not present, so that is the correct thing to check for malformed syntax.
--- scripts/qmp/qmp-shell | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/qmp/qmp-shell +2 -2
@@ -166,8 +166,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): def __cli_expr(self, tokens, parent): for arg in tokens: - (key, _, val) = arg.partition('=') - if not val: + (key, sep, val) = arg.partition('=') + if sep != '=': raise QMPShellError("Expected a key=value pair, got '%s'" % arg) value = self.__parse_value(val)
Signature · 1 line
2.9.3
Quoted 12 lines · Daniel P. Berrange
The qmp-shell property parser currently rejects attempts to set string properties to the empty string eg
(QEMU) migrate-set-parameters tls-hostname=
Error while parsing command line: Expected a key=value pair, got 'tls-hostname='
command format: <command-name> [arg-name1=arg1] ... [arg-nameN=argN]This is caused by checking the wrong condition after splitting the parameter on '='. The "partition" method will return "" for the separator field, if the seperator was not present, so that is the correct thing to check for malformed syntax.
Quoted 4 lines
Signed-off-by Daniel P. Berrange <[email protected]>--- scripts/qmp/qmp-shell | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Probably worth having in 2.9, since we are having the parallel discussion about permitting an empty string as a way to clear out TLS in migration parameters.
Quoted 17 lines
scripts/qmp/qmp-shell +2
-2@@ -166,8 +166,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): def __cli_expr(self, tokens, parent): for arg in tokens: - (key, _, val) = arg.partition('=') - if not val: + (key, sep, val) = arg.partition('=') + if sep != '=': raise QMPShellError("Expected a key=value pair, got '%s'" % arg) value = self.__parse_value(val)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 12 lines · Daniel P. Berrange
The qmp-shell property parser currently rejects attempts to set string properties to the empty string eg
(QEMU) migrate-set-parameters tls-hostname=
Error while parsing command line: Expected a key=value pair, got 'tls-hostname='
command format: <command-name> [arg-name1=arg1] ... [arg-nameN=argN]This is caused by checking the wrong condition after splitting the parameter on '='. The "partition" method will return "" for the separator field, if the seperator was not present, so that is the correct thing to check for malformed syntax.
Ah, good point.
Quoted 1 line
Signed-off-by Daniel P. Berrange <[email protected]>
Quoted 20 lines
--- scripts/qmp/qmp-shell | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)scripts/qmp/qmp-shell +2
-2@@ -166,8 +166,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): def __cli_expr(self, tokens, parent): for arg in tokens: - (key, _, val) = arg.partition('=') - if not val: + (key, sep, val) = arg.partition('=') + if sep != '=': raise QMPShellError("Expected a key=value pair, got '%s'" % arg) value = self.__parse_value(val)
Quoted 7 lines · Daniel P. Berrange
The qmp-shell property parser currently rejects attempts to set string properties to the empty string eg
(QEMU) migrate-set-parameters tls-hostname=
Error while parsing command line: Expected a key=value pair, got 'tls-hostname='
command format: <command-name> [arg-name1=arg1] ... [arg-nameN=argN]
Quoted 6 lines
This is caused by checking the wrong condition after splitting the parameter on '='. The "partition" method will return "" for the separator field, if the seperator was not present, so that is the correct thing to check for malformed syntax.
Signed-off-by Daniel P. Berrange <[email protected]>
I'll take this through my tree, unless qemu-trivial beats me to the punch. Thanks!