3.9. Serial ports

VirtualBox fully supports virtual serial ports in a virtual machine in an easy-to-use manner.[15]

Ever since the original IBM PC, personal computers have been equipped with one or two serial ports (also called COM ports by DOS and Windows). Most importantly, computer mice used to be connected to serial ports before USB became commonplace.

While serial ports are no longer as important as they used to be, there are still some important uses left for them. For example, serial ports can be used to set up a primitive network over a null-modem cable, in case Ethernet is not available. Also, serial ports are indispensable for system programmers needing to do kernel debugging, since kernel debugging software usually interacts with developers over a serial port. With virtual serial ports, system programmers can do kernel debugging on a virtual machine instead of needing a real computer to connect to.

If a virtual serial port is enabled, the guest operating system sees a standard 16450-type device. Both receiving and transmitting data is supported. How this virtual serial port is then connected to the host is configurable, and the details depend on your host operating system.

You can use either the graphical user interface or the command-line VBoxManage tool to set up virtual serial ports. For the latter, please refer to Section 8.7, “VBoxManage modifyvm”; in that section, look for the --uart and --uartmode options.

In either case, you can configure up to two virtual serial ports simultaneously. For each such device, you will need to determine

  1. what kind of serial port the virtual machine should see by selecting an I/O base address and interrupt (IRQ). For these, we recommend to use the traditional values[16], which are:

    1. COM1: I/O base 0x3F8, IRQ 4

    2. COM2: I/O base 0x2F8, IRQ 3

    3. COM3: I/O base 0x3E8, IRQ 4

    4. COM4: I/O base 0x2E8, IRQ 3

  2. Then, you will need to determine what this virtual port should be connected to. For each virtual serial port, you have the following options:

    • You can elect to have the virtual serial port "disconnected", which means that the guest will see the device, but it will behave as if no cable had been connected to it.

    • You can connect the virtual serial port to a physical serial port on your host. (On a Windows host, this will be a name like COM1; on Linux or Solaris hosts, it will be a device node like /dev/ttyS0). VirtualBox will then simply redirect all data received from and sent to the virtual serial port to the physical device.

    • You can tell VirtualBox to connect the virtual serial port to a software pipe on the host. This depends on your host operating system:

      • On a Windows host, data will be sent and received through a named pipe. You can use a helper program called VMware Serial Line Gateway, available for download at http://www.l4ka.org/tools/vmwaregateway.php . This tool provides a fixed server mode named pipe at \\.\pipe\vmwaredebug and connects incoming TCP connections on port 567 with the named pipe.

      • On a Mac, Linux or OpenSolaris host, a local domain socket is used instead. On Linux there are various tools which can connect to a local domain socket or create one in server mode. The most flexible tool is socat and is available as part of many distributions.

      In this case, you can configure whether VirtualBox should create the named pipe (or, on non-Windows hosts, the local domain socket) itself or whether VirtualBox should assume that the pipe (or socket) exists already. With the VBoxManage command-line options, this is referred to as "server" or "client" mode, respectively.

Up to two serial ports can be configured simultaneously per virtual machine, but you can pick any port numbers out of the above. For example, you can configure two serial ports to be able to work with COM2 and COM4 in the guest.



[15] Serial port support was added with VirtualBox 1.5.