PCI Delegation in Xen (Xen Pci Passthrough)

#
# Debian 7
#
# add xen-pciback to initrd
echo "xen-pciback" >> /etc/modules
update-initramfs -u

# hide device (module and pciid have to be adapted)
cat < /etc/modprobe.d/xen-pciback.conf
install e100 modprobe xen-pciback; modprobe --first-time --ignore-install e100
options xen-pciback hide=(00:0c.0)
EOF

# test
xm pci-list-assignable-devices

# Links
http://wiki.xen.org/wiki/Assign_Hardware_to_DomU_with_PCIBack_as_module
http://debianforum.de/forum/viewtopic.php?f=32&t=139776
http://nixnote.blogspot.de/2012/03/xen-part-9-pci-passthrough.html
http://wiki.xen.org/wiki/Bind_lib.bash_:_A_script_that_makes_pciback_with_modules_easier_to_use

#
# Debian 6
#
# get pci id (for example avm isdn card)
lspci | grep Ethernet | cut -d " " -f1

# hide deivce in Dom0 (Debinan 6.0)
sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT="quiet"|GRUB_CMDLINE_LINUX_DEFAULT="xen-pciback.hide=(00:09.0)(01:02.0) quiet"|g' /etc/default/grub
# xen-pciback.permissive pci=resource_alignment=00:09.0;01:02.0
#echo "GRUB_CMDLINE_XEN_DEFAULT=\"iommu=1\"" >> /etc/default/grub
update-grub

sed -i 's|#(pci-passthrough-strict-check yes)|(pci-passthrough-strict-check no)|g' /etc/xen/xend-config.sxp

reboot

# view hidden devices
xm pci-list-assignable-devices

# add device to DomU
cat <> /etc/xen/${DOMAIN_NAME}
pci = ['00:09.0','01:02.0']
extra = 'iommu=soft swiotlb=force'
EOF

# OPTIONAL: configure second nic in domU
mount /dev/vg1/${DOMAIN_NAME}-disk /mnt/
cat <> /mnt/etc/network/interfaces
auto eth1
iface eth1 inet dhcp
# post-up ethtool -K eth0 tx off
EOF
umount /mnt

# hide device in Dom0 (Debian 5.0)
vi /boot/grub/menu.lst
pciback.permissive pciback.hide=(05:00.0)(01:07.0)

# USB
# to delegate USB devices you need to delegate the PCI USB controller to the DomU

# LINKS
http://wiki.xen.org/xenwiki/XenPCIpassthrough
http://lubl.de/blog/2009/09/creating-a-squeeze-amd64-domu/
http://wiki.xen.org/xenwiki/VTdHowTo
http://wiki.xen.org/xenwiki/XenPCIpassthrough
http://www.neobiker.de/wiki/index.php?title=USB_in_DomU