Annotation of qemu/QMP/qmp-shell, revision 1.1.1.1

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()
                     45: 
                     46:     print 'Connected!'
                     47: 
                     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]'
                     70: 
                     71: if __name__ == '__main__':
                     72:     main()

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.