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.
14 from __future__
import print_function
17 from qmp
import QEMUMonitorProtocol
19 cmd
, args
= sys
.argv
[0], sys
.argv
[1:]
25 return '''environment variables:
26 QMP_SOCKET=<path | addr:port>
28 %s [-h] [-s <QMP socket path | addr:port>] [<path>]
31 def usage_error(error_msg
= "unspecified error"):
32 sys
.stderr
.write('%s\nERROR: %s\n' % (usage(), error_msg
))
43 usage_error("missing argument: QMP socket path or address");
47 if 'QMP_SOCKET' in os
.environ
:
48 socket_path
= os
.environ
['QMP_SOCKET']
50 usage_error("no QMP socket path or address given");
52 srv
= QEMUMonitorProtocol(socket_path
)
59 for item
in srv
.command('qom-list', path
=args
[0]):
60 if item
['type'].startswith('child<'):
61 print('%s/' % item
['name'])
62 elif item
['type'].startswith('link<'):
63 print('@%s/' % item
['name'])
65 print('%s' % item
['name'])