How to build a custom kernel module or device driver for XenServer

Last updated on November 5, 2012 by Dan Nanni

Citrix allows one to build any custom kernel module or hardware driver for XenServer, by offering Driver Development Kit (DDK). A DDK is essentially a virtual machine with all the kernel headers and development tools needed to extend the XenServer kernel. The following guide is on how to use DDK to compile a custom kernel module or hardware driver for XenServer (now called Citrix Hypervisor).

In this example, I am going to use the DDK downloadable from Citrix for XenServer 6.0 with Hotfix XS60E003. So you will need to have a XenServer host of the same version. If you just have installed fresh XenServer 6.0, you first need to apply Hotfix XS60E003 to your XenServer in order to use the DDK. Note that the Hotfix XE60E003 has two Hotfix dependencies: XS60E001 and XS60E001. Therefore, apply three Hotfixes one by one in sequence to fresh XenServer 6.0: XS60E001, XS60E002 and XS60E003. Here are the steps.

Download the Hotfixes from the following URLs, and apply these Hotfixes to your XenServer.

$ wget https://support.citrix.com/servlet/KbServlet/download/28993-102-680294/XS60E001.zip
$ wget https://support.citrix.com/servlet/KbServlet/download/29185-102-680311/XS60E002.zip
$ wget https://support.citrix.com/servlet/KbServlet/download/29609-102-680420/XS60E003.zip

After applying all three Hotfixes, reboot your XenServer host. Finally, confirm that you are running the following kernel on your updated XenServer:

$ uname -r
2.6.32.12-0.7.1.xs6.0.0.531.170662xen

Now, download DDK for XenServer 6.0 with Hotfix XS60E003:

$ wget http://downloadns.citrix.com.edgesuite.net/6225/XenServer-6.0.0-XS60E003-ddk.iso

Upload the DDK iso image to your XenServer host, and then import the uploaded DDK VM as follows.

$ mkdir -p /mnt/tmp
$ mount <path_to_DDK_ISO>/ddk.iso /mnt/tmp –o loop
$ xe vm-import filename=/mnt/tmp/ddk/ova.xml

The "xe vm-import" command will print out the UUID of your DDK VM. Make a note of the UUID (noted as <DDK-VM-UUID>).

Now follow the rest of steps below to launch the imported DDK VM.

Find the UUID of the network associated with pool-wide eth0 network by obtaining a list of networks as follows, and make a note of the UUID (noted as <network-UUID>).

$ xe network-list

Now, create a virtual interface of DDK VM.

$ xe vif-create network-uuid=<network-UUID> vm-uuid=<DDK-VM-UUID> device=0

Disable VNC of DDK VM:

$ xe vm-param-set uuid=<DDK-VM-UUID> other-config:disable_pv_vnc=1

Start DDK VM:

$ xe vm-start uuid=<DDK-VM-UUID>

Retrieve domain ID of the DDK VM:

$ xe vm-list params=dom-id uuid=<DDK-VM-UUID> --minimal
1

In this example, the domain ID of the DDK VM is 1. So connect to the VM text console as follows:

$ /usr/lib/xen/bin/xenconsole 1

Once logging in to DDK VM, you will find the kernel source for your XenServer in /usr/src/kernels/2.6.32.12-0.7.1.xs6.0.0.531.170662xen-i686/. You can build your own custom kernel module or hardware driver using this kernel source inside DDK VM.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean