Xen & PCI Passthrough

Xen & PCI Passthrough

December 15, 2009 19:29 2 comments
 
4 Kudos
Don't
move!

Yesterday we have made the tree. Don’t know what’s the correct translation of that but, I mean, we have decorated the tree. You know.. when you put some fancy balls on a tree to celebrate Christmas properly..
Well, during this task I’ve discovered that I am not using my Wireless Phones so much so I was wondering about a way to make use of them.

So came to my mind brilliant idea to try to connect those phones to my XEN home-server.
I rebooted the machine, enabled integrated audio in the BIOS and I started looking for a solution to pass the relative PCI audio controller to my virtual machine “aquaria” that is the one devoted to such a task.

By “Googleing” around I’ve found very few sparse information so I decided to blog about this, since I think PCI passthrough is a XEN point of strength.

PCI passthrough means the ability to literally pass a PCI peripheral to a domU domain in order to gave it the full control of that peripheral.
There are two ways to achieve this: using pciback or pcistub.
I’m going to consider only pciback in my post because I think it’s the most elegant solution.

In order to make your dom0 providing such a feature you’ll need CONFIG_XEN_PCIDEV_BACKEND=y in your dom0 kernel configuration.
In order to make your domU acknowledging such device you’ll need CONFIG_XEN_PCIDEV_FRONTEND=y in your domU kernel configuration.

Please, double check your configuration.

As far as I know, CONFIG_XEN_PCIDEV_FRONTEND, is available only in xen-patched kernel (so you won’t find such parameter in your vanilla kernel). I think this is a huge limitation since I hadn’t ever installed a xen-patched-domU kernel since yesterday. I hope someday it’s going to be merged in mainline.

However this isn’t enough to get your XEN environment working properly.
To allow dom0 passing the PCI device you should collect its address:

Once you gathered those informations, you have to edit /boot/grub/grub.conf file in order to tell dom0 to use pciback to handle that PCI controller:

The next step is to properly configure your domU so, open its configuration file and add

.

Theorically this should be enough to make your domU working properly.

This is my dom0 dmesg after being restarted:

And these are my domU dmesg and lspci:

I hope this walkthrough has been useful to you. If someone more experienced than me in these things would contact me to fix some mistakes, I’d be glad to hear him/her out :)

  • Michel

    Thanks for this great post, please help me in this line:
    “The next step is to properly configure your domU so, open its configuration file and add ”

    where is the domU configuration file.

  • elbryan

    Where you created it or where your distribution put it at the first time.
    I think the default target is */etc/xen* but I put all the configuration files inside a */xen/config* directory (that I created myself).

    *In gentoo*: If you browse the */etc/xen* directory, you’ll find a lot of configuration files.
    Your question is quite strange because you usually have to modify a bit every guest machine configuration file in order to attach it to the right devices and set memory values and so on.

    Which distribution do you use?