KVM - The Linux Kernel-Based Virtual Machine
News, Blogs and Resources on the Linux (KVM) Kernel-Based Virtual Machine

Multiplexing your monitor and serial port

There’s a feature in kvm which allows you to multiplex your serial and monitor port over a single connection. This is another one of the many features inherited from the qemu tree and was added around kvm-57 which is probably not well known. I think this is one feature that may not be used much but I think it’s still good to know thy options.

The Syntax

The syntax to enable the multiplexing of your monitor port is as follows:

mon:dev_string

Your monitor is accessed using a key sequence of Ctrl-A then c. This key sequence will toggle between your monitor and serial port. For example, if you wanted to multiplex your monitor onto a telnet server listening on port 4444, you would start your kvm guest with the following option.

qemu-system-x86_64  -hda  windows.img  -serial  mon:telnet::4445,server,nowait 

For more on accessing your monitor via telnet, see this post here on accessing your monitor across the network.

 

An example

For a concrete example, start your kvm guest using a syntax similar to the one described in the previous section, for example.

qemu-system-x86_64  -hda  windows.img  -m 400 -serial  mon:telnet::4445,server,nowait

Now type the following in a terminal window on your kvm host

telnet localhost 4445

When you do this you will get an output similar to the following.

Note that you will not get any response from your keyboard in this session. This is because when you initially connect, you’ll be connecting to the serial port via the telnet server. Now type Ctl-a then c and hit enter from within the same session. You’ll now see your kvm monitor come up as shown below.

Using this key sequence you can toggle between the serial and monitor sessions using your telnet server. To break out of the telnet server, issue the Ctrl-] and you’ll get the telnet prompt as shown below from which you can then quit.

The multiplexing your monitor and serial port is another one of those features that is probably not very popular but you never know when you might have to pull it out of your bag of tricks. Can you think of an application of this feature?

Share your thoughts and drop a comment if you can think of how you might use this feature.
 

See Also

Comments

I think this could be quite useful...

Thanks for the article :)

I have a headless server running qemu-kvm. No Xorg, just console through SSH.

Machines are run as daemons, "low-level" access to the machines are made with VNC and "high-level" access is made with SSH/rdesktop.

At the moment I have no way of getting to the monitor, which is quite annoying, since I sometimes would like to change the CD iso file. Using this function would of course solve my problem and if I get a multiplexer with a serial interface, I don't need to use VNC to get "low-level" access to a virtual machine (most of my virtual machines are servers with console only anyway).

I could also convert this into a cleaner administration of my console-only virtual machines, as I would not need to run SSH-daemons on all the machines (remembering the different ports, different users, different keys, etc), I can just administrate them directly with this function - and get access to the monitor at the same time :)

Post new comment

The content of this field is kept private and will not be shown publicly.