arm: Fix compiler warning (fprintf format string)
[qemu.git] / QMP / qmp-shell
blobf89b9af87ec86994b2f6365d7d0ac240cf82b3d7
1 #!/usr/bin/python
3 # Simple QEMU shell on top of QMP
5 # Copyright (C) 2009 Red Hat Inc.
7 # Authors:
8 # Luiz Capitulino <lcapitulino@redhat.com>
10 # This work is licensed under the terms of the GNU GPL, version 2. See
11 # the COPYING file in the top-level directory.
13 # Usage:
15 # Start QEMU with:
17 # $ qemu [...] -monitor control,unix:./qmp,server
19 # Run the shell:
21 # $ qmp-shell ./qmp
23 # Commands have the following format:
25 # < command-name > [ arg-name1=arg1 ] ... [ arg-nameN=argN ]
27 # For example:
29 # (QEMU) info item=network
31 import qmp
32 import readline
33 from sys import argv,exit
35 def shell_help():
36 print 'bye exit from the shell'
38 def main():
39 if len(argv) != 2:
40 print 'qemu-shell <unix-socket>'
41 exit(1)
43 qemu = qmp.QEMUMonitorProtocol(argv[1])
44 qemu.connect()
46 print 'Connected!'
48 while True:
49 try:
50 cmd = raw_input('(QEMU) ')
51 except EOFError:
52 print
53 break
54 if cmd == '':
55 continue
56 elif cmd == 'bye':
57 break
58 elif cmd == 'help':
59 shell_help()
60 else:
61 try:
62 resp = qemu.send(cmd)
63 if resp == None:
64 print 'Disconnected'
65 break
66 print resp
67 except IndexError:
68 print '-> command format: <command-name> ',
69 print '[arg-name1=arg1] ... [arg-nameN=argN]'
71 if __name__ == '__main__':
72 main()