|
|
1.1 root 1: #!/usr/bin/python
2: #
3: # Simple QEMU shell on top of QMP
4: #
5: # Copyright (C) 2009 Red Hat Inc.
6: #
7: # Authors:
8: # Luiz Capitulino <[email protected]>
9: #
10: # This work is licensed under the terms of the GNU GPL, version 2. See
11: # the COPYING file in the top-level directory.
12: #
13: # Usage:
14: #
15: # Start QEMU with:
16: #
17: # $ qemu [...] -monitor control,unix:./qmp,server
18: #
19: # Run the shell:
20: #
21: # $ qmp-shell ./qmp
22: #
23: # Commands have the following format:
24: #
25: # < command-name > [ arg-name1=arg1 ] ... [ arg-nameN=argN ]
26: #
27: # For example:
28: #
29: # (QEMU) info item=network
30:
31: import qmp
32: import readline
33: from sys import argv,exit
34:
35: def shell_help():
36: print 'bye exit from the shell'
37:
38: def main():
39: if len(argv) != 2:
40: print 'qemu-shell <unix-socket>'
41: exit(1)
42:
43: qemu = qmp.QEMUMonitorProtocol(argv[1])
44: qemu.connect()
1.1.1.2 ! root 45: qemu.send("qmp_capabilities")
1.1 root 46:
47: print 'Connected!'
48:
49: while True:
50: try:
51: cmd = raw_input('(QEMU) ')
52: except EOFError:
53: print
54: break
55: if cmd == '':
56: continue
57: elif cmd == 'bye':
58: break
59: elif cmd == 'help':
60: shell_help()
61: else:
62: try:
63: resp = qemu.send(cmd)
64: if resp == None:
65: print 'Disconnected'
66: break
67: print resp
68: except IndexError:
69: print '-> command format: <command-name> ',
70: print '[arg-name1=arg1] ... [arg-nameN=argN]'
71:
72: if __name__ == '__main__':
73: main()
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.