# VFIO Pass through working on 9070XT

> Source: <https://forum.level1techs.com/t/vfio-pass-through-working-on-9070xt/227194?page=4#post_79>
> Published: 2026-09-15 13:19:42+00:00

Hi All,

I just wanted to share some updates, that might help anyone struggling with their 9070XT.

My initial process was:

``` bash
#!/bin/bash

systemctl stop lightdm.service
sleep 2

echo 0000:10:00.0 > /sys/bus/pci/drivers/amdgpu/unbind
sleep 2

 0000:10:00.1 > /sys/bus/pci/drivers/snd_hda_intel/unbind
#sleep 2

echo 3 > /sys/bus/pci/devices/0000:10:00.0/resource2_resize
sleep 2

systemctl start lightdm.service
```

I haven’t actually used my VMs for several months, fast forward to a couple of days ago, and when i tried it, it no longer works the same. I can use the script, start the VM, and the VM starts with the GPU attached, but upon exiting, the driver would no longer grab the GPU back, meaning the only way i could run another VM or reset my GPU was by doing a hard reset. According to Google AI this is because between 6.12 and 7.2 there have been changes to the hardware scheduler and power management.

However, with google’s help I was able to come up with the following script, which has been added to the libvirt/hooks directory. And now it automatically does everything. I can start and stop VMs without a hard reset. I have used it a bunch of times and so far, it has worked every time.

``` bash
#!/bin/bash

# CONFIGURATION: The target PCIe address of your secondary AMD card
GPU_PCI="0000:10:00.0"

ACTION="$2"
PHASE="$3"

# 1. RUN BEFORE ANY VM BOOTS (Prepares the card without freezing)
if [ "$ACTION" = "prepare" ] && [ "$PHASE" = "begin" ]; then
    # Stop LightDM cleanly from the system background
    systemctl stop lightdm.service
    sleep 2

    # Unbind from host driver
    if [ -e "/sys/bus/pci/devices/$GPU_PCI/driver" ]; then
        echo "$GPU_PCI" > /sys/bus/pci/drivers/amdgpu/unbind 2>/dev/null
        sleep 2
    fi

    # Set BAR size down for VM compatibility
    echo 3 > /sys/bus/pci/devices/$GPU_PCI/resource2_resize 2>/dev/null
    sleep 1
    
    # Restart LightDM right away so your host desktop comes back online while VM is running
    systemctl start lightdm.service
fi

# 2. RUN AFTER ANY VM SHUTS DOWN (Reclaims the card safely for successive boots)
if [ "$ACTION" = "release" ] && [ "$PHASE" = "end" ]; then
    # Stop LightDM in the background so X11 stops polling the hardware lanes
    systemctl stop lightdm.service
    sleep 2

    # Clear driver overrides and force bind safely
    echo "amdgpu" > /sys/bus/pci/devices/$GPU_PCI/driver_override 2>/dev/null
    echo "$GPU_PCI" > /sys/bus/pci/drivers/amdgpu/bind 2>/dev/null
    sleep 2

    # Restart LightDM to securely restore your desktop environment
    systemctl start lightdm.service
fi
```

So, I wanted to share it in case it can help anyone else.
