[libvirt] virtio serial config

Matthew Booth mbooth at redhat.com
Thu Mar 18 15:59:31 UTC 2010

On 18/03/10 14:31, Matthew Whitehead wrote:
> Matthew,
>   Dan B referred me to you. I want to create 4 (or more) virtual serial devices between two KVM virtual hosts. The output of one serial device would be the input to the other. Virt-manager doesn't provide this, so I'm prepared to hack the config files manually. Unfortunately, I can't find documentation on the syntax.
> Can you assist?

I'm normally the one complaining about lack of documentation :) That's
quite an oversight.

The basic syntax for a virtio-serial channel is:

    <channel type='pty'>
      <target type='virtio' name='org.linux-kvm.port.1'/>

You'll want 4 <channel/> entries per guest. Give them all different names.

The interesting bit is going to be plugging the character devices
together on the host. I'm pretty sure you'll have to use pipes. Note
that afaik the libvirt documentation on this is wrong and misleading.
Don't read it, just test instead :)

IIRC, the way pipes actually work is that it expects to be able to use 2
pipes based on the path you specify, called foo.in and foo.out. I seem
to recall you need to create these manually too. The following advice is
completely untested. It may also be responsible for global warming and
the rise of reality TV.


# mkfifo /tmp/guesta-virtioserial{1,2}.{in,out}
# ln /tmp/guesta-virtioserial1.in /tmp/guestb-virtioserial1.out
# ln /tmp/guesta-virtioserial1.out /tmp/guestb-virtioserial1.in
# ln /tmp/guesta-virtioserial2.in /tmp/guestb-virtioserial2.out
# ln /tmp/guesta-virtioserial2.out /tmp/guestb-virtioserial2.in

Guest A:

<channel type='pipe'>
  <source path="/tmp/guesta-virtioserial1"/>
  <target type='virtio' name='org.linux-kvm.port.1'/>
<channel type='pipe'>
  <source path="/tmp/guesta-virtioserial2"/>
  <target type='virtio' name='org.linux-kvm.port.2'/>

Guest B:

<channel type='pipe'>
  <source path="/tmp/guestb-virtioserial1"/>
  <target type='virtio' name='org.linux-kvm.port.1'/>
<channel type='pipe'>
  <source path="/tmp/guestb-virtioserial2"/>
  <target type='virtio' name='org.linux-kvm.port.2'/>

At this point, both virtio-serial devices in each guest should be

Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:       +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

More information about the libvir-list mailing list