From patchwork Tue Jul 24 11:03:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 172878 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 8A9392C008A for ; Tue, 24 Jul 2012 22:45:58 +1000 (EST) Received: from localhost ([::1]:41968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Stcwr-0008SG-6d for incoming@patchwork.ozlabs.org; Tue, 24 Jul 2012 07:06:41 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Stcve-0006fG-2K for qemu-devel@nongnu.org; Tue, 24 Jul 2012 07:05:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Stcvc-0005SY-So for qemu-devel@nongnu.org; Tue, 24 Jul 2012 07:05:25 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:36778) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Stcvc-00058R-Nh for qemu-devel@nongnu.org; Tue, 24 Jul 2012 07:05:24 -0400 Received: by mail-yw0-f45.google.com with SMTP id p34so6575216yhp.4 for ; Tue, 24 Jul 2012 04:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=xKHlJpYk7KnBJ/uBcVofhZF8YxlWerxzijS3MAf3zpU=; b=hGruLczFq3Q9iz6aWZMIeS6d9WHm55VjMpGtv8XwDy4X2ERCLSt/vpYnj/VQDYPeib vP3UCQB2KAAlWh8sC6nTS+tAxakzZSv5tG103fXdrNX4OzceYu9rALnhCeYrF3yG/Q0E ZIWMfUh8yHkFZ+BlULczGpLpd/AvRElXIrUJKuM3kMh4Ez2gY3y1mMjWjsMPfdo7/TZR OJFvbqtOvZ0jTnttdsjMkA9esLYZsUuVXLZ3/WeZhHx91egDeJd6CSa/4UIcCGino9pr Dps5Yb9lQOBl0BJuHhTOp4BW94BBt0zhA1S4DjgZqyEXeu7zC6+zlxnckxvm35/Jwfe+ 0mLw== Received: by 10.42.145.7 with SMTP id d7mr14391235icv.45.1343127924367; Tue, 24 Jul 2012 04:05:24 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-189-113.ip51.fastwebnet.it. [93.34.189.113]) by mx.google.com with ESMTPS id if4sm1752561igc.10.2012.07.24.04.05.21 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Jul 2012 04:05:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 24 Jul 2012 13:03:54 +0200 Message-Id: <1343127865-16608-17-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1343127865-16608-1-git-send-email-pbonzini@redhat.com> References: <1343127865-16608-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.213.45 Cc: kwolf@redhat.com, jcody@redhat.com, eblake@redhat.com, stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 16/47] 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 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 --- tests/qemu-iotests/iotests.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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'''