qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] qmp: allow setting properties to empty string in qmp-shell
Date: Fri, 3 Mar 2017 12:15:50 -0500	[thread overview]
Message-ID: <194be75d-52ae-757f-2dbb-f8f4597cec67@redhat.com> (raw)
In-Reply-To: <20170302122429.7737-1-berrange@redhat.com>



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)
> 

  parent reply	other threads:[~2017-03-03 17:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2017-03-06  8:19 ` Markus Armbruster

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=194be75d-52ae-757f-2dbb-f8f4597cec67@redhat.com \
    --to=jsnow@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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).