3 # QEMU Object Model test tools
5 # Copyright IBM, Corp. 2011
8 # Anthony Liguori <aliguori@us.ibm.com>
10 # This work is licensed under the terms of the GNU GPL, version 2 or later. See
11 # the COPYING file in the top-level directory.
16 from qmp
import QEMUMonitorProtocol
18 cmd
, args
= sys
.argv
[0], sys
.argv
[1:]
24 return '''environment variables:
25 QMP_SOCKET=<path | addr:port>
27 %s [-h] [-s <QMP socket path | addr:port>] [<path>]
30 def usage_error(error_msg
= "unspecified error"):
31 sys
.stderr
.write('%s\nERROR: %s\n' % (usage(), error_msg
))
42 usage_error("missing argument: QMP socket path or address");
46 if os
.environ
.has_key('QMP_SOCKET'):
47 socket_path
= os
.environ
['QMP_SOCKET']
49 usage_error("no QMP socket path or address given");
51 srv
= QEMUMonitorProtocol(socket_path
)
58 for item
in srv
.command('qom-list', path
=args
[0]):
59 if item
['type'].startswith('child<'):
60 print '%s/' % item
['name']
61 elif item
['type'].startswith('link<'):
62 print '@%s/' % item
['name']
64 print '%s' % item
['name']