How to share liblitmus with a virtual machine
To make the userspace libraries of LITMUSRT (liblitmus) available to the virtual machine in kvm , it is convenient to set up an NFS-server on the host to synchronize the libraries automatically. I used a Debian system for my setup, but it should be easy to adapt the following instructions to other Linux distributions. On both the host and the client, /var/nfs will be the shared directory.
First we install and configure nfs on the host:
apt-get install nfs-kernel-server nfs-common portmap mkdir /var/nfs chown nobody:nogroup /var/nfs/
Enter into /etc/exports:
/var/nfs localhost(rw,sync,no_subtree_check,all_squash,insecure,anonuid=1000)
Where 1000 is the userid for your user name. (View /etc/passwd for example)
Still on the host, we need to make sure that the NFS directory is shared and that your user account has access to it:
exportfs -a usermod -aG nogroup $USER chmod g+w /var/nfs
Again, you should substitute $USER with the right name.
To make the virtual machine able to use the network and NFS, we need to ensure that the desired features are enabled in the kernel configuration. I had to add for internet connection:
- CONFIG_NET_ETHERNET=y
- CONFIG_NET_PCI=y
- CONFIG_8139CP=y
and for NFS:
- CONFIG_NETWORK_FILESYSTEMS=y
- CONFIG_NFS_V4=y
then make menuconfig automatically adds:
- CONFIG_NFS_FS=y
- CONFIG_LOCKD=y
- CONFIG_NFS_COMMON=y
- CONFIG_SUNRPC=y
- CONFIG_SUNRPC_GSS=y
- CONFIG_RPCSEC_GSS_KRB5=y
- CONFIG_KEYS=y
- CONFIG_DNS_RESOLVER=y
Now you should start kvm with the following command to enable network connection (view also How to start kvm) :
kvm -smp 2 -m 512 -boot c -vga std -net nic -net user,hostfwd=tcp::10022-:22 -kernel path_to_kernel/arch/x86/boot/bzImage -append root=/dev/hda1 -hda kvm_image.img
On the client we also need some configurations:
mkdir /var/nfs
And we want to automatically mount the new network directory. Add the following entry to /etc/fstab:
10.0.2.2:/var/nfs /var/nfs nfs defaults 0 0