Serial communication mechanism VirtualBox virtual machine, there are two, one is through the virtual machine's serial port to connect to the host serial port, the other is the virtual machine serial port to connect to a named pipe on the host, the first way to now I do not practice it, just named pipe currently practiced otherwise successful.
1. Enable serial ports
New Virtual Machine After setting appears port panel, you can serial port settings, default can not afford to use the general port selection using COM1 corresponding to the virtual machine / dev / ttyS0, Port Mode Select Host Pipe, represents the virtual machine's serial port a named pipe to host, create a channel represents start a virtual machine VirtualBox corresponds create a named pipe HostOS in, and it corresponds to the virtual machine's serial port. Port path when selecting Host Pipe represents the path named pipes on Windows systems, it is \. Pipe xxx form, in Linux can be set to any path, for example, we will set it to / tmp / vbox. Note that if the port path corresponding named pipe can not be created, then the virtual machine will fail to start; port named pipe path can not be repeated to create.
You can also use the command line to enable a virtual machine and create a connection to the host named pipe, the following command will be Ubuntu 8.10 Dev OS virtual machine's COM1 serial port and host / tmp / vbox named pipes connected:
VBoxManage setextradata "Ubuntu8.10DevOS" "VBoxInternal / Devices / serial / 0 / Config / IRQ" 4
VBoxManage setextradata "Ubuntu8.10DevOS" "VBoxInternal / Devices / serial / 0 / Config / IOBase" 0x3f8
VBoxManage setextradata "Ubuntu8.10DevOS" "VBoxInternal / Devices / serial / 0 / LUN # 0 / Driver" Char
VBoxManage setextradata "Ubuntu8.10DevOS" "VBoxInternal / Devices / serial / 0 / LUN # 0 / AttachedDriver / Driver" NamedPipe
VBoxManage setextradata "Ubuntu8.10DevOS" "VBoxInternal / Devices / serial / 0 / LUN # 0 / AttachedDriver / Config / Location" "/ tmp / vbox"
VBoxManage setextradata "Ubuntu8.10DevOS" "VBoxInternal / Devices / serial / 0 / LUN # 0 / AttachedDriver / Config / IsServer" 1
2. The serial communication between the virtual machine and the host HostOS
Start the virtual machine Ubuntu8.10DevOS, then creates a new file in the vbox host / tmp / directory, use ls -l can see it is a sock type of file, use to communicate. Install minicom in HostOS in, minicom serial port can be used as a test:
sudo apt-get install minicom
Then we can configure minicom, it points to / tmp / vbox, Run
sudo gedit /etc/minicom/minirc.dfl and modify
pu port unix # / tmp / vbox
It can also be modified via the serial port settings in minicom. Baud rate and should ensure that the virtual machine minicom serial port settings of the serial port as before the test. Virtual machine serial port baud rate settings can refer to the following, minicom baud rate settings directly in the program Ctrl + A, O after modification, or modify the configuration files.
1) Start minicom in HostOS in:
In a virtual machine in a terminal execute:
echo is that ok?> / dev / ttyS0
In HostOS echo in minicom the corresponding content
2) in a virtual machine in a terminal execute:
cat / dev / ttyS0
Then host minicom will appear in the input state, in which the input information will be echoed to the virtual terminal.
3. The serial communication between virtual machines and the virtual machine
Communication between the two virtual machines can also be accomplished by using a host named pipes. Principle can be simply described: Named Pipes to create a virtual machine on the host and its serial port connected to another virtual machine will be connected to your serial port on the host named pipe, two serial ports so that the virtual machine will be able to even up. Here are two virtual machines use their own COM1 port, the host of the named pipe is the same pipe / tmp / vbox, when configuring a channel is created (assuming Ubuntu8.10DevOS), the other is not created. Start the virtual machine to create a channel when you start, and then start the other virtual machines, each virtual machine to open two terminals, each with the following command COM1 port input and output are set to 115200 baud
stty ispeed 115200 ospeed 115200 -F / dev / ttyS0
Executed on one of the virtual machine A terminal
cat / dev / ttyS0
Execute on another virtual machine B
echo ok> / dev / ttyS0
A virtual machine then terminal B will receive messages sent ok.