The OKL4 File System: Inter-VM communications

The okl4fs module is used for inter-vm communications. It allows you to create a bi-directional fifo-like channel between OK Linux and another VM, presumably a native OKL4 application. This is useful in situations when IPC is unsuitable, for example if you want to transfer long messages or lots of raw data between VMs.

The general procedure for using the channel is very simple:

  1. Perform a mknod call to create a new fifo file.
  2. Open the new file.
  3. Read and write like you would with a normal fifo.

To see exactly what is going on, there are a few places to look. The first is the okl4fs kernel module in OK Linux located at:

linux/arch/l4/kernel/fs/okl4fs

It doesn't do much - it is really just a wrapper around the real okl4fs code which resides in the fs library in OKL4.

Secondly, there is the fs library itself in OKL4, located in libs/fs. The main points of interest here are read/write, socketpair and memsec_malloc. Intervm communication is built on the intra-VM pipe/socketpair functionality as it is conceptually very similar - the only difference is that the two virtual machines must share a common memory region and data structures. The socketpair code does the initial setup of the data structures, and uses memsec_malloc instead of the standard malloc to ensure that they are allocated from the region of memory that is shared between the VMs.

The hardest part is actually configuring the channel at build time. It is backed by several Memsections which are shared between the VMs. These are configured on the OKL4 side - see the intervm example (in iguana/example/intervm) for a simple example of how this works. There are three memsections - one for communicating in each direction and another that is where all the shared control information (data structures and mutexes) is stored. Note that the two data memsections must be the same size but the control memsection can be different.

The intervm channel is still a prototype so it has several limitations. Firstly, there can only be one channel in the system . Secondly, each end of the channel can only be opened by one thread/process at a time. Finally, the file name that refers to the channel is hardcoded to "intervm_test" (so the file name must be "intervm_test" when calling mknod).

OKL4FS (last edited 2008-08-11 02:34:29 by localhost)