qom: add test tools (resend from "qom: dynamic properties")
AFAICT tell the qom tool got dropped from Anthony's "qom: dynamic properties and composition tree" series due to some hardcoded paths for the QMP socket.
I've since ended up adding support for user-specified paths to get them working in my environment so I figured I'd resend to the list since I've seen others express interest.
Only functional change for existing users would be the need to set your QMP_SOCKET env variable to the previously hard-coded path:
mdroth@illuin:~$ qom-set -h
environment variables:
QMP_SOCKET=<path | addr:port>
usage:
/home/mdroth/bin/qom-set [-h] [-s <QMP socket path | addr:port>] <path>.<property> <value>mdroth@illuin:~$ qom-get -h
environment variables:
QMP_SOCKET=<path | addr:port>
usage:
/home/mdroth/bin/qom-get [-h] [-s <QMP socket path | addr:port>] <path>.<property>mdroth@illuin:~$ qom-list -h
environment variables:
QMP_SOCKET=<path | addr:port>
usage:
/home/mdroth/bin/qom-list [-h] [-s <QMP socket path | addr:port>] [<path>]PATCH 1/2 qmp: make qmp.py easier to use
From: Anthony Liguori <[email protected]>
--- QMP/qmp.py | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
QMP/qmp.py +6 -0
@@ -128,6 +128,12 @@ class QEMUMonitorProtocol: qmp_cmd['id'] = id return self.cmd_obj(qmp_cmd) + def command(self, cmd, **kwds): + ret = self.cmd(cmd, kwds) + if ret.has_key('error'): + raise Exception(ret['error']['desc']) + return ret['return'] + def get_events(self, wait=False): """ Get a list of available QMP events.
Signature · 1 line
1.7.4.1
PATCH 2/2 qom: add test tools
In reply to Michael RothFrom: Anthony Liguori <[email protected]>
--- QMP/qom-get | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ QMP/qom-list | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ QMP/qom-set | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+), 0 deletions(-) create mode 100755 QMP/qom-get create mode 100755 QMP/qom-list create mode 100755 QMP/qom-set
QMP/qom-get new file +65 -0
@@ -0,0 +1,65 @@ +#!/usr/bin/python +## +# QEMU Object Model test tools +# +# Copyright IBM, Corp. 2011 +# +# Authors: +# Anthony Liguori <[email protected]> +# +# 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 +import os +from qmp import QEMUMonitorProtocol + +cmd, args = sys.argv[0], sys.argv[1:] +socket_path = None +path = None +prop = None + +def usage(): + return '''environment variables: + QMP_SOCKET=<path | addr:port> +usage: + %s [-h] [-s <QMP socket path | addr:port>] <path>.<property> +''' % cmd + +def usage_error(error_msg = "unspecified error"): + sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg)) + exit(1) + +if len(args) > 0: + if args[0] == "-h": + print usage() + exit(0); + elif args[0] == "-s": + try: + socket_path = args[1] + except: + usage_error("missing argument: QMP socket path or address"); + args = args[2:] +elif os.environ.has_key('QMP_SOCKET'): + socket_path = os.environ['QMP_SOCKET'] +else: + usage_error("no QMP socket path or address given"); + +if len(args) > 0: + try: + path, prop = args[0].rsplit('.', 1) + except: + usage_error("invalid format for path/property/value") +else: + usage_error("not enough arguments") + +srv = QEMUMonitorProtocol(socket_path) +srv.connect() + +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
QMP/qom-list new file +62 -0
62 lines not on this page · raw message
QMP/qom-set new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Quoted 7 lines · Michael Roth
AFAICT tell the qom tool got dropped from Anthony's "qom: dynamic properties and composition tree" series due to some hardcoded paths for the QMP socket.
I've since ended up adding support for user-specified paths to get them working in my environment so I figured I'd resend to the list since I've seen others express interest.
Quoted 8 lines
Only functional change for existing users would be the need to set your
QMP_SOCKETenv variable to the previously hard-coded path:mdroth@illuin:~$ qom-set -h environment variables: QMP_SOCKET=<path | addr:port> usage: /home/mdroth/bin/qom-set [-h] [-s <QMP socket path | addr:port>] <path>.<property> <value>
HI, Michael.
Recently i am learing about QOM. Can you let me know how to specify <path> <property> <value>? Can you provide some examples?
Quoted 14 lines
mdroth@illuin:~$ qom-get -h environment variables: QMP_SOCKET=<path | addr:port> usage: /home/mdroth/bin/qom-get [-h] [-s <QMP socket path | addr:port>] <path>.<property>mdroth@illuin:~$ qom-list -h environment variables: QMP_SOCKET=<path | addr:port> usage: /home/mdroth/bin/qom-list [-h] [-s <QMP socket path | addr:port>] [<path>]
Signature · 3 lines
Regards, Zhi Yong Wu