kernel virtual machine

iommu unbind for kvm

Might put something like this in /etc/default/libvirtd. The iommu_group is used because all these devices might share the 1 interrupt and system complains (risk of instability) if they are split up. Then we can tell virt-manager to claim the pci devices for a guest, I left the topmost device, a pci bridge out.

This is tried on ASUS P9D with Intel i7-4790K CPU. In this case I have to assign both pci slots and the onboard IEEE1394 controller

for N in /sys/kernel/iommu_groups/9/devices/*
do
        P=`echo ${N} | cut -c36-`
        if L=`readlink -f /sys/bus/pci/devices/${P}/driver`
        then
                if test "${L}" != "/sys/bus/pci/drivers/pci-stub"
                then
                        if test `echo ${L} | cut -c1-21` == "/sys/bus/pci/drivers/"
                        then
                                echo ${P} > "/sys/bus/pci/devices/${P}/driver/unbind"
                        fi

                        VEN=`</sys/bus/pci/devices/${P}/vendor cut -c3-`
                        DEV=`</sys/bus/pci/devices/${P}/device cut -c3-`
                        echo "${VEN} ${DEV}" > /sys/bus/pci/drivers/pci-stub/new_id
                        #echo $BASE > /sys/bus/pci/drivers/pci-stub/bind
                fi
        fi
done