# Vfio driver override not working

## genvfio

Hey,

I'm trying to override the driver of my graphicscard with vfio-pci to passthrough it for my kvm but this sh** is not working very well  :Sad: 

I have two identical cards so I can't use the vendor ids. For assinging the kernel driver I use the initramfs dracut.

Dracut script:

```
#!/bin/bash

# called by dracut

check() {

    require_binaries /bin/bash

}

# called by dracut

depends() {

    return 0

}

# called by dracut

install() {

    inst_simple "/sbin/vfio-pci-override.sh"

    inst_simple "/etc/modprobe.d/vfio.conf"

}

```

/sbin/vfio-pci-override.sh script:

```
#!/bin/sh

 

# 03:00.0 is the pci-bus of my graphics card and 03:00.1 its sound bus

# that I want to use for my virtual machine

DEVS="0000:03:00.0 0000:03:00.1"

 

for DEV in $DEVS; do

    echo "vfio-pci" > /sys/bus/pci/devices/$DEV/driver_override

done

 

modprobe -i vfio-pci

```

/etc/modprobe.d/vfio.conf script:

```
install vfio-pci /sbin/vfio-pci-override.sh

```

When I run my kernel with the initramfs the graphicscard uses vfio-pci but not the soundcard:

lspci -nnk:

```

03:00.0 VGA compatible controller [0300]: NVIDIA Corporation GM204 [GeForce GTX 970] [10de:13c2] (rev a1)

   Subsystem: Gigabyte Technology Co., Ltd GM204 [GeForce GTX 970] [1458:367a]

   Kernel driver in use: vfio-pci

   Kernel modules: nvidia_drm, nvidia

03:00.1 Audio device [0403]: NVIDIA Corporation GM204 High Definition Audio Controller [10de:0fbb] (rev a1)

   Subsystem: Gigabyte Technology Co., Ltd GM204 High Definition Audio Controller [1458:367a]

   Kernel driver in use: snd_hda_intel

```

But in /sys/bus/pci/devices/0000:03:00.1/driver_override is vfio-pci so I don't know why only the VGA controller is using the vfio-pci.

I hope you have an idea what I could do and how to resolve the problem.

Thanks in advance.

----------

## Plumbo

Hi,

I've never tried this with two identical cards before, but I would imagine that complicates things somewhat.

Do you have the audiodrivers built in-kernel?  If so, what happens if you let vfio claim them in-kernel and load the audio as modules?

Also, I've never used the driver_override as you have, but in my QEmu-launchscript I have this to unload alsa-drivers and passthrough the hole card to the guest:

/etc/init.d/alsasound stop

echo "8086 8d20" > /sys/bus/pci/drivers/vfio-pci/new_id

echo "0000:00:1b.0" > /sys/bus/pci/drivers/snd_hda_intel/unbind

echo "0000:00:1b.0" > /sys/bus/pci/drivers/vfio-pci/bind

echo "8086 8d20" > /sys/bus/pci/drivers/vfio-pci/remove_id

This removes snd_hda_intel (which I use in linux), and replaces it with vfio-pci. Maybe you can try the same, and if your second card gets assigned as well you can always do the reverse when exiting the guest. Having both binded to vfio wont matter as long as you're in the guest system.

Hope you figure it out.   :Very Happy: 

----------

