I have virtio-serial devices working on a handful of guests. Here is
some information about how I configured it, etc.
First, I should point out a few useful resources on the web.
[1]
http://fedoraproject.org/wiki/Features/VirtioSerial
[2]
http://www.linux-kvm.org/page/VMchannel_Requirements
[3]
http://fedorapeople.org/gitweb?p=amitshah/public_git/test-virtserial.git
There is some good informatio here, including examples of how to
create a virtioserial device on the command-line. There is now,
however, much information about configuring these devices from the
guest config file (XML).
Here is what I added to my guest config file:
<controller type='virtio-serial' index='0' ports='4'
vectors='0'>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x05' function='0x0'/>
</controller>
And ...
<channel type='unix'>
<source mode='bind' path='/path/to/socket'/>
<target type='virtio' name='org.linux-kvm.port.0'/>
</channel>
It is my understandin that the 'controller' block is not required and
should work with default values. However, there is currently a bug
that requires this block so that we can define ports to be != 0.
Matthew Booth has more information.
With this configuration, I get a UNIX socket on the host and a
character device on the host. Obviously the UNIX socket path can be
defined. In the guest, we'll get a character device and a symlink:
# ls -l /dev/vport0p1
crw-rw----. 1 root root 249, 1 May 13 17:53 /dev/vport0p1
# ls -l /dev/virtio-ports/org.linux-kvm.port.0
lrwxrwxrwx. 1 root root 11 May 13 17:53 /dev/virtio-ports/org.linux-kvm.port.0 ->
../vport0p1
I have a very simple client/service app (in C) that can communicate
over this channel. In a nutshell,
host:
- create socket (AF_UNIX)
- connect to socket
- write to socket
guest:
- open file (char device)
- poll
- read
Very simple. It needs to be improved such that each can handle 2-way
communication, but that should be simple.
Ryan