COM port in
Virtual Machine -
An Extended Guide


Contents

  1. Access serial ports in virtual machines over the network
  2. How to add serial port to VMware Workstation
  3. How to setup serial port in VirtualBox
  4. How to enable serial port in Hyper-V

If someone were to tell you that serial ports still served a purpose, you might find it odd, surprising, or even humorous. But guess what? They aren’t wrong. Serial ports do still serve a variety of important purposes.

For instance, they can be used to establish a primitive network over a null-modem cable when the Ethernet isn’t available. Usually, kernel debugging software interacts with the developers over the serial ports, so they are extremely important for system programmers, who have to carry out kernel debugging.

Sec logo

Serial to Ethernet Connector

Connect serial ports over Ethernet
4.9 Rank based on 52+ users, Reviews(86)
Download 14-day fully-functional trial period
Serial to Ethernet Connector

Now, as you might know, developers rely on serial ports to interface with kernel debugging software. But it is possible to place a serial port in a virtual machine and carry out kernel debugging. This means there is no need for a real computer to be connected.

However, virtual environments aren’t typically compatible with serial ports due to the fact that virtualization software tools don’t host COM ports. So, there are other solutions that we need to look for if we want to enable a serial port in virtual machine. Well, there are a few methods that we can take a look at.

Access serial ports in virtual machines
over the network


One of the simplest ways to connect a COM port in a virtual machine is (in Windows or Linux) by using the Serial to Ethernet Connector approach. The Serial to Ethernet Connector software tool can provide you with access to COM in Hyper-V, VMware, and even VirtualBox.

Serial to Ethernet Connector is an effective tool that allows for the sharing of multiple serial ports over the network, physical or virtual.
Sec logo

Serial to Ethernet Connector

Connect serial ports over Ethernet
4.9 Rank based on 52+ users, Reviews(86)
Download 14-day fully-functional trial period
Serial to Ethernet Connector

The computer a shared device is connected to, such as remote machine or host, will function as the server. The virtual machine connects to it as soon as the remote access to serial devices is established and acts as the client.

Now, if you’re wondering how to enable a serial port in a virtual machine over the network, you will need to download and install the app onto the guest operating systems as well as on the host. This will aid the creation of client and server connections through the software. Serial to Ethernet Connectors opens up access to serial port in VirtualBox, VMWare, and Hyper-V.

How to add serial port to
VMware Workstation

Vmware serial port

It is possible to add 4 serial ports to a virtual machine. A virtual serial port can output data to files, named pipes, and physical serial ports. A VMware serial port can be added to a virtual machine in order to create devices such as modems etc. that are made available to the virtual machine itself. The VMware serial ports can also be used to transmit debugging data from the virtual machine to another virtual machine or a host system.

To enable COM port redirection in a virtual machine, begin with:

  1. Powering off the virtual machine.
  2. Choosing the virtual machine and opting for VM>Settings.
  3. Then, on the "Hardware" tab, click on "Add."
  4. Next, select the "Add Hardware" wizard and opt for "Serial Port".
  5. Finally, click on “Finish” to add the VMware Serial Port to the virtual machine.
  6. Choose where the virtual serial port sends the output.

    • • You can also use a physical parallel port. For this, transmit the output to the host system's physical serial port.
    • • To use the output file, send the output to any file in the host system. You can use an existing output file or create a new one by going to the directory and typing a file name.
    • • To output to the named pipe, establish a connection between two virtual machines or a connection between a host system application and a virtual machine.
  7. Configure the named pipe if you have selected the output to the named pipe.

(For Windows Host) Make use of the default pipe name or enter another pipe name. Make sure the pipe name starts with \\.\pipe\. Ensure that it is the same on both the client and the server.

(For Linux Host) Type a UNIX socket name in the next text box. This could be something like /tmp/socket. As stated above, the name must be identical on the client and server.

To transmit debugging information to a host system application, choose “This End is the Server” on the initial drop-down menu and “The Other End is the Application” on the next drop-down menu.

To transmit debugging information to a virtual machine, choose “This End is the Server” on the initial drop-down menu and “The Other End is the Application” on the next drop-down menu.

Finally, to connect the virtual machine and the port, choose “Connect at Power On”. The connection with the virtual machine will be activated once the machine is on.

When a connection is established between two virtual machines, the first often functions as the server.

Repeat the process for the second virtual machine. However, make sure it is set up as the client by choosing "This End is the Client." Do this when you are configuring the named pipe.

How to setup serial port in VirtualBox

Virtualbox serial port

VirtualBox Serial Port machines also offer support for virtual serial ports in a virtual machine. When the virtual serial port becomes enabled, the guest OS is presented with a UART device that is standard compatible. Here, both the reception and transmission of data is possible. The connection between the host and the virtual serial port can be configured. However, the exact details are dependent on the host OS.

You can use the VBoxManage command or the Settings tab to command the establishment of virtual serial ports. In one of the methods, you can configure a maximum of 4 virtual serial ports for each virtual machine.

This means setting things such as Port Mode and Port Number.
The Port Number is what determines the serial port that the virtual machine sees. Traditional values need to be used for best results. A user-defined serial port can also be configured. Enter an I/O base address and IRQ.

Port Mode refers to what the virtual port is connected to. Port Mode can be Disconnected, Connected to Host Device, or Connected to Host Pipe.

  • Disconnected means the device will be visible to the guest, but will function as though no cable has been connected.

  • The Host Device Connection entails physically connecting the serial port to serial pot on the host. In Windows, this will, typically, be denoted by a name like COM1. On Linux, you’ll find something like /dev/ttyS0. VirtualBox will then just redirect all the data (received from and sent to the virtual port) to the physical device.

  • In the Host Pipe connection, the Oracle VM VirtualBox is configured to connect the virtual serial port to one of the host’s software pipe. This is done in accordance with the host OS:
  1. On Windows, the data is sent/received via a named pipe. The pipe name is registered as \\.\pipe\ where is used to identify the machine, but may be chosen on a whim.

  2. In a Mac, a local domain socket comes into play. The socket filename is chosen in a way that allows the VirtualBox user to enjoy certain privileges with regards to creating and writing it. The tmp is a common choice.

  3. In Linux, some multiples tools connect to a local domain socket or develop one in server mode. Socat is the most usable and is available across distributions.

In this scenario, the VirtualBox can be configured to create the local domain socket non-Windows hosts, the named pipe, or itself, etc. Also, the VirtualBox must assume that the socket or pipe is in existence already.

In the case of a direct connection between two virtual machines, configure one virtual machine to develop a socket or pipe and the other one to attach to it.

  • Raw File: The virtual serial port output can be sent to a file. This is helpful for collecting diagnostic output. Any file can be used. The only requirement is that VirtualBox users has enough privileges to write and create.

  • TCP Socket: This helps forward serial traffic over TCP/IP. It can act as a TCP client that connects to servers or a server itself. The option allows for the direct connection between the remote machine and the guest's serial port via TCP.

1. TCP Server: The current Pipe/Socket checkbox needs to be deselected and the port number specified in the address/path field. The port number can be 23 or 2023. In the case of UNIX-like systems, the port number has to be more than 1024.

2. TCP Client: For the purpose of creating virtual null-modem cable over the LAN/Internet, the other end should connect via TCP, while specifying the hostname: port in the Path/Address field. When the "Connect to Existing Pipe/Socket" box is ticked, the TCP socket will go into client mode.

As you can see, 4 serial ports can be configured or each virtual machine. However, multiple port numbers can be picked.

How to enable serial port in Hyper-V

Hyper-v serial port

The virtual machine’s serial port must be set up from within the Hyper-V. For this, you need to start from the Hyper-V Manager. Begin by…

  • Right-clicking the virtual machine and selecting "Settings."
  • Choose the COM port from the “Hardware” menu.
  • Click the Named Pipe Radio button.
  • Enter the name for the pipe in the Pipe name textbox.
  • Make a note of the Named pipe path shown by Hyper-V shows.

From the Hyper-V Host Machine

  • Make use of a serial client to connect to the named pipe by using the Named pipe path.

There is also a second method that describes how to pass serial port from RDP to a virtual machine (Hyper-V). It requires access to the virtual machine through the "Remote Desktop Connection" application.

  • Look for the “Show Options” button on the left corner at the bottom.
  • Then, look for the “Local Resources” tab.
  • Look for the box called "Local Devices and Resources".
  • Then, click "More".
  • Tick the “Ports” box.
  • Now, sign in to the virtual machine via the tab placed under "General".

This will give you access to your local machine’s resources inside your virtual machine.

Hopefully, the detailed instructions in this guide have given you an understanding of how to add COM port in a virtual machine. The settings that we discussed will provide you with all the functionality necessary for accessing serial ports inside the guest machine itself, as though it were plugged in directly.
You will also be able to communicate with the virtually created port via the software solution. You won’t need additional settings.

Serial to Ethernet Connector allows you to access COM ports in a virtual machine of any kind or type. This includes VirtualBox serial port, VMware serial port, Hyper-V com port, and even VMware serial port passthrough.

So, the next time you hear "Can you add a serial port to a virtual machine?", you know the answer!

Serial to Ethernet Connector

Requirements: Windows 2000, Windows (32-bit and 64-bit): XP/2003/2008/ Vista/7/8/10, Windows Server 2012/2016 , 4.66MB size
Version 7.1.876 (27th Jan, 2017) Release notes
Category: Communication Application