Tuesday, July 09, 2013

Installing Hyper-V PV Drivers for Linux Guests

Background 


PV, or paravirtualization improves VM performance bypassing hardware emulation where the emulator would introduce significant and unnecessary overhead.  A good example is a VMs networking stack, which exists twice.  Once in the VM, and again in the parent operating system running on the hypervisor.

PV drivers allow a guest O/S to take advantage of optimisations offered by PV.  Using drivers is an easy way to allow the kernel to take advantage of PV facilities without requiring that the kernel by recompiled with hypervisor PV APIs in mind.  E.g. externally, the networking PV driver can be used by an unchanged kernel, and internally it is a thin wrapper over the hypervisor's networking API.


Problem


Turning to Hyper-V, it's PV drivers and accompanying utils are referred to as "Linux Integration Services" aka LIS.  The latest versions are available for download.  This gives you an ISO for RPMs for supported Linux distributions.

The difficulty for me is that the ISO contains only RPMs, and they target the older linux kernel typical of even recent versions of RHEL.  LIS is not compatible with CloudStack's internal services that are implemented by VMs running Debian Wheezy...

# uname -r
3.2.0-4-686-pae

# cat /etc/*-release
Cloudstack Release 4.2.0 Fri Jul  5 04:16:17 UTC 2013
PRETTY_NAME="Debian GNU/Linux 7.0 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7.0"
VERSION="7.0 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"

Solution


Fortunately, Debian Wheezy was compiled with the Hyper-V drivers.  You can verify the presence of the kernel modules using using modinfo  E.g.

# modinfo -F filename hid-hyperv hv_storvsc hv_netvsc hv_vmbus hv_utils
/lib/modules/3.2.0-4-686-pae/kernel/drivers/hid/hid-hyperv.ko
/lib/modules/3.2.0-4-686-pae/kernel/drivers/scsi/hv_storvsc.ko
/lib/modules/3.2.0-4-686-pae/kernel/drivers/net/hyperv/hv_netvsc.ko
/lib/modules/3.2.0-4-686-pae/kernel/drivers/hv/hv_vmbus.ko
/lib/modules/3.2.0-4-686-pae/kernel/drivers/hv/hv_utils.ko

NB:  As of linux kernel 3.2, hv_timesource is no longer an independent kernel module (source).

However I still need the user mode daemons that make up LIS.  

Hyper-V Key Value Pair (KVP) Component


The KVP component that is responsible for transferring data in the form of key value pairs between the host and the guest O/S.  It also performs other tasks.

Using rpm2cpio, you can extract the daemon and service controller from the RPM.  rpm2cpio returns the .cpio, which a. tar, is a concatenation of files.    This guide explains how to get the actual contents.  E.g. 

# rpm2cpio microsoft-hyper-v-rhel63.3.4-1.20120727.i686.rpm | cpio -idmv
./etc/init.d/hv_kvp_daemon
./etc/modprobe.d/hyperv_pvdrivers.conf
./usr/sbin/hv_kvp_daemon
28 blocks


Final Remarks


The file ./etc/init.d/hv_kvp_daemon provides only an example of how to start the daemon, but it cannot be used directly.  The  script is not tailored to Debian, because it uses distro-specific methods from /etc/init.d/functions such as daemonDebian offers equivalent functionality in the start-stop-daemon function (source).

Finally, the licensing for the binary fo daemon built by MSFT is ambiguous.  Unlike the drivers, which modinfo lists as GPL, the binary makes no statement on its terms of licensing.

No comments :