root / QMP / vm-info @ f4918804
History | View | Annotate | Download (586 Bytes)
1 | 01f2785e | Luiz Capitulino | #!/usr/bin/python |
---|---|---|---|
2 | 01f2785e | Luiz Capitulino | # |
3 | 01f2785e | Luiz Capitulino | # Print Virtual Machine information |
4 | 01f2785e | Luiz Capitulino | # |
5 | 01f2785e | Luiz Capitulino | # Usage: |
6 | 01f2785e | Luiz Capitulino | # |
7 | 01f2785e | Luiz Capitulino | # Start QEMU with: |
8 | 01f2785e | Luiz Capitulino | # |
9 | 01f2785e | Luiz Capitulino | # $ qemu [...] -monitor control,unix:./qmp,server |
10 | 01f2785e | Luiz Capitulino | # |
11 | 01f2785e | Luiz Capitulino | # Run vm-info: |
12 | 01f2785e | Luiz Capitulino | # |
13 | 01f2785e | Luiz Capitulino | # $ vm-info ./qmp |
14 | 01f2785e | Luiz Capitulino | # |
15 | 01f2785e | Luiz Capitulino | # Luiz Capitulino <lcapitulino@redhat.com> |
16 | 01f2785e | Luiz Capitulino | |
17 | 01f2785e | Luiz Capitulino | import qmp |
18 | 01f2785e | Luiz Capitulino | from sys import argv,exit |
19 | 01f2785e | Luiz Capitulino | |
20 | 01f2785e | Luiz Capitulino | def main(): |
21 | 01f2785e | Luiz Capitulino | if len(argv) != 2: |
22 | 01f2785e | Luiz Capitulino | print 'vm-info <unix-socket>' |
23 | 01f2785e | Luiz Capitulino | exit(1) |
24 | 01f2785e | Luiz Capitulino | |
25 | 01f2785e | Luiz Capitulino | qemu = qmp.QEMUMonitorProtocol(argv[1]) |
26 | 01f2785e | Luiz Capitulino | qemu.connect() |
27 | 01f2785e | Luiz Capitulino | |
28 | 01f2785e | Luiz Capitulino | for cmd in [ 'version', 'hpet', 'kvm', 'status', 'uuid', 'balloon' ]: |
29 | 01f2785e | Luiz Capitulino | print cmd + ': ' + str(qemu.send('query-' + cmd)) |
30 | 01f2785e | Luiz Capitulino | |
31 | 01f2785e | Luiz Capitulino | if __name__ == '__main__': |
32 | 01f2785e | Luiz Capitulino | main() |