While working on virtualisation of custom services, I came across ivshmem module in kvm that I am now using to have interrupts and shared memory between host and multiple guests. Setting it up is easy, but available documentation is outdated.
Configuration
Host: Ubuntu 11.10, installed qemu-kvm
Guest: Gentoo, for minimal configuration and maximum customisability
Making it work
- Download and compile ivshmem support code from nahanni’s gitorious repo on host and guest(s):
git clone https://git.gitorious.org/nahanni/guest-code.git - [Host] Go to ivshmem_server folder in downloaded code, build and run the following:
./ivshmem_server -m 512 -s nahanni -p /tmp/nahanni - [Host] Run guest vm(s) using the following command line (or any other arguments):
kvm -boot d -hda vhost-gentoo.raw -cpu core2duo -m 1G -chardev socket,path=/tmp/nahanni,id=nahanni -device ivshmem,chardev=nahanni,size=512m,ioeventfd=on,vectors=8 - [Guest] Go to kernel_module/standard folder in downloaded code, build and run
insmod kvm_ivshmem.ko - Check the kernel messages, make sure you see ‘MSI-X enabled’. If there is any error, fix the error first.
dmesg | tail - Check major number allocated to the char device created:
cat /proc/devices | grep kvm_ivshmem - Use the major number above – it’s ’250′ for my sequence of actions on my configured VM.
mknod --mode=666 /dev/ivshmem c 250 0 - If you have multiple ivshmem devices serving different purposes
# for each ivshmem device
mknod --mode=666 /dev/ivshmem<n> c <n> - It works now! Try the test code in tests folder in downloaded support code.
—

Follow me on Twitter