From patchwork Fri Sep 28 17:57:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 187884 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B75742C00CE for ; Sat, 29 Sep 2012 05:09:27 +1000 (EST) Received: from localhost ([::1]:47044 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THfj1-0000c5-3b for incoming@patchwork.ozlabs.org; Fri, 28 Sep 2012 14:55:47 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THfhu-00061x-3D for qemu-devel@nongnu.org; Fri, 28 Sep 2012 14:54:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THfhr-0006uQ-6A for qemu-devel@nongnu.org; Fri, 28 Sep 2012 14:54:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31744) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THfhq-0006tO-T6 for qemu-devel@nongnu.org; Fri, 28 Sep 2012 14:54:35 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8SIsWjh011370 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 28 Sep 2012 14:54:32 -0400 Received: from dhcp-5-188.str.redhat.com (vpn1-7-84.ams2.redhat.com [10.36.7.84]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q8SHvF3W020617; Fri, 28 Sep 2012 13:57:57 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 28 Sep 2012 19:57:12 +0200 Message-Id: <1348855033-17174-30-git-send-email-kwolf@redhat.com> In-Reply-To: <1348855033-17174-1-git-send-email-kwolf@redhat.com> References: <1348855033-17174-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 29/30] qemu-iotests: map underscore to dash in QMP argument names X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Paolo Bonzini iotests.py provides a convenience function that uses Python keyword arguments to represent QMP command arguments. However, almost all QMP commands use dashes for argument names (the sole exception is block_set_io_throttle), and dashes are not allowed in a keyword argument name. Hence provide automatic conversion of underscores to dashes. Signed-off-by: Paolo Bonzini Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- tests/qemu-iotests/iotests.py | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index e05b1d6..a94ea75 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -19,6 +19,7 @@ import os import re import subprocess +import string import unittest import sys; sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'QMP')) import qmp @@ -96,9 +97,14 @@ class VM(object): os.remove(self._qemu_log_path) self._popen = None + underscore_to_dash = string.maketrans('_', '-') def qmp(self, cmd, **args): '''Invoke a QMP command and return the result dict''' - return self._qmp.cmd(cmd, args=args) + qmp_args = dict() + for k in args.keys(): + qmp_args[k.translate(self.underscore_to_dash)] = args[k] + + return self._qmp.cmd(cmd, args=qmp_args) def get_qmp_events(self, wait=False): '''Poll for queued QMP events and return a list of dicts'''