I can't confirm for sure right now, but just to be sure, have you set "kvm hidden" and "vendor id"? Those are necessary for NVIDIA cards to init on KVM, and I have a mini-guide here if you don't have those.PortalPlayer wrote: ↑Sat Jul 29, 2023 12:16 am 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.
How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM
Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM
-
- Posts: 2
- Joined: Sat Jul 29, 2023 12:09 am
Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM
I have both, but it still doesn't work. Still a black screen. I know the VM is working, since I hear audio, but that's pretty much it.MattKC wrote: ↑Tue Aug 01, 2023 5:21 am I can't confirm for sure right now, but just to be sure, have you set "kvm hidden" and "vendor id"? Those are necessary for NVIDIA cards to init on KVM, and I have a mini-guide here if you don't have those.
EDIT: Fixed it. I had to pass a patched ROM over. Despite not needing one on other VMs, I guess it was required here.
To get your GPU BIOS on Linux, you'll need to run this as root:
Code: Select all
echo 1 > /sys/bus/pci/devices/0000:01:00.0/rom
cat /sys/bus/pci/devices/0000:01:00.0/rom > path/to/dump/vbios.rom
echo 0 > /sys/bus/pci/devices/0000:01:00.0/rom
Note that the Linux method didn't work for me, but the Windows method did. Try the Windows method if this didn't work.
You can also extract it using GPU-Z on Windows.
Then, open it inside of a hex editor, and search for the string "VIDEO". Look a couple bytes back until you find the hex values "0x55 0xAA". Delete everything before those bytes, so the file starts with those two hex values. Don't worry, you're not going to break your GPU doing this, none of these changes are being made to it. Save the patched ROM to a location (I saved mine to /etc/nvidia.rom).
Finally, edit your VM XML, and add
Code: Select all
<rom file="/etc/nvidia.rom"/>
It should work now.
I'm not that good at explaining stuff, so if this doesn't actually work for you, then you can look up another guide on Google.
Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM
The Linux method won't work either way because (during boot) the kernel ends up modifying the shadow VBIOS that is resident in memory (to enable kernel modesetting, etc), and ultimately that's what you end up dumping from sysfs. It's a known "issue" that the NVIDIA Windows driver doesn't play well with the Linux-modified vbios, hence the fix being to dump it directly from the card's ROM using custom tools (either NVIDIA's own flash tool, or GPU-Z).PortalPlayer wrote: ↑Tue Aug 01, 2023 12:37 pm Note that the Linux method didn't work for me, but the Windows method did. Try the Windows method if this didn't work.
It's does help to use a copy of VBIOS by default though, you'll get a lot more consistency with QEMU's behavior.
Last edited by foxlet on Thu Aug 03, 2023 12:50 am, edited 1 time in total.
Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM
To add extra context, the reason why "x-vga" is needed is because it enables support for the Linux VGA arbitrator. Since legacy VGA calls (used to initialize the card) are still handled by writing to a fixed address (one decided back in the ISA days), the only way for the host and guest to share low-level VGA access is through the arbitrator. UEFI Class 3 hardware, on the other hand, use protected-mode drivers that don't require legacy VGA servicesMattKC wrote: ↑Sat Feb 04, 2023 9:12 pm 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.

Last edited by foxlet on Wed Aug 16, 2023 4:50 am, edited 1 time in total.
Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM
Just for fun... I've managed to get early Vista previews (and Longhorn) working in QEMU through the right combination of hardware. This card is just about old enough that the NVIDIA drivers don't have any "Code 43" VM protection lol
- acidiclight
- Posts: 88
- Joined: Tue Dec 27, 2022 10:53 pm
- Location: MeteoTech Premises
- Contact:
Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM
Hmmmm. I haven't read the full post yet since it's a lot of text but I'm very intrigued. I used to have a Windows 7 VM with full GPU passthrough working with an RTX 2060, but at the time I was also doing Single-GPU passthrough and needed to pass through USB controllers as well (so I could have keyboard/mouse support). Could never get it working though because my motherboard's chipset is too new for Win7 and thus it had no idea how to talk to any USB device I plugged in.
(I'm aware you can directly pass in USB devices instead of their controllers, and this is ultimately what I did, however it breaks hot-swap support which is fundamentally incompatible with things like external HDDs and thumbdrives.)
What I'm curious about now is how to get 8/8.1 working. Tried a few days ago, and it does natively support UEFI obviously....however I could NOT get nvidia drivers to install at all. I ended up giving up and upgrading the VM to Windows 10.
(I'm aware you can directly pass in USB devices instead of their controllers, and this is ultimately what I did, however it breaks hot-swap support which is fundamentally incompatible with things like external HDDs and thumbdrives.)
What I'm curious about now is how to get 8/8.1 working. Tried a few days ago, and it does natively support UEFI obviously....however I could NOT get nvidia drivers to install at all. I ended up giving up and upgrading the VM to Windows 10.
Re: How I set up Windows 7 (or Vista) GPU passthrough with libvirt/QEMU/KVM
I managed to get Windows 8.1 working with no real trouble, though I was using an AMD GPU which are obviously much less hostile to KVM than NVIDIA GPUs are. If you didn't before, definitely try the "kvm hidden" and "vendor ID" patches, those tend to get NVIDIA cards cooperating, though someone here had to load a custom VBIOS to make it work.acidiclight wrote: ↑Wed Aug 09, 2023 8:53 pm What I'm curious about now is how to get 8/8.1 working. Tried a few days ago, and it does natively support UEFI obviously....however I could NOT get nvidia drivers to install at all. I ended up giving up and upgrading the VM to Windows 10.