Hello.

I've been tesing VGA passthrough using libvirt.
However, My Windows7(64bit) Virtual Machine stopped at loading screen as soon as I installed graphic driver(AMD Radeon HD 7750) and then restarted the VM.
How Can I use VGA passthrough technology in my Windows7 VM?
I attached my testing information(HW, system environment and settings, qemu log and so on..)

Best Regards.

------------------------------------- INFORMATION ------------------------------------------------------

<1. HW specificatioin>
1-(1). Motherboard: Gigabyte Z87X-OC-CF
1-(2). CPU: Intel(R) Core(TM) i5-4430 CPU @ 3.00GHz
1-(3). Video: AMD Radeon HD 7750
1-(4). Audio: AMD Radeon HD 7700/7800 Series

<2. System specification>
2-(1). OS: Debian 8.5 (Jessie)
2-(2). Kernel: 3.16.0-4-amd64
2-(3). qemu: v2.1.2
2-(4). libvirt: v1.2.9
2-(5). virt-manager: v1.0.1

<3. Testing process>
3-(1). Execute a vfio.sh script. -> # ./vfio.sh
3-(2). Execute the following command -> # virsh create windows7_test999_Radeon.xml
3-(3). Connect to windows7 VM via vnc viewer.
3-(4). Install AMD Radeon HD 7750 graphic driver.
3-(5). Rebooting.
3-(6). Infinite windows7 loading screen. ---> PROBLEM!! 

<4. Detailed system settings and script information>

4-(1). vfio.sh script

# ./vfio.sh

=========================
#!/bin/bash                                                                          

# vfio.sh

configfile=/etc/vfio-pci1.cfg

vfiobind() {
    dev="$1"
        vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
        device=$(cat /sys/bus/pci/devices/$dev/device)
        if [ -e /sys/bus/pci/devices/$dev/driver ]; then
                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id

}

modprobe vfio-pci

cat $configfile | while read line;do
    echo $line | grep ^# >/dev/null 2>&1 && continue
        vfiobind $line
done

exit 0
========================

4-(2). /etc/vfio-pci1.cfg

# cat /etc/vfio-pci1.cfg
0000:01:00.0
0000:01:00.1

# lspci -nn
---SNIP---
01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Cape Verde PRO [Radeon HD 7750 / R7 250E] [1002:683f]
01:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series] [1002:aab0]
---SNIP---


4-(3). /etc/initramfs-tools/modules

# cat /etc/initramfs-tools/modules
pci_stub ids=1002:683f,1002:aab0


4-(4). dmesg | grep pci-stub

# dmesg | grep pci-stub
[    2.863634] pci-stub: add 1002:683F sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
[    2.863642] pci-stub 0000:01:00.0: claimed by stub
[    2.863647] pci-stub 0000:02:00.0: claimed by stub
[    2.863662] pci-stub 0000:03:00.0: claimed by stub
[    2.863666] pci-stub 0000:04:00.0: claimed by stub
[    2.863669] pci-stub: add 1002:AAB0 sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
[    2.863673] pci-stub 0000:01:00.1: claimed by stub
[    2.863678] pci-stub 0000:02:00.1: claimed by stub
[    2.863684] pci-stub 0000:03:00.1: claimed by stub
[    2.863690] pci-stub 0000:04:00.1: claimed by stub

4-(5). /etc/modules

# cat /etc/modules
pci_stub
vfio
vfio_iommu_type1
vfio_pci
kvm
kvm_intel 


4-(6). /etc/default/grub

# cat /etc/default/grub

========================
# cat /etc/default/grub 
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on vfio_iommu_type1.allow_unsafe_interrupts=1"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
========================

4-(7). Kernel module check

# lsmod | grep pci_stub
pci_stub               12429  0 

# lsmod | grep vfio
vfio_pci               31388  0 
vfio_iommu_type1       17118  0 
vfio                   18402  2 vfio_iommu_type1,vfio_pci

# lsmod | grep kvm
kvm_intel             139116  0 
kvm                   388784  1 kvm_intel


4-(8). virsh create windows7_test999_Radeon.xml

# virsh create windows7_test999_Radeon.xml
Domain windows7_test999 created from windows7_test999_Radeon.xml


4-(9). virsh list

 Id    Name                           State
----------------------------------------------------
 2     windows7_test999               running
 
4-(10). qemu process check
 
# ps aux | grep qemu
root      1283 20.4 24.1 6788084 3965048 ?     SLl  16:45  16:17 qemu-system-x86_64 -enable-kvm -name windows7_test999 -S -machine pc-i440fx-2.1,accel=kvm,usb=off -m 3815 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid a2366bca-b992-4b02-b6ab-c6b2e8198362 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/windows7_test999.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot order=dc,menu=on,strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/data/iso/win7.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -drive file=/data/iso/virtio-win-0.1.118.iso,if=none,id=drive-ide0-1-1,readonly=on,format=raw -device ide-cd,bus=ide.1,unit=1,drive=drive-ide0-1-1,id=ide0-1-1 -drive file=/root/virsh/win7.qcow2,if=none,id=drive-virtio-disk0,format=qcow2,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0 -netdev tap,fd=24,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=94:de:80:a4:4b:39,bus=pci.0,addr=0x3 -device usb-tablet,id=input0 -vnc 0.0.0.0:0 -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device vfio-pci,host=01:00.0,id=hostdev0,bus=pci.0,addr=0x6 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 -msg timestamp=on
root      2228  0.0  0.0  16640  2312 pts/2    S+   18:05   0:00 grep qemu
 

4-(11). windows7_test999_Radeon.xml

========================

<domain type='kvm' id='2'>
  <name>windows7_test999</name>
  <uuid>a2366bca-b992-4b02-b6ab-c6b2e8198362</uuid>
  <memory unit='KiB'>3906560</memory>
  <currentMemory unit='KiB'>3906252</currentMemory>
  <vcpu placement='static'>2</vcpu>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.1'>hvm</type>
    <boot dev='cdrom'/>
    <boot dev='hd'/>
    <bootmenu enable='yes'/>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/data/iso/win7.iso'/>
      <backingStore/>
      <target dev='vdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/data/iso/virtio-win-0.1.118.iso'/>
      <backingStore/>
      <target dev='hdd' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-1'/>
      <address type='drive' controller='0' bus='1' target='0' unit='1'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/root/virsh/win7.qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>
    <controller type='usb' index='0'>
      <alias name='usb0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='ide' index='0'>
      <alias name='ide0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='network'>
      <mac address='94:de:80:a4:4b:39'/>
      <source network='default'/>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <input type='tablet' bus='usb'>
      <alias name='input0'/>
    </input>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='5900' autoport='no' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </hostdev>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </memballoon>
  </devices>
</domain>

========================

4-(12). cat /var/log/libvirt/qemu/windows7_test999.log

# cat /var/log/libvirt/qemu/windows7_test999.log

2016-09-06 09:21:38.826+0000: starting up                                          
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin QEMU_AUDIO_DRV=none /usr/bin/kvm -name windows7_test999 -S -machine pc-i440fx-2.1,accel=kvm,usb=off -m 3815 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid a2366bca-b992-4b02-b6ab-c6b2e8198362 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/windows7_test999.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot order=dc,menu=on,strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/data/iso/win7.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -drive file=/data/iso/virtio-win-0.1.118.iso,if=none,id=drive-ide0-1-1,readonly=on,format=raw -device ide-cd,bus=ide.1,unit=1,drive=drive-ide0-1-1,id=ide0-1-1 -drive file=/root/virsh/win7.qcow2,if=none,id=drive-virtio-disk0,format=qcow2,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0 -netdev tap,fd=24,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=94:de:80:a4:4b:39,bus=pci.0,addr=0x3 -device usb-tablet,id=input0 -vnc 0.0.0.0:0 -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device vfio-pci,host=01:00.0,id=hostdev0,bus=pci.0,addr=0x6 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 -msg timestamp=onDomain id=2 is tainted: high-privileges