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

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.

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.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

One thought on “How to build a custom kernel module or device driver for XenServer

  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.

    How about showing us how you actually go about doing that? I tried just compiling the kernel source and get this error:

    CHK include/linux/version.h
    CHK include/linux/utsrelease.h
    SYMLINK include/asm -> arch/x86/include/asm
    make[1]: *** No rule to make target `missing-syscalls'. Stop.

    I'm sure there is an official way to do this but it is all very poorly documented.

Leave a comment

Your email address will not be published. Required fields are marked *

Current ye@r *