spapr_pci: Use XICS interrupt allocator and do not cache interrupts in PHB
[qemu-kvm.git] / scripts / qmp / qom-get
blob0172c694413cf4a9bc69ece9dbc25f7ade822339
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>.<property>
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 if len(args) > 0:
52 try:
53 path, prop = args[0].rsplit('.', 1)
54 except:
55 usage_error("invalid format for path/property/value")
56 else:
57 usage_error("not enough arguments")
59 srv = QEMUMonitorProtocol(socket_path)
60 srv.connect()
62 rsp = srv.command('qom-get', path=path, property=prop)
63 if type(rsp) == dict:
64 for i in rsp.keys():
65 print '%s: %s' % (i, rsp[i])
66 else:
67 print rsp