All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qmp: fix handling of cmd with Equals in qmp-shell
@ 2013-05-06  8:37 Zhangleiqiang
  0 siblings, 0 replies; 3+ messages in thread
From: Zhangleiqiang @ 2013-05-06  8:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Zhangleiqiang, armbru, lcapitulino


	qmp: fix handling of cmd with equal mark in qmp-shell

    qmp-shell splits the argument and value of input command
	by equal mark("="). But there are commands whose values
	include equal mark themselves, and the json built by
	qmp-shell will not correct. For example, when using NBD as
	the target of block-backup command, the input
	"block-backup target=nbd+unix:///drive0?socket=/tmp/nbd.sock"
	will fail, because the json built will be as follows:

    {
		"execute":"block-backup",
		"arguments":{"target":"nbd+unix:///drive0?socket"}
	}

    Fix it by joining the sections split by equal mark excluding the
	first section in __build_cmd function when the length of sections
	is larger than two.

Signed-off-by: zhangleiqiang <zhangleiqiang@huawei.com>
---
 QMP/qmp-shell | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/QMP/qmp-shell b/QMP/qmp-shell
index d126e63..73cb3b6 100755
--- a/QMP/qmp-shell
+++ b/QMP/qmp-shell
@@ -99,6 +99,8 @@ class QMPShell(qmp.QEMUMonitorProtocol):
         for arg in cmdargs[1:]:
             opt = arg.split('=')
             try:
+                if(len(opt) > 2):
+                    opt[1] = '='.join(opt[1:])
                 value = int(opt[1])
             except ValueError:
                 if opt[1] == 'true':
-- 
1.8.1.4


----------
Leiqzhang

Best Regards

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qmp: fix handling of cmd with Equals in qmp-shell
  2013-05-06  8:31 Zhangleiqiang
@ 2013-05-06 16:09 ` Luiz Capitulino
  0 siblings, 0 replies; 3+ messages in thread
From: Luiz Capitulino @ 2013-05-06 16:09 UTC (permalink / raw)
  To: Zhangleiqiang; +Cc: armbru, qemu-devel

On Mon, 6 May 2013 08:31:23 +0000
Zhangleiqiang <zhangleiqiang@huawei.com> wrote:

> 	qmp: fix handling of cmd with equal mark in qmp-shell
> 
>     qmp-shell splits the argument and value of input command
> 	by equal mark("="). But there are commands whose values
> 	include equal mark themselves, and the json built by
> 	qmp-shell will not correct. For example, when using NBD as
> 	the target of block-backup command, the input
> 	"block-backup target=nbd+unix:///drive0?socket=/tmp/nbd.sock"
> 	will fail, because the json built will be as follows:
> 
>     {
> 		"execute":"block-backup",
> 		"arguments":{"target":"nbd+unix:///drive0?socket"}
> 	}
> 
>     Fix it by joining the sections split by equal mark excluding the
> 	first section in __build_cmd function when the length of sections
> 	is larger than two.
> 
> Signed-off-by: zhangleiqiang <zhangleiqiang@huawei.com>

Applied to the qmp branch, thanks.

> ---
>  QMP/qmp-shell | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/QMP/qmp-shell b/QMP/qmp-shell
> index d126e63..73cb3b6 100755
> --- a/QMP/qmp-shell
> +++ b/QMP/qmp-shell
> @@ -99,6 +99,8 @@ class QMPShell(qmp.QEMUMonitorProtocol):
>          for arg in cmdargs[1:]:
>              opt = arg.split('=')
>              try:
> +                if(len(opt) > 2):
> +                    opt[1] = '='.join(opt[1:])
>                  value = int(opt[1])
>              except ValueError:
>                  if opt[1] == 'true':

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH] qmp: fix handling of cmd with Equals in qmp-shell
@ 2013-05-06  8:31 Zhangleiqiang
  2013-05-06 16:09 ` Luiz Capitulino
  0 siblings, 1 reply; 3+ messages in thread
From: Zhangleiqiang @ 2013-05-06  8:31 UTC (permalink / raw)
  To: lcapitulino, armbru; +Cc: Zhangleiqiang, qemu-devel

	qmp: fix handling of cmd with equal mark in qmp-shell

    qmp-shell splits the argument and value of input command
	by equal mark("="). But there are commands whose values
	include equal mark themselves, and the json built by
	qmp-shell will not correct. For example, when using NBD as
	the target of block-backup command, the input
	"block-backup target=nbd+unix:///drive0?socket=/tmp/nbd.sock"
	will fail, because the json built will be as follows:

    {
		"execute":"block-backup",
		"arguments":{"target":"nbd+unix:///drive0?socket"}
	}

    Fix it by joining the sections split by equal mark excluding the
	first section in __build_cmd function when the length of sections
	is larger than two.

Signed-off-by: zhangleiqiang <zhangleiqiang@huawei.com>
---
 QMP/qmp-shell | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/QMP/qmp-shell b/QMP/qmp-shell
index d126e63..73cb3b6 100755
--- a/QMP/qmp-shell
+++ b/QMP/qmp-shell
@@ -99,6 +99,8 @@ class QMPShell(qmp.QEMUMonitorProtocol):
         for arg in cmdargs[1:]:
             opt = arg.split('=')
             try:
+                if(len(opt) > 2):
+                    opt[1] = '='.join(opt[1:])
                 value = int(opt[1])
             except ValueError:
                 if opt[1] == 'true':
-- 
1.8.1.4


----------
Leiqzhang

Best Regards

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-06 16:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-06  8:37 [Qemu-devel] [PATCH] qmp: fix handling of cmd with Equals in qmp-shell Zhangleiqiang
  -- strict thread matches above, loose matches on Subject: below --
2013-05-06  8:31 Zhangleiqiang
2013-05-06 16:09 ` Luiz Capitulino

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.