ati-vga: Fix check for blt outside vram
[qemu/ar7.git] / scripts / qmp / qom-tree
blob31603c681fbf8b241f7a130999f3877ac4cdeeed
1 #!/usr/bin/python
2 ##
3 # QEMU Object Model test tools
5 # Copyright IBM, Corp. 2011
6 # Copyright (c) 2013 SUSE LINUX Products GmbH
8 # Authors:
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.
16 from __future__ import print_function
17 import sys
18 import os
19 from qmp import QEMUMonitorProtocol
21 cmd, args = sys.argv[0], sys.argv[1:]
22 socket_path = None
23 path = None
24 prop = None
26 def usage():
27 return '''environment variables:
28 QMP_SOCKET=<path | addr:port>
29 usage:
30 %s [-h] [-s <QMP socket path | addr:port>] [<path>]
31 ''' % cmd
33 def usage_error(error_msg = "unspecified error"):
34 sys.stderr.write('%s\nERROR: %s\n' % (usage(), error_msg))
35 exit(1)
37 if len(args) > 0:
38 if args[0] == "-h":
39 print(usage())
40 exit(0);
41 elif args[0] == "-s":
42 try:
43 socket_path = args[1]
44 except:
45 usage_error("missing argument: QMP socket path or address");
46 args = args[2:]
48 if not socket_path:
49 if 'QMP_SOCKET' in os.environ:
50 socket_path = os.environ['QMP_SOCKET']
51 else:
52 usage_error("no QMP socket path or address given");
54 srv = QEMUMonitorProtocol(socket_path)
55 srv.connect()
57 def list_node(path):
58 print('%s' % path)
59 items = srv.command('qom-list', path=path)
60 for item in items:
61 if not item['type'].startswith('child<'):
62 try:
63 print(' %s: %s (%s)' % (item['name'], srv.command('qom-get', path=path, property=item['name']), item['type']))
64 except:
65 print(' %s: <EXCEPTION> (%s)' % (item['name'], item['type']))
66 print('')
67 for item in items:
68 if item['type'].startswith('child<'):
69 list_node((path if (path != '/') else '') + '/' + item['name'])
71 if len(args) == 0:
72 path = '/'
73 else:
74 path = args[0]
76 list_node(path)