Running your KVM virtual machines headless in a data center environment using the built in vnc server is a neat feature of KVM but what happens when you want to access your monitor from across the network? Well, it turns out there’s an option for redirecting your monitor to tcp sockets and there are two methods of doing this.

There are two basic options for redirecting your monitor to tcp sockets, namely raw socket and using the telnet protocol. I’ll go ahead and show the syntax for both options then discuss the options you have. For redirecting your monitor to raw tcp socket you use the following syntax:
-monitor tcp:192.168.1.1:4444,server,nowait
For redirecting to a socket supporting telnet protocol you use the following syntax
-monitor telnet:192.168.1.1:4444,server,nowait
The options are
So as an example for your typical case where you have your headless kvm virtual machine running with a vnc server and want to access the monitor from across the network, you’d probably want to use the following command to start your virtual machine.
qemu-system-x86_64 –m 400 –hda windows.img –usbdevice tablet –vnc :1 –monitor telnet:192.168.1.100:4444,server,nowait
If you’re going to be listening on any ip addresses on your server, you can also use
qemu-system-x86_64 –m 400 –hda windows.img –usbdevice tablet –vnc :1 –monitor telnet::4444,server,nowait
Now in order to access your virtual machine monitor from across the network you would type the following
telnet 192.168.1.100 4444
This would give you access to your monitor remotely. To close and break out of the monitor you simply type Ctrl-] to get the telnet prompt then type quit. If you have security on your virtual machine host server such as ssh, then you can either ssh to the host server then telnet to localhost or use ssh tunneling.
So next time you’re thinking about running headless kvm machines and wondering how to manage them remotely you have two more options.
Comments
Hi Haydn, Thanks for the
Tuesday, August 26, 2008 - 07:54 J (not verified)Hi Haydn, Thanks for the quick solution, it works like a charm! I had already tried something similar, but that didn't work. Do you think the above is also possible with tools like virt-install which uses the libvirt package?
Well, now I can continue testing whether kvm is suitable as a replacement for our xen 3.0 boxes. If you have more tips on the management of mulitple remote kvm servers, please post them! :) I am especially interested in live migration (with NFS/SAN/DRBD) .
Re: Thanks.. monitor
Tuesday, August 26, 2008 - 13:27 Haydn SolomonHi J,
Glad that the information was useful to you.. maybe you'll make the switch to KVM. :) So I did some initial investigations and libvirt already has an interface for the monitor but when looking at virtinst I don't see any use of it however I didn't look in detail. I do agree that this is an important feature as no sense in remote control if you have no access to monitor. I will spend more time later looking through the various tools to see if there's an feature that makes use of the libvirt monitor interface.
I will continue to post information on features of KVM as I discover them as it's not well documented and information is difficult to find. Regardless of this fact, I think KVM is a really good piece of software and will be around for a long time.
Thank You!!
Tuesday, August 26, 2008 - 16:07 Dan VerWeire (not verified)I have been wondering if this was possible and couldn't figure out what to search for to find how to do it! Thank you!