From patchwork Mon Dec 12 20:18:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 130820 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E7D3E1007D7 for ; Tue, 13 Dec 2011 07:23:09 +1100 (EST) Received: from localhost ([::1]:55489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaCOu-0003PW-EP for incoming@patchwork.ozlabs.org; Mon, 12 Dec 2011 15:23:04 -0500 Received: from eggs.gnu.org ([140.186.70.92]:42077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaCOe-0002xb-22 for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:22:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaCOc-0000eK-GH for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:22:47 -0500 Received: from cpe-70-123-132-139.austin.res.rr.com ([70.123.132.139]:44532 helo=localhost6.localdomain6) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaCOc-0000eE-3v for qemu-devel@nongnu.org; Mon, 12 Dec 2011 15:22:46 -0500 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by localhost6.localdomain6 (8.14.4/8.14.4/Debian-2ubuntu1) with ESMTP id pBCKMYoo032560; Mon, 12 Dec 2011 14:22:35 -0600 Received: (from anthony@localhost) by localhost6.localdomain6 (8.14.4/8.14.4/Submit) id pBCKMX3A032559; Mon, 12 Dec 2011 14:22:33 -0600 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Mon, 12 Dec 2011 14:18:14 -0600 Message-Id: <1323721273-32404-19-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1323721273-32404-1-git-send-email-aliguori@us.ibm.com> References: <1323721273-32404-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 70.123.132.139 Cc: Kevin Wolf , Peter Maydell , Anthony Liguori , Stefan Hajnoczi , Jan Kiszka , Markus Armbruster , Luiz Capitulino Subject: [Qemu-devel] [PATCH v3 018/197] qom: add test tools (v2) 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 Signed-off-by: Anthony Liguori --- v1 -> v2 - fix comments (Stefan) --- QMP/qom-get | 26 ++++++++++++++++++++++++++ QMP/qom-list | 30 ++++++++++++++++++++++++++++++ QMP/qom-set | 21 +++++++++++++++++++++ 3 files changed, 77 insertions(+), 0 deletions(-) create mode 100755 QMP/qom-get create mode 100755 QMP/qom-list create mode 100755 QMP/qom-set diff --git a/QMP/qom-get b/QMP/qom-get new file mode 100755 index 0000000..e6c063a --- /dev/null +++ b/QMP/qom-get @@ -0,0 +1,26 @@ +#!/usr/bin/python +## +# QEMU Object Model test tools +# +# Copyright IBM, Corp. 2011 +# +# Authors: +# Anthony Liguori +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. See +# the COPYING file in the top-level directory. +## + +import sys +from qmp import QEMUMonitorProtocol + +srv = QEMUMonitorProtocol('/tmp/server.sock') +srv.connect() + +path, prop = sys.argv[1].rsplit('.', 1) +rsp = srv.command('qom-get', path=path, property=prop) +if type(rsp) == dict: + for i in rsp.keys(): + print '%s: %s' % (i, rsp[i]) +else: + print rsp diff --git a/QMP/qom-list b/QMP/qom-list new file mode 100755 index 0000000..b91f814 --- /dev/null +++ b/QMP/qom-list @@ -0,0 +1,30 @@ +#!/usr/bin/python +## +# QEMU Object Model test tools +# +# Copyright IBM, Corp. 2011 +# +# Authors: +# Anthony Liguori +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. See +# the COPYING file in the top-level directory. +## + +import sys +from qmp import QEMUMonitorProtocol + +srv = QEMUMonitorProtocol('/tmp/server.sock') +srv.connect() + +if len(sys.argv) == 1: + print '/' + sys.exit(0) + +for item in srv.command('qom-list', path=sys.argv[1]): + if item['type'].startswith('child<'): + print '%s/' % item['name'] + elif item['type'].startswith('link<'): + print '@%s/' % item['name'] + else: + print '%s' % item['name'] diff --git a/QMP/qom-set b/QMP/qom-set new file mode 100755 index 0000000..c5589d8 --- /dev/null +++ b/QMP/qom-set @@ -0,0 +1,21 @@ +#!/usr/bin/python +## +# QEMU Object Model test tools +# +# Copyright IBM, Corp. 2011 +# +# Authors: +# Anthony Liguori +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. See +# the COPYING file in the top-level directory. +## + +import sys +from qmp import QEMUMonitorProtocol + +srv = QEMUMonitorProtocol('/tmp/server.sock') +srv.connect() + +path, prop = sys.argv[1].rsplit('.', 1) +print srv.command('qom-set', path=path, property=prop, value=sys.argv[2])