* [Qemu-devel] [PATCH] qmp: allow setting properties to empty string in qmp-shell
@ 2017-03-02 12:24 Daniel P. Berrange
2017-03-02 16:03 ` Eric Blake
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Daniel P. Berrange @ 2017-03-02 12:24 UTC (permalink / raw)
To: qemu-devel; +Cc: Markus Armbruster, qemu-trivial, 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.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
scripts/qmp/qmp-shell | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index 0373b24..eccb88a 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -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)
--
2.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] qmp: allow setting properties to empty string in qmp-shell
2017-03-02 12:24 [Qemu-devel] [PATCH] qmp: allow setting properties to empty string in qmp-shell Daniel P. Berrange
@ 2017-03-02 16:03 ` Eric Blake
2017-03-03 17:15 ` John Snow
2017-03-06 8:19 ` Markus Armbruster
2 siblings, 0 replies; 4+ messages in thread
From: Eric Blake @ 2017-03-02 16:03 UTC (permalink / raw)
To: Daniel P. Berrange, qemu-devel; +Cc: qemu-trivial, Markus Armbruster
[-- Attachment #1: Type: text/plain, Size: 1725 bytes --]
On 03/02/2017 06:24 AM, Daniel P. Berrange wrote:
> 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.
>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
> scripts/qmp/qmp-shell | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Eric Blake <eblake@redhat.com>
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.
>
> diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
> index 0373b24..eccb88a 100755
> --- a/scripts/qmp/qmp-shell
> +++ b/scripts/qmp/qmp-shell
> @@ -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)
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] qmp: allow setting properties to empty string in qmp-shell
2017-03-02 12:24 [Qemu-devel] [PATCH] qmp: allow setting properties to empty string in qmp-shell Daniel P. Berrange
2017-03-02 16:03 ` Eric Blake
@ 2017-03-03 17:15 ` John Snow
2017-03-06 8:19 ` Markus Armbruster
2 siblings, 0 replies; 4+ messages in thread
From: John Snow @ 2017-03-03 17:15 UTC (permalink / raw)
To: Daniel P. Berrange, qemu-devel; +Cc: qemu-trivial, Markus Armbruster
On 03/02/2017 07:24 AM, Daniel P. Berrange wrote:
> 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.
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
> ---
> scripts/qmp/qmp-shell | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
> index 0373b24..eccb88a 100755
> --- a/scripts/qmp/qmp-shell
> +++ b/scripts/qmp/qmp-shell
> @@ -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)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] qmp: allow setting properties to empty string in qmp-shell
2017-03-02 12:24 [Qemu-devel] [PATCH] qmp: allow setting properties to empty string in qmp-shell Daniel P. Berrange
2017-03-02 16:03 ` Eric Blake
2017-03-03 17:15 ` John Snow
@ 2017-03-06 8:19 ` Markus Armbruster
2 siblings, 0 replies; 4+ messages in thread
From: Markus Armbruster @ 2017-03-06 8:19 UTC (permalink / raw)
To: Daniel P. Berrange; +Cc: qemu-devel, qemu-trivial
"Daniel P. Berrange" <berrange@redhat.com> writes:
> 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.
>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
I'll take this through my tree, unless qemu-trivial beats me to the
punch. Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-06 8:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-02 12:24 [Qemu-devel] [PATCH] qmp: allow setting properties to empty string in qmp-shell Daniel P. Berrange
2017-03-02 16:03 ` Eric Blake
2017-03-03 17:15 ` John Snow
2017-03-06 8:19 ` Markus Armbruster
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).