https://wiki.xenproject.org/index.php?title=XCP_Ubuntu_PCIPassthrough&feed=atom&action=historyXCP Ubuntu PCIPassthrough - Revision history2024-03-28T09:25:18ZRevision history for this page on the wikiMediaWiki 1.31.3https://wiki.xenproject.org/index.php?title=XCP_Ubuntu_PCIPassthrough&diff=2721&oldid=prevAngrygreenfrogs at 10:58, 28 February 20122012-02-28T10:58:46Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 10:58, 28 February 2012</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 4:</td>
<td colspan="2" class="diff-lineno">Line 4:</td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>I don't believe you can do USB-only pass through with XCP 1.0. However, you can do PCI pass-through and pass-through the entire USB controller device.</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>I don't believe you can do USB-only pass through with XCP 1.0. However, you can do PCI pass-through and pass-through the entire USB controller device.</div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td class="diff-marker">−</td>
<td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Read this guide: it contains most of the answers, even if it's hard to parse: [<del class="diffchange diffchange-inline">http://new-wiki.xen.org/old-wiki/xenwiki/XenPCIpassthrough.html XEN PCI Passthrough</del>]</div></td>
<td class="diff-marker">+</td>
<td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Read this guide: it contains most of the answers, even if it's hard to parse: [<ins class="diffchange diffchange-inline">[Xen_PCI_Passthrough]</ins>]</div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>NOTE: Although this entire procedure worked, in the end I have to admit I found that PCI passthrough was too complex and not reliable enough for my purposes, so please give it a try, but I recommend doing it on a test machine.</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>NOTE: Although this entire procedure worked, in the end I have to admit I found that PCI passthrough was too complex and not reliable enough for my purposes, so please give it a try, but I recommend doing it on a test machine.</div></td>
</tr>
</table>Angrygreenfrogshttps://wiki.xenproject.org/index.php?title=XCP_Ubuntu_PCIPassthrough&diff=2720&oldid=prevAngrygreenfrogs: Created page with "=Introduction= The below is only applicable to PV hosts. In this example the OS used was Ubuntu 10.04 LTS. I don't believe you can do USB-only pass through with XCP 1.0. However…"2012-02-28T10:58:12Z<p>Created page with "=Introduction= The below is only applicable to PV hosts. In this example the OS used was Ubuntu 10.04 LTS. I don't believe you can do USB-only pass through with XCP 1.0. However…"</p>
<p><b>New page</b></p><div>=Introduction=<br />
The below is only applicable to PV hosts. In this example the OS used was Ubuntu 10.04 LTS.<br />
<br />
I don't believe you can do USB-only pass through with XCP 1.0. However, you can do PCI pass-through and pass-through the entire USB controller device.<br />
<br />
Read this guide: it contains most of the answers, even if it's hard to parse: [http://new-wiki.xen.org/old-wiki/xenwiki/XenPCIpassthrough.html XEN PCI Passthrough]<br />
<br />
NOTE: Although this entire procedure worked, in the end I have to admit I found that PCI passthrough was too complex and not reliable enough for my purposes, so please give it a try, but I recommend doing it on a test machine.<br />
<br />
=Confirm that your dom0 supports pciback=<br />
I used XCP 1.0 in my case, which does support pciback, so you can skip this if you're on XCP.<br />
<br />
<pre><br />
# (on dom0)<br />
# Look for 'pciback' here<br />
ls /sys/bus/pci/drivers/<br />
</pre><br />
<br />
=Confirm domU supports pciback=<br />
Now check your Linux domU (guest OS) for pci-passthrough support (needs xen-pcifront module). Your Ubuntu system must have xen-pcifront/xen_pcifront installed in the kernel for pci pass-through to work. Basically your kernel version must be v2.6.37+ to have it included by default.<br />
<pre><br />
# (on domU)<br />
# check the version<br />
uname -a<br />
</pre><br />
<br />
"uname -a" should return a kernel version greater than 2.6.37. <br />
<br />
=Custom domU pciback kernel=<br />
If your kernel version is less than 2.6.37, and there are no readily available replacement kernels, you can compile a custom kernel yourself.<br />
<br />
==Compiling the kernel==<br />
No Ubuntu 10.04 packages exist for a kernel of this version. I also tried the kernels located here: http://kernel.ubuntu.com/~kernel-ppa/mainline/, but apparently they're not compiled with Xen support or something because my XCP refused to boot the kernel complaining about missing modules... so I finally gave up and compiled my own kernel:<br />
<pre><br />
# (on domU)<br />
<br />
# v2.6.37+ linux has pcifront built in:<br />
# if you have a lower version, you need a newer kernel<br />
# here's compile instructions I used on Lucid 10.04:<br />
# reference: http://linuxtweaking.blogspot.com/2011/02/how-to-compile-kernel-from-kernelorg-in.html<br />
#<br />
# If you feel like living dangerously/lazily, you can try to use the 32-bit kernel I compiled..<br />
# I've put up a link here, but naturally this comes with NO warranty at all, and Ubuntu specifically states<br />
# compiling your own kernel voids any potential warranty/support.. so there's that..<br />
# anyways:<br />
# http://dev.locatrix.com/linux-headers-2.6.37_2.6.37-10.00.Custom_i386.deb<br />
# http://dev.locatrix.com/linux-image-2.6.37_2.6.37-10.00.Custom_i386.deb<br />
# so skip most of the below and follow along from where it starts with dpkg -i for the above files <br />
<br />
cd ~ # or somewhere<br />
<br />
apt-get install fakeroot kernel-wedge build-essential makedumpfile kernel-package libncurses5 libncurses5-dev<br />
apt-get build-dep --no-install-recommends linux-image-$(uname -r)<br />
<br />
mkdir src<br />
cd src<br />
<br />
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.37.tar.gz<br />
tar xvf linux-2.6.37.tar.gz<br />
cd linux-2.6.37<br />
<br />
# basically I left all the defaults alone.. seemed to already include xen and everything else<br />
#for some god unknown reason I did have to uncheck the option labeled "one laptop per child" (OLC) support... no clue..<br />
make menuconfig<br />
<br />
export CONCURRENCY_LEVEL=3<br />
make-kpkg clean<br />
time fakeroot make-kpkg --initrd kernel-image kernel-headers<br />
<br />
cd ..<br />
ls -l # note the package file names and install them<br />
<br />
dpkg -i linux-headers-2.6.37_2.6.37-10.00.Custom_i386.deb<br />
dpkg -i linux-image-2.6.37_2.6.37-10.00.Custom_i386.deb<br />
update-initramfs -c -k 2.6.37<br />
<br />
update-grub<br />
<br />
# note down the new kernel/init versions<br />
ls -la /<br />
# e.g. /vmlinuz-2.6.37 /initrd.img-2.6.37<br />
<br />
#shutdown<br />
halt<br />
</pre><br />
<br />
==Configure XCP to use the new kernel==<br />
Here's how I re-configured my dom0 XCP to use the new kernel (this is the same as you configure it in the first place for which kernel to use):<br />
<br />
<pre><br />
# BACK on dom0<br />
<br />
#find VM's uuid<br />
xe vm-list<br />
<br />
#take down a copy of this stuff before you change it<br />
xe vm-param-list uuid=MYUUID<br />
<br />
#specifically we'll modify the bootloader<br />
xe vm-param-list uuid=MYUUID | grep PV-bootloader-args<br />
<br />
#make sure your VM is now set to boot from the new kernel<br />
#this may or may not apply to you.. but I configured my VM to have the kernel/ramdisk set this way.<br />
#make sure to modify the below to match your exact kernel/ramdisk and remember the above in case you need to change it back.<br />
xe vm-param-set uuid=MYUUID PV-bootloader-args="--kernel=/vmlinuz-2.6.37 --ramdisk=/initrd.img-2.6.37"<br />
<br />
xe vm-param-list uuid=MYUUID | grep PV-args<br />
# note the args.. modify to add "iommu=soft swiotlb=force", for example:<br />
xe vm-param-set uuid=MYUUID PV-args="root=/dev/MYBOOTDRIVE ro quiet iommu=soft swiotlb=force"<br />
Now search for the PCI device you want to passthrough. I wanted to passthrough a USB device, so that's what I'm doing here:<br />
<br />
# (on dom0)<br />
#search for the device/pci information.. couple different ways:<br />
<br />
#easy way to identify pci devices:<br />
lspci -tv<br />
<br />
#best way to get the exact pci number, the device number should be from here:<br />
ls /sys/bus/pci/devices<br />
<br />
#some more general info for USB for confirmation<br />
#for usb 2.0<br />
dmesg | grep ehci_hcd<br />
#e.g. ehci_hcd 0000:00:1d.7: PCI INT A -> GSI 21 (level, low) -> IRQ 21<br />
#for usb 1.1<br />
dmesg | grep uhci_hcd<br />
#e.g. uhci_hcd 0000:00:1d.3: irq 23, io base 0x0000ff20<br />
#note down the pci address 0000:00:1d.7<br />
# how I found the usb 1.1 UPS device:<br />
dmesg | tail<br />
#usb 2-1: USB disconnect, address 2<br />
#usb 2-1: new low speed USB device using uhci_hcd and address 3<br />
<br />
# regardless really use the device number from /sys/bus/pci/devices above <br />
</pre><br />
<br />
=Setup PCI passthrough=<br />
Now set the PCI devices to pass through. The below seems to be correct. The 0/ seems to be the virtual bus number.. so from what I understand it should always be 0.<br />
<pre><br />
# (on dom0)<br />
#the below is a comma separated list of each PCI device to pass-through.. I passed through all of my USB controllers that I found<br />
#the list could be just one device, like "other-config:pci=0/0000:00:1d.0".. I passed through all of them:<br />
xe vm-param-set other-config:pci=0/0000:00:1d.0,0/0000:00:1d.1,0/0000:00:1d.2,0/0000:00:1d.3,0/0000:00:1d.7 uuid=MYUUID <br />
<br />
#You can later remove this setting if needed<br />
xe vm-param-remove param-name=other-config param-key=pci uuid=MYUUID<br />
</pre><br />
<br />
Start up the VM again<br />
<pre><br />
# (on dom0)<br />
xe vm-start uuid=MYUUID <br />
</pre><br />
<br />
Watch the xcp system logs as the machine boots to catch the pciback passthrough messages<br />
<pre><br />
# (on dom0)<br />
tail -f /var/log/kern.log<br />
<br />
I received messages like "FLR functionality not supported", but apparently that shouldn't stop it from working. The bottom of this page talks about FLR: XenPCIpassthrough<br />
<br />
The below allows live attaching a pci device to the VM. This also worked once I fixed up the linux kernel as above.<br />
<br />
<pre><br />
# (on dom0)<br />
xl list<br />
# note down the "Name" for your VM.. use below...<br />
# again, the PCI device number here is from "ls /sys/bus/pci/devices" (with "lspci -tv" helping you find the right one)<br />
xl pci-attach mymachinename 0000:00:1d.7<br />
<br />
# there's other handy xl commands..<br />
# xl pci-detach mymachinename 0000:00:1d.7<br />
# xl pci-list mymachinename<br />
</pre><br />
</pre></div>Angrygreenfrogs