Scripting qemu / kvm monitor

There are some tasks in qemu / kvm monitor which could be scripted (i.e. like changing VNC password on demand).

Here is how to do it with netcat and minicom.

Using netcat (nc)

Use this option:

Then you can do:


You can also use nc -U to access the unix socket file.

Using minicom

First, you need to tell qemu / kvm process to have a monitor accessible via a UNIX socket – if you use Proxmox VE, it will be created automatically, if not, just use such a command line parameter:

Where /var/run/qemu-server/105.mon is the path to the socket.

Next, install minicom and create the /etc/minicom/minirc.105-mon file with the contents like below – this will tell minicom to connect to the serial monitor console of this qemu / kvm quest:

Next, minicom needs to execute a script – an example for changing a VNC password below (save it as “change-vnc-pass”; see “man runscript” for more syntax help):

The last thing would be to start minicom and execute these commands:

That’s it!

If you’d like to start it from crontab, you have to use screen – otherwise, minicom will complain about “No cursor motion capability (cm)” when started using cron:

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Lxadm.com.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.