Sunday, June 23, 2013

Connecting two HelenOS guests in QEMU using SLIP

I've been recently working on implementing the SLIP protocol support for HelenOS, represented by the following ticket:

#439 SLIP IP link provider
It turned out that it was actually much more difficult to setup the environment for QEMU than to implement the actual SLIP support, even though on the HelenOS front I had to work around a known HelenOS IPC deficiency:
#508 Parallel sessions don't mix well with call forwarding
The basic SLIP support has been integrated into HelenOS in mainline revision 1849.

The following describes the steps that one needs to make in order to have two HelenOS instances running in QEMU talk to each other using SLIP. First of all, make sure to have a recent version of QEMU installed as versions prior to QEMU 1.5.0 may hang when dealing with the redirected serial port.

Since we are going to redirect and connect the serial ports of both HelenOS guests via two named pipes, we need to make some preparations first. On the host system, replicate the following steps:

$ mkfifo /tmp/fifoA.in /tmp/fifoA.out
$ ln -s /tmp/fifoA.out /tmp/fifoB.in
$ ln -s /tmp/fifoA.in /tmp/fifoB.out

Now, launch two HelenOS guests, each with its own pipe. Note that the symbolic links representing the fifo pair B are intentionally crossed so that QEMU opens each pipe in a proper way:

$ qemu-system-i386 -cdrom image.iso -serial pipe:/tmp/fifoA &
$ qemu-system-i386 -cdrom image.iso -serial pipe:/tmp/fifoB &

In the first HelenOS instance, run the following commands:

/ # slip devices/\hw\pci0\00:01.0\com1\a net/sl0
/ # inet create 10.0.0.1/24 net/sl0 ma
/ # inet add-sr 10.0.1.0/24 10.0.0.1 mr

And in the other HelenOS instance, run this set of commands:

/ # slip devices/\hw\pci0\00:01.0\com1\a net/sl0
/ # inet create 10.0.1.1/24 net/sl0 ma
/ # inet add-sr 10.0.0.0/24 10.0.1.1 mr

At this point, you should be able to ping the first instance from the second one and vice versa:









No comments: