How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Creating ultra fast virtual machines of old operating systems for fun and profit
User avatar
MattKC
Site Admin
Posts: 323
Joined: Mon Aug 22, 2022 1:05 am
Contact:

How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by MattKC »

After spending quite some time trying to work it out, I've finally made a Windows 7 VM that runs at near native performance with full hardware acceleration using a passed through GPU!

The information surrounding this is very scattered, and sometimes even completely false, so I thought I'd collect my experience here. I assume you're at least somewhat familiar with GPU passthrough and how to set one up, so I'll be skipping the basics and cutting right to the main challenges of Windows 7.

The Problem

Windows 7 is tough for GPU passthrough because the most widely supported path is having the guest boot through UEFI. Specifically, OVMF, the implementation most commonly used with QEMU. UEFI was the firmware standard that finally dethroned the IBM PC BIOS' decades-long reign, however that dethroning happened some time between Windows 7 and Windows 8, and as such, 7 only supports it partially.

I won't pretend to fully understand this myself, but essentially even though Windows 7 can boot in UEFI mode, it relies on some legacy BIOS interrupt(s) for graphics initialization that are not provided in pure UEFI. UEFI has an optional feature called CSM (Compatibility Support Module) that provides those interrupts (along with a general BIOS implementation), but CSM is slowly being phased out since modern OSes no longer need it.

There is a version of OVMF with CSM, and Windows 7 can be installed with it, however this variant appears to have poor support for PCI-e passthrough. OVMF with pure EFI has much better support, but doesn't have the interrupts Windows 7 requires to boot.

Well why use UEFI at all when Windows 7 doesn't even fully support it? Well, there are very mixed opinions on whether passthrough is possible with SeaBIOS (QEMU's default BIOS implementation) or not. There's a lot of posts saying it's significantly more difficult, that there are strict limitations like your host must also be booted in BIOS mode, and various other posts discouraging its use.

Seemingly what we really need is a way for Windows 7 to play nice with pure UEFI, but this is easier said than done...

What I Tried

There are a surprising amount of people that are trying to boot Windows 7 on UEFI, usually to try getting it to run on more modern hardware. Windows 7 really had staying power, didn't it?

What will most likely happen if you try to boot Windows 7 on pure UEFI is it'll crash at "Starting Windows". Normally, Windows 7 will display "Starting Windows", and then 4 colored orbs will animate to form the Windows flag. However, I guess somewhere before that happens (or maybe as part of it), that BIOS interrupt is called, and because it isn't present, Windows will either hang or immediately reboot.

I thought it might be helpful to work with an existing installation rather than the installer, so using the CSM variant of OVMF, I installed Windows 7 normally with a regular virtualized GPU (QXL). This went smoothly, and I soon had a functional install. It was very tempting to try passing through the GPU right now, but it didn't work. With both GPUs connected (real and QXL), UEFI would render to the card, but Windows would not. It would see the card in Device Manager, and it lets you install drivers, but then tells you the card couldn't start due to "Code 12" or "This device cannot find enough free resources to use." Depending on who you talk to, this might be because Windows 7 is too picky to have both a virtual GPU and a real GPU at the same time, or because you need to be more careful about PCI port assignment or something? Unfortunately, disabling the virtual GPU didn't help either - it simply refused to display any image at all, even the UEFI now for some reason.

UefiSeven is a pre-loader for Windows 7's UEFI that installs the missing interrupt so Windows can use it as necessary. In theory, this sounds like the perfect solution, but for some reason I could never get it to work, it would still freeze or crash at "Starting Windows". There seem to be a lot of GitHub issues saying the same thing, so perhaps it only works on some hardware configurations (or it's a completely separate compatibility issue that happens to have a very similar presentation?)

FlashBoot Pro - another pre-loader of sorts that claims to patch the Windows 7 loader to function correctly on pure UEFI. I never actually tried this because the version that does this is paid, but I bring it up because their developers wrote some interesting information about why the freeze on "Starting Windows" may occur. They say it's actually a BSOD that can't display properly because it's unable to switch to 640x480x16 mode due to the lack of CSM/BIOS. This actually checks out with my experience, because I noticed the VM would itself would "pause", indicating that the CPU had actually completely halted.

Patched OVMF for Windows 7 - I believe an alternative to UefiSeven that patches something directly in the firmware rather than at runtime in software. Unfortunately, this too didn't seem to help, either with or without UefiSeven installed, it would exhibit some kind of unusual behavior where instead of hanging or crashing at "Starting Windows", it would switch immediately to a progress bar saying "Windows is loading files..." (the same one you get when booting the Windows 7 installer or repair partition). It would load for a few seconds, and then crash.

Claims that it would work if I ensured it was PCI-e instead of PCI - I'm not super sure about this one, but I read some claims that the PCI-e devices are passed through by default behind a "PCI-e to PCI bridge", and that's what led to the aforementioned Code 12 issue. I have no idea if that's true, but their assertion was if you forced it to be PCI-e (which can only be done with QEMU command line rather than libvirt), it would work. Unfortunately this didn't help me, I tried adding the GPU with QEMU command line, but it showed permission denied errors that I couldn't figure out how to solve (even chmod-ing the device to 777 didn't work). I have no idea about the validity of this claim or the supposed solution, so take this with a grain of salt.

Native supported added in KB5017361? - Allegedly some time late 2022, Microsoft added native support for UEFI in Windows 7, supposedly rendering UefiSeven obsolete. Official support would definitely be preferable over "hacks", but the only evidence that this actually happened seems to be a single tweet, it's never been mentioned in any official statement/capacity, and even the tweet makes some mention of workarounds still being required for graphics. Regardless, I installed the update (and all of the updates leading up to it), but experienced no change.

What Worked (For Me)

At first, SeaBIOS + passthrough doesn't appear to work at all, which seemed to reinforce all the people who claimed it was problematic. My passed through GPU displayed no image whatsoever. Regardless, after all the frustration I had with UEFI, the handful of people saying SeaBIOS worked fine for them made me want to try it myself again.

It turns out there was one thing I was missing when trying to passthrough with SeaBIOS. You have to enable x-vga. For some reason I'd never come across this before, but this was the magic flag that made my GPU get picked up by the BIOS and subsequently Windows 7.

As aforementioned, I've read that Windows 7 is too picky for both a real and virtual GPU to be connected, and this does seem to be somewhat correct. At least, when I have both connected, the real GPU gives me "Code 12" for lack of resources again. But with just the real GPU connected (and drivers installed of course), I get perfect fully GPU accelerated Windows 7, in all of its Aero glory.

So once again assuming you have some knowledge of virt-manager/GPU passthrough already (if not, you probably want to use this guide to start from scratch), here's how I got a Windows 7 VM to work:
  1. Create a virtual machine with virt-manager - there's an existing preset for "win7", from this it should automatically create a Q35 chipset with SeaBIOS which is what you want.
  2. Check "Customize hardware before install" before finishing the wizard so we can make some changes.
  3. virt-manager will have made a Display and Video device. To avoid "Code 12" (insufficient resources), you'll need to remove the virtualized GPU by setting the Video device to "None". Alternatively you can remove the Display and Video devices altogether. This can be done at any time, so if you'd prefer to do installation with a vGPU and switch to a real one later, go for it.
  4. Add your GPU as a PCI Host Device as normal.
  5. Enable x-vga. This is a QEMU-specific thing, so to do this in virt-manager, you'll want to add some custom QEMU args to the XML:
    1. Replace the top line with this to allow QEMU command line extensions:

      Code: Select all

      <domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0" type="kvm">
      
    2. Add the following lines to the end of the file after "</devices>" but before "</domain>":

      Code: Select all

      <qemu:override>
        <qemu:device alias="hostdev0">
          <qemu:frontend>
            <qemu:property name="x-vga" type="bool" value="true"/>
          </qemu:frontend>
        </qemu:device>
      </qemu:override>
      
  6. That's it! If everything went well, you should now get SeaBIOS running through your GPU. From here, you can proceed to installing and running Windows 7, and finally installing the GPU drivers. For reference, the GPU I passed through was an AMD RX 570, which has native support for Windows 7. If your GPU is too new to have drivers for 7, it will still "work", but without any hardware acceleration, which kind of defeats the purpose of passing through a real GPU to begin with.

    I've also heard that NVIDIA cards try to detect if they're being passed through and disable themselves if so (in order to upsell you to their more expensive "enterprise" cards that support it officially). To bypass this, you'll need to configure your VM to hide the fact that it's a VM. There are ways to do this, but it's out of scope for this guide. As always, Google is your friend.
I hope this was helpful, and happy VMing arthurDance
User avatar
damy
Posts: 16
Joined: Sun Jan 01, 2023 9:10 pm
Location: EU

Re: How I set up Windows 7 GPU passthrough with libvirt/QEMU/KVM

Post by damy »

Pretty cool guide(?)
I think I have heard about this error code 12 but in a egpu context. Not sure if it helps or not, but on egpu.io there are a few threads about this error and how to fix it iirc
Image
User avatar
MattKC
Site Admin
Posts: 323
Joined: Mon Aug 22, 2022 1:05 am
Contact:

Re: How I set up Windows 7 GPU passthrough with libvirt/QEMU/KVM

Post by MattKC »

Just tested and this also works with Windows Vista, provided you have a GPU that supports it. A lot of newer GPUs/drivers only go as far back as 7. On Vista, I had success with an ATI Radeon HD 3870 from 2007.
gregory003
Posts: 3
Joined: Fri Mar 17, 2023 6:50 pm

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by gregory003 »

Hi. I'm trying you guide but stuck at error code 12 in Win7 at bios. Sadly GPU not given any output, even after disabling qlx or removing entire spicevm from vm. Interesting thing, my GPU works fine with both windows 10 with UEFI on newer machine and real Windows 7 in BIOS mode on older one (Core 2 Duo).
Could you maybe post your xml file and information on which Linux distro you accomplish Windows 7 GPU passthrough? I.e. on my Ubuntu I had qemu-system-something package instead of qemu-kvm, and not know if it is the same.
User avatar
MattKC
Site Admin
Posts: 323
Joined: Mon Aug 22, 2022 1:05 am
Contact:

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by MattKC »

gregory003 wrote: Sat Mar 18, 2023 3:58 pm Hi. I'm trying you guide but stuck at error code 12 in Win7 at bios. Sadly GPU not given any output, even after disabling qlx or removing entire spicevm from vm. Interesting thing, my GPU works fine with both windows 10 with UEFI on newer machine and real Windows 7 in BIOS mode on older one (Core 2 Duo).
Could you maybe post your xml file and information on which Linux distro you accomplish Windows 7 GPU passthrough? I.e. on my Ubuntu I had qemu-system-something package instead of qemu-kvm, and not know if it is the same.
Are you sure you enabled x-vga? You won't get any GPU output on BIOS without it.
gregory003
Posts: 3
Joined: Fri Mar 17, 2023 6:50 pm

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by gregory003 »

It's XML from my config:

Code: Select all

<domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0" type="kvm">
  <name>win7</name>
  <uuid>7a56fa7a-2ba8-4dbe-a989-ded20bf14654</uuid>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://microsoft.com/win/7"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory unit="KiB">4194304</memory>
  <currentMemory unit="KiB">4194304</currentMemory>
  <vcpu placement="static">4</vcpu>
  <os>
    <type arch="x86_64" machine="pc-q35-6.2">hvm</type>
    <bootmenu enable="yes"/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv mode="custom">
      <relaxed state="on"/>
      <vapic state="on"/>
      <spinlocks state="on" retries="8191"/>
      <vendor_id state="on" value="randomid"/>
    </hyperv>
    <kvm>
      <hidden state="on"/>
    </kvm>
    <vmport state="off"/>
    <ioapic driver="kvm"/>
  </features>
  <cpu mode="host-passthrough" check="none" migratable="on"/>
  <clock offset="localtime">
    <timer name="rtc" tickpolicy="catchup"/>
    <timer name="pit" tickpolicy="delay"/>
    <timer name="hpet" present="no"/>
    <timer name="hypervclock" present="yes"/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled="no"/>
    <suspend-to-disk enabled="no"/>
  </pm>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type="file" device="disk">
      <driver name="qemu" type="qcow2" discard="unmap"/>
      <source file="/var/lib/libvirt/images/win7.qcow2"/>
      <target dev="sda" bus="sata"/>
      <boot order="2"/>
      <address type="drive" controller="0" bus="0" target="0" unit="0"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <target dev="sdb" bus="sata"/>
      <readonly/>
      <boot order="1"/>
      <address type="drive" controller="0" bus="0" target="0" unit="1"/>
    </disk>
    <controller type="usb" index="0" model="ich9-ehci1">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1d" function="0x7"/>
    </controller>
    <controller type="usb" index="0" model="ich9-uhci1">
      <master startport="0"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1d" function="0x0" multifunction="on"/>
    </controller>
    <controller type="usb" index="0" model="ich9-uhci2">
      <master startport="2"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1d" function="0x1"/>
    </controller>
    <controller type="usb" index="0" model="ich9-uhci3">
      <master startport="4"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1d" function="0x2"/>
    </controller>
    <controller type="pci" index="0" model="pcie-root"/>
    <controller type="pci" index="1" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="1" port="0x8"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0" multifunction="on"/>
    </controller>
    <controller type="pci" index="2" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="2" port="0x9"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
    </controller>
    <controller type="pci" index="3" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="3" port="0xa"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x2"/>
    </controller>
    <controller type="pci" index="4" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="4" port="0xb"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x3"/>
    </controller>
    <controller type="pci" index="5" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="5" port="0xc"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x4"/>
    </controller>
    <controller type="pci" index="6" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="6" port="0xd"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x5"/>
    </controller>
    <controller type="pci" index="7" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="7" port="0xe"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x6"/>
    </controller>
    <controller type="pci" index="8" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="8" port="0xf"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x7"/>
    </controller>
    <controller type="pci" index="9" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="9" port="0x10"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0" multifunction="on"/>
    </controller>
    <controller type="pci" index="10" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="10" port="0x11"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x1"/>
    </controller>
    <controller type="pci" index="11" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="11" port="0x12"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x2"/>
    </controller>
    <controller type="pci" index="12" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="12" port="0x13"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x3"/>
    </controller>
    <controller type="pci" index="13" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="13" port="0x14"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x4"/>
    </controller>
    <controller type="pci" index="14" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="14" port="0x15"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x5"/>
    </controller>
    <controller type="sata" index="0">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1f" function="0x2"/>
    </controller>
    <controller type="virtio-serial" index="0">
      <address type="pci" domain="0x0000" bus="0x02" slot="0x00" function="0x0"/>
    </controller>
    <interface type="network">
      <mac address="52:54:00:68:51:96"/>
      <source network="default"/>
      <model type="e1000e"/>
      <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
    </interface>
    <input type="mouse" bus="ps2"/>
    <input type="keyboard" bus="ps2"/>
    <input type="evdev">
      <source dev="/dev/input/by-id/usb-Telink_Wireless_Receiver-event-mouse"/>
    </input>
    <input type="evdev">
      <source dev="/dev/input/by-id/usb-SIGMACHIP_USB_Keyboard-event-kbd" grab="all" grabToggle="ctrl-ctrl" repeat="on"/>
    </input>
    <audio id="1" type="none"/>
    <hostdev mode="subsystem" type="pci" managed="yes">
      <source>
        <address domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
      </source>
      <address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0" multifunction="on"/>
    </hostdev>
    <hostdev mode="subsystem" type="pci" managed="yes">
      <source>
        <address domain="0x0000" bus="0x01" slot="0x00" function="0x1"/>
      </source>
      <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/>
    </hostdev>
    <memballoon model="virtio">
      <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
    </memballoon>
  </devices>
  <qemu:override>
    <qemu:device alias="hostdev0">
      <qemu:frontend>
        <qemu:property name="x-vga" type="bool" value="true"/>
      </qemu:frontend>
    </qemu:device>
  </qemu:override>
</domain>
User avatar
MattKC
Site Admin
Posts: 323
Joined: Mon Aug 22, 2022 1:05 am
Contact:

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by MattKC »

Your XML file works for me, so it would seem to be something specific to your setup/hardware. I notice you passed through two devices (presumably one for the GPU and one for the GPU's audio device); try only passing through the main GPU in case the x-vga arg referring to "hostdev0" is linking to the wrong device.
gregory003
Posts: 3
Joined: Fri Mar 17, 2023 6:50 pm

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by gregory003 »

Meh, half weekend I was tryed to configure correct setup, but give up. I realized that could buying pretty good older hardware for few bucks (sometimes even for free), so it isn't even worth the effort.
User avatar
CallyHam
Posts: 6
Joined: Tue Jun 13, 2023 1:42 am

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by CallyHam »

Hello, i've attempted this and of course followed the necessary steps, i get output from my gpu but output is locked at 640x480 resolution, the colors seem to be 4-bit, its overall quite choppy and my usb controller doesn't work ( it is 3.0 so i assume that's got something to do with it)
i've tried installing, setting up and updating windows first then passing my gpu later but i get the same issues, my gpu is an RX 480 8GB, i tried windows vista and 7 but both have all the same issues, i've attached an image and also my xml in hopes i can get this working, thanks in advance to whoever answers!
EDIT: also is there some kind of discord i can join for easier help? i'm not very good with forums lol
EDIT 2: just remembered it would probably be useful to mention im doing single gpu
vista.xml
(7.74 KiB) Downloaded 654 times
vista.xml
(7.74 KiB) Downloaded 654 times
Attachments
what.png
Image
User avatar
MattKC
Site Admin
Posts: 323
Joined: Mon Aug 22, 2022 1:05 am
Contact:

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by MattKC »

CallyHam wrote: Tue Jun 13, 2023 1:50 am Hello, i've attempted this and of course followed the necessary steps, i get output from my gpu but output is locked at 640x480 resolution, the colors seem to be 4-bit, its overall quite choppy and my usb controller doesn't work ( it is 3.0 so i assume that's got something to do with it)
I'm curious about this line:

Code: Select all

<rom bar="on" file="/var/lib/libvirt/vgabios/vbios.rom"/>
Did you add that? I don't have that on my system, try removing it and see if it helps.
User avatar
CallyHam
Posts: 6
Joined: Tue Jun 13, 2023 1:42 am

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by CallyHam »

oh yeah thats just the gpu rom file, i added it to see if the rom file would help but adding or removing it made no difference for me unfortunately
edit: just double checked after removing and yeah no difference
Image
User avatar
MattKC
Site Admin
Posts: 323
Joined: Mon Aug 22, 2022 1:05 am
Contact:

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by MattKC »

Hmm I can't see anything else that would cause that.
  • Have you tried the general troubleshooting stuff like firmware updates for your GPU?
  • Are you able to passthrough fine on any other guest OSes (like Windows 10, macOS, Linux, etc.)? Or are these the only passthrough OSes youve tried?
  • I assume you've installed the AMD drivers on Windows 7, do you get an error message in Windows' device manager? (it should be noted that the RX 480 has no drivers on Vista so that's probably a dead end)
User avatar
CallyHam
Posts: 6
Joined: Tue Jun 13, 2023 1:42 am

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by CallyHam »

i haven't tried a firmware update on my gpu, i believe that involves flashing so i'll have to figure that out at some point
i have had success passing through with drivers on windows 10 and 11, haven't attempted macos or any linux distros just yet
on windows 7 i attempted to install amd drivers through vnc but it would always get stuck at some point, as for vista today i did manage to find someone who seemingly ported drivers for the rx 480 to vista with extended kernel so if i can even get to the desktop i'll try those, i just first need to atleast have mouse and keyboard input in the guest before i can really have a good try at installing drivers

i would definitely prefer if i could get vista working but if it comes down to it 7 is fine too

heres where i found those vista drivers in case you wanna take a look: https://msfn.org/board/topic/184042-amd ... ows-vista/
there also was a comment of someone saying it worked on their rx 480 so it could work for me
Image
User avatar
CallyHam
Posts: 6
Joined: Tue Jun 13, 2023 1:42 am

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by CallyHam »

for the basic gpu passthrough setup i used this guide: https://gitlab.com/risingprismtv/single ... wikis/home
then added your extra xml lines to mine along with passing in my gpu, usb and audio controller and i of course used bios instead of any of the ovmf options\
i didn't think i'd have a much different experience considering you used an rx 570, are there any other configs i can share that may give some clues as to whats wrong?
are there maybe any bios settings i need to enable?
EDIT: i also tried windows 7 again and all the same issues appeared
UPDATE: colors and resolution are back to normal now! i disabled above 4g decoding in my bios and thats fixed now, no mouse and keyboard input yet, usb 3.0 is probably the issue there but progress!
vistacolors.jpg
Image
User avatar
MattKC
Site Admin
Posts: 323
Joined: Mon Aug 22, 2022 1:05 am
Contact:

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by MattKC »

CallyHam wrote: Tue Jun 13, 2023 5:09 am UPDATE: colors and resolution are back to normal now! i disabled above 4g decoding in my bios and thats fixed now
Ahh nice, glad you got the visuals working.

As for USB 3.0, I'm fairly certain the issue is that neither Windows Vista/7 natively support USB 3. I believe there are drivers for it, but you should be able to passthrough your keyboard and mouse through other means that don't require the guest to support USB 3, such as evdev passthrough or adding them as a "USB host device".
User avatar
CallyHam
Posts: 6
Joined: Tue Jun 13, 2023 1:42 am

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by CallyHam »

yeah i gathered vista/7 wouldnt support usb 3 out of the box, i've attempted adding my m/kb as usb host devices but had no luck with that either, i don't know what evdev passthrough is or how to use it but ill have to figure that out

UPDATE: Finally got to the desktop, i had to use vnc on my phone for just the input, i painfully installed usb 3.0 drivers and am now running a functional vista desktop, all thats left is the extended kernel and drivers
VistaDesktop.jpg
Image
User avatar
CallyHam
Posts: 6
Joined: Tue Jun 13, 2023 1:42 am

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by CallyHam »

Final Update!!! Finally achieved full aero and gpu acceleration.
had some issues and got help with them by the creator on discord, quick recap of everything i had to do to get this working:
• Disable "Above 4G Decoding" in my bios to fix the 4-bit color issues
• Temporarily add a VNC to the vm for input since my USB 3.0 Host Controller had no drivers by default and adding a USB Host Device wouldn't work
• Install specifically the October 2022 version of the vista extended kernel (https://archive.org/details/extended-ke ... dows-vista)
• Install custom ported AMD drivers by following the "READ ME!!!!.txt" from this driverpack (https://msfn.org/board/topic/184042-amd ... ows-vista/)
• Finally, enjoy that long awaited aero transparency!

Thank you for the assistance i probably would've gave up without it baldiDance
GPUACCELERATIONONVISTA.jpg
Last edited by CallyHam on Wed Jun 14, 2023 2:39 am, edited 2 times in total.
Image
User avatar
MattKC
Site Admin
Posts: 323
Joined: Mon Aug 22, 2022 1:05 am
Contact:

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by MattKC »

Awesome, that looks great! So glad you were able to get it all figured out :D
MrLeRien
Posts: 1
Joined: Sat Jun 24, 2023 7:31 pm

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by MrLeRien »

Signed up on the forum to say that i've managed to get the vista gpu passthrough working too!
Now i can enjoy windows vista with glorious ultrawide and.. forget why i've installed it in the first place lmao

On the subject of windows 7, i did manage a while back to get GPU passthrough working using UEFI booting.
To be honest i always thought you could never passthrough using SeaBIOS, so i did a LOT of trial and error with UEFI until i found a way to get it working.
I've used the OVMF fork you mentionned on your post, but specifically using the i440fx chipset with both the NVIDIA and QXL GPUs added to the libvirt config.
You CANNOT boot win7 via OVMF if you don't have a QXL gpu attached or use Q35. otherwise it would do a black screen after a few seconds and crash (which i believe was your problem when you were using it)
On the NVIDIA GPU side you would see the "Starting Windows" boot screen, completely hanged. You'd think that windows crashed but the setup screen would apprear on the QXL side! Maybe this is the microsoft basic driver somehow having a problem initialising the GPU?
After that, you could install windows 7 and once arrived on the desktop install the nvidia driver. With a couple of KVM hiding tricks to get around the Code 43 error, everything would magically work! the QXL gpu still HAS to stay in the VM config for windows to boot for some reason, but you could disable the GPU in device manager and it still would work fine.

I wish i still had the XML for the VM to show but i've reinstalled arch linux so i don't have it anymore :/
sucks that i didn't know about the x-vga trick for SeaBIOS tho, that would've saved me 2 sleepness nights :(

anyways thanks for the tutorial!
Attachments
why.png
User avatar
PortalPlayer
Posts: 9
Joined: Sat Jul 29, 2023 12:09 am

Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM

Post by PortalPlayer »

Can anyone with an Nvidia GPU confirm if this guide works? I have one, and it didn't work for me, and it seems like that's probably why it also didn't work for gregory003.

EDIT: For more information, it just stays on a black screen, but I can hear audio via the passthrough audio.
UEFI virtual machines work for me, and I do have x-vga enabled, so it's probably something to do with Nvidia.
Post Reply