3 # QEMU Object Model test tools
5 # Copyright IBM, Corp. 2011
6 # Copyright (c) 2013 SUSE LINUX Products GmbH
9 # Anthony Liguori <aliguori@amazon.com>
10 # Andreas Faerber <afaerber@suse.de>
12 # This work is licensed under the terms of the GNU GPL, version 2 or later. See
13 # the COPYING file in the top-level directory.
19 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
20 from qemu.qmp import QEMUMonitorProtocol
22 cmd, args = sys.argv[0], sys.argv[1:]
28 return '''environment variables:
29 QMP_SOCKET=<path | addr:port>
31 %s [-h] [-s <QMP socket path | addr:port>] [<path>]
34 def usage_error(error_msg = "unspecified error"):
35 sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg))
46 usage_error("missing argument: QMP socket path or address");
50 if 'QMP_SOCKET' in os.environ:
51 socket_path = os.environ['QMP_SOCKET']
53 usage_error("no QMP socket path or address given");
55 srv = QEMUMonitorProtocol(socket_path)
60 items = srv.command('qom-list', path=path)
62 if not item['type'].startswith('child<'):
64 print(' %s: %s (%s)' % (item['name'], srv.command('qom-get', path=path, property=item['name']), item['type']))
66 print(' %s: <EXCEPTION> (%s)' % (item['name'], item['type']))
69 if item['type'].startswith('child<'):
70 list_node((path if (path != '/') else '') + '/' + item['name'])