target-s390: Implement CONVERT TO LOGICAL
[qemu/agraf.git] / QMP / qom-list
blob1e7cc6cb2d00f2681d424913a09bfbaed394a265
1 #!/usr/bin/python
2 ##
3 # QEMU Object Model test tools
5 # Copyright IBM, Corp. 2011
7 # Authors:
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 import sys
15 import os
16 from qmp import QEMUMonitorProtocol
18 cmd, args = sys.argv[0], sys.argv[1:]
19 socket_path = None
20 path = None
21 prop = None
23 def usage():
24 return '''environment variables:
25 QMP_SOCKET=<path | addr:port>
26 usage:
27 %s [-h] [-s <QMP socket path | addr:port>] [<path>]
28 ''' % cmd
30 def usage_error(error_msg = "unspecified error"):
31 sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg))
32 exit(1)
34 if len(args) > 0:
35 if args[0] == "-h":
36 print usage()
37 exit(0);
38 elif args[0] == "-s":
39 try:
40 socket_path = args[1]
41 except:
42 usage_error("missing argument: QMP socket path or address");
43 args = args[2:]
45 if not socket_path:
46 if os.environ.has_key('QMP_SOCKET'):
47 socket_path = os.environ['QMP_SOCKET']
48 else:
49 usage_error("no QMP socket path or address given");
51 srv = QEMUMonitorProtocol(socket_path)
52 srv.connect()
54 if len(args) == 0:
55 print '/'
56 sys.exit(0)
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']
63 else:
64 print '%s' % item['name']