diff mbox

[3/4] qemu-iotests: Allow caller to disable underscore convertion for qmp

Message ID 1390984843-2101-4-git-send-email-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng Jan. 29, 2014, 8:40 a.m. UTC
QMP command "block_set_io_throttle" expects underscores in parameters
instead of dashes: {iops,bps}_{rd,wr,max}.

Add optional argument conv_keys (defaults to True, backward compatible),
it will be used in IO throttling test case.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 tests/qemu-iotests/iotests.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Eric Blake Jan. 29, 2014, 2:09 p.m. UTC | #1
On 01/29/2014 01:40 AM, Fam Zheng wrote:

s/convertion/conversion/ in the subject

> QMP command "block_set_io_throttle" expects underscores in parameters
> instead of dashes: {iops,bps}_{rd,wr,max}.
> 
> Add optional argument conv_keys (defaults to True, backward compatible),
> it will be used in IO throttling test case.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  tests/qemu-iotests/iotests.py | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 

You know, it might be nice to get the '-'/'_' looseness into QMP itself
when invoked via JSON strings over the monitor, rather than just the
testsuite wrapper, since we're already inconsistent in several commands.
 But that's a bigger project for another day.
Stefan Hajnoczi Jan. 29, 2014, 2:23 p.m. UTC | #2
On Wed, Jan 29, 2014 at 04:40:42PM +0800, Fam Zheng wrote:
> QMP command "block_set_io_throttle" expects underscores in parameters
> instead of dashes: {iops,bps}_{rd,wr,max}.
> 
> Add optional argument conv_keys (defaults to True, backward compatible),
> it will be used in IO throttling test case.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  tests/qemu-iotests/iotests.py | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Benoît Canet Jan. 29, 2014, 3:29 p.m. UTC | #3
Le Wednesday 29 Jan 2014 à 16:40:42 (+0800), Fam Zheng a écrit :
> QMP command "block_set_io_throttle" expects underscores in parameters
> instead of dashes: {iops,bps}_{rd,wr,max}.
> 
> Add optional argument conv_keys (defaults to True, backward compatible),
> it will be used in IO throttling test case.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  tests/qemu-iotests/iotests.py | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index ca79d09..c1f5427 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -179,11 +179,14 @@ class VM(object):
>              self._popen = None
>  
>      underscore_to_dash = string.maketrans('_', '-')
> -    def qmp(self, cmd, **args):
> +    def qmp(self, cmd, conv_keys=True, **args):
>          '''Invoke a QMP command and return the result dict'''
>          qmp_args = dict()
>          for k in args.keys():
> -            qmp_args[k.translate(self.underscore_to_dash)] = args[k]
> +            if conv_keys:
> +                qmp_args[k.translate(self.underscore_to_dash)] = args[k]
> +            else:
> +                qmp_args[k] = args[k]
>  
>          return self._qmp.cmd(cmd, args=qmp_args)
>  
> -- 
> 1.8.5.3
> 
> 
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Fam Zheng Feb. 1, 2014, 3:31 p.m. UTC | #4
On Wed, 01/29 07:09, Eric Blake wrote:
> On 01/29/2014 01:40 AM, Fam Zheng wrote:
> 
> s/convertion/conversion/ in the subject
> 
> > QMP command "block_set_io_throttle" expects underscores in parameters
> > instead of dashes: {iops,bps}_{rd,wr,max}.
> > 
> > Add optional argument conv_keys (defaults to True, backward compatible),
> > it will be used in IO throttling test case.
> > 
> > Signed-off-by: Fam Zheng <famz@redhat.com>
> > ---
> >  tests/qemu-iotests/iotests.py | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> 
> You know, it might be nice to get the '-'/'_' looseness into QMP itself
> when invoked via JSON strings over the monitor, rather than just the
> testsuite wrapper, since we're already inconsistent in several commands.
>  But that's a bigger project for another day.
> 

I agree. Let's stick to this now and leave the loosing in QMP for later.

Fam
diff mbox

Patch

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index ca79d09..c1f5427 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -179,11 +179,14 @@  class VM(object):
             self._popen = None
 
     underscore_to_dash = string.maketrans('_', '-')
-    def qmp(self, cmd, **args):
+    def qmp(self, cmd, conv_keys=True, **args):
         '''Invoke a QMP command and return the result dict'''
         qmp_args = dict()
         for k in args.keys():
-            qmp_args[k.translate(self.underscore_to_dash)] = args[k]
+            if conv_keys:
+                qmp_args[k.translate(self.underscore_to_dash)] = args[k]
+            else:
+                qmp_args[k] = args[k]
 
         return self._qmp.cmd(cmd, args=qmp_args)