It is possible to attach UML serial lines and consoles to many types of host I/O channels by specifying them on the command line.
You can attach them to host ptys, ttys, file descriptors, and ports. This allows you to do things like
The general format of the command line option is device=channel.
Devices are specified with "con" or "ssl" (console or serial line, respectively), optionally with a device number if you are talking about a specific device.
Using just "con" or "ssl" describes all of the consoles or serial lines. If you want to talk about console #3 or serial line #10, they would be "con3" and "ssl10", respectively.
A specific device name will override a less general "con=" or "ssl=". So, for example, you can assign a pty to each of the serial lines except for the first two like this:
The specificity of the device name is all that matters; order on the command line is irrelevant.
ssl=pty ssl0=tty:/dev/tty0 ssl1=tty:/dev/tty1
There are a number of different types of channels to attach a UML device to, each with a different way of specifying exactly what to attach to.
This will cause UML to allocate a free host pseudo-terminal for the device. The terminal that it got will be announced in the boot log. You access it by attaching a terminal program to the corresponding tty:
This will make UML attach the device to the specified tty (i.e
will attach UML's console 1 to the host's /dev/tty3). If the tty that you specify is the slave end of a tty/pty pair, something else must have already opened the corresponding pty in order for this to work.
UML will run an xterm and the device will be attached to it.
This will attach the UML devices to the specified host port. Attaching console 1 to the host's port 9000 would be done like this:
Attaching all the serial lines to that port would be done similarly:
You access these devices by telnetting to that port. Each active telnet session gets a different device. If there are more telnets to a port than UML devices attached to it, then the extra telnet sessions will block until an existing telnet detaches, or until another device becomes active (i.e. by being activated in /etc/inittab).
This channel has the advantage that you can both attach multiple UML devices to it and know how to access them without reading the UML boot log. It is also unique in allowing access to a UML from remote machines without requiring that the UML be networked. This could be useful in allowing public access to UMLs because they would be accessible from the net, but wouldn't need any kind of network filtering or access control because they would have no network access.
If you attach the main console to a portal, then the UML boot will appear to hang. In reality, it's waiting for a telnet to connect, at which point the boot will proceed.
If you set up a file descriptor on the UML command line, you can attach a UML device to it. This is most commonly used to put the main console back on stdin and stdout after assigning all the other consoles to something else:
This allows the device to be opened, in contrast to 'none', but reads will block, and writes will succeed and the data will be thrown out.
This causes the device to disappear. If you are using devfs, the device will not appear in /dev. If not, then attempts to open it will return -ENODEV.
You can also specify different input and output channels for a device by putting a comma between them:
will cause serial line 3 to accept input on the host's /dev/tty3 and display output on an xterm. That's a silly example - the most common use of this syntax is to reattach the main console to stdin and stdout as shown above.
If you decide to move the main console away from stdin/stdout, the initial boot output will appear in the terminal that you're running UML in. However, once the console driver has been officially initialized, then the boot output will start appearing wherever you specified that console 0 should be. That device will receive all subsequent output.
There are a number of interesting things you can do with this capability.
First, this is how you get rid of those bleeding console xterms by attaching them to host ptys:
This will make a UML console take over an unused host virtual console, so that when you switch to it, you will see the UML login prompt rather than the host login prompt:
You can attach two virtual machines together with what amounts to a serial line as follows:
Run one UML with a serial line attached to a pty -
Look at the boot log to see what pty it got (this example will assume that it got /dev/ptyp1).
Boot the other UML with a serial line attached to the corresponding tty -
Log in, make sure that it has no getty on that serial line, attach a terminal program like minicom to it, and you should see the login prompt of the other virtual machine.