Patchwork [15/15] QMP: Introduce vm-info

login
register
mail settings
Submitter Luiz Capitulino
Date Nov. 19, 2009, 3:13 p.m.
Message ID <1258643623-8636-16-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/38858/
State New
Headers show

Comments

Luiz Capitulino - Nov. 19, 2009, 3:13 p.m.
A Python script which uses qmp.py to print some simple VM info.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 QMP/vm-info |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
 create mode 100755 QMP/vm-info

Patch

diff --git a/QMP/vm-info b/QMP/vm-info
new file mode 100755
index 0000000..76a119e
--- /dev/null
+++ b/QMP/vm-info
@@ -0,0 +1,32 @@ 
+#!/usr/bin/python
+#
+# Print Virtual Machine information
+#
+# Usage:
+#
+# Start QEMU with:
+#
+# $ qemu [...] -monitor control,unix:./qmp,server
+#
+# Run vm-info:
+#
+# $ vm-info ./qmp
+#
+# Luiz Capitulino <lcapitulino@redhat.com>
+
+import qmp
+from sys import argv,exit
+
+def main():
+    if len(argv) != 2:
+        print 'vm-info <unix-socket>'
+        exit(1)
+
+    qemu = qmp.QEMUMonitorProtocol(argv[1])
+    qemu.connect()
+
+    for cmd in [ 'version', 'hpet', 'kvm', 'status', 'uuid', 'balloon' ]:
+        print cmd + ': ' + str(qemu.send('info item=' + cmd))
+
+if __name__ == '__main__':
+    main()