Automated screendump of KVM machines?

Patschi

Member
Jul 23, 2013
51
0
6
29
Austria
pkern.at
I'm trying since hours to get the output of a virtual machine (KVM) automated. For this I'm trying to use the integrated "screendump" command of KVM, but I'm not able to execute it somehow automated.

I was using QMP (Which is created by default), but all commands I found in the web aren't working as expected - all helpful commands were not found.
Code:
root@pve:~# echo '{ "execute": "screendump", "arguments": { "filename": "/tmp/test.ppm" } }' | socat - /var/run/qemu-server/201.qmp
{"QMP": {"version": {"qemu": {"micro": 1, "minor": 7, "major": 1}, "package": ""}, "capabilities": []}}
{"error": {"class": "CommandNotFound", "desc": "The command screendump has not been found"}}

My next try was to use "qm monitor" to dump the screen to a file. It's working manually like expected, but I'm not able to get it executed fully automated... Tried many things, but nothing helped.
Code:
root@pve:~# echo -e "screendump /tmp/test.ppm\nquit" | qm monitor 201
Entering Qemu Monitor for VM 201 - type 'help' for help
qm> quit
root@pve:~#

Converting the final .ppm file is very easy. For that just imagemagick is needed: "convert image.ppm image.png".

My third idea was to convert the VNC socket to a image, but for this case I didn't really found many useful tools. So I guess the both ideas above are a better possibility.
Does someone knows better way to get this work? Thanks for any suggestions!