HOW-TO make dual-boot obsolete using kvm VGA passthrough

Questions about virtualization software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

I made some updates to my tutorial and added instructions to run the Windows VM in user mode, that is as non-root user.
See: https://heiko-sieger.info/running-windo ... e_non-root

It seems rather trivial now with Linux Mint 19. Obviously Ubuntu (and perhaps Linux Mint) have worked hard to better integrate qemu/kvm into the distribution. There seem to be no permission issues, as far as I can see. Please let me know if you tried it and it worked / didn't work.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

I added a new tutorial for Installing a Linux Mint 19 (Ubuntu 18.04) VM with VGA Passthrough , as well as a post arguing in favor of a Linux Virtual Gaming Machine.

Once you installed Windows as a virtual machine with VGA passthrough, it's easy to create a Linux VM that can use the same graphics card you use for your Windows VM (of course, not while Windows is running!).

This should even further help migrate from Windows to Linux.

The nice thing is that I can experiment with the Linux gaming VM all the while my host system stays untouched and untainted by wine etc.

If you follow my tutorial, add the

Code: Select all

runas=<username> \
beneath the qemu... command to run the Linux VM in unprivileged mode. (<username> must first be added to the groups kvm and perhaps libvirt before this works.)
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
driz

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by driz »

hey all, been a while since I've posted, but today I built a new system for my parents. They needed two work stations and were about to buy a laptop. I ended up building them a system (very similar to my girls') for about 500$. Everything was going perfect, but I couldn't get the windows iso to boot and had never encountered this issue before. I came back here to discuss it and found you have a new blog @powerhouse, i ran through it and you had the exact solution. I was lazy and just rsynced my ovmf stuff over to their system, i read https://heiko-sieger.info/running-windo ... ont_boot_2 and this fixed it perfectly.

as usual, thanks for your efforts!
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

driz wrote: Sun Sep 02, 2018 7:46 pm hey all, been a while since I've posted, but today I built a new system for my parents. They needed two work stations and were about to buy a laptop. I ended up building them a system (very similar to my girls') for about 500$. Everything was going perfect, but I couldn't get the windows iso to boot and had never encountered this issue before. I came back here to discuss it and found you have a new blog @powerhouse, i ran through it and you had the exact solution. I was lazy and just rsynced my ovmf stuff over to their system, i read https://heiko-sieger.info/running-windo ... ont_boot_2 and this fixed it perfectly.

as usual, thanks for your efforts!
That's good news! I'm glad my website remains useful. How are the girls getting along with their virtual Windows PCs?
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
driz

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by driz »

powerhouse wrote: Mon Sep 03, 2018 5:21 pm That's good news! I'm glad my website remains useful. How are the girls getting along with their virtual Windows PCs?
Still running great! I keep trying to think of things to beef it up, but until they get into better games, it's just perfect man. I do wish everything could be put to sleep, but we can't have it all :D
mint_user1234

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by mint_user1234 »

Can someone help me?
I am having Problem isolating the GPU. I tried
viewtopic.php?f=231&t=212692&start=40#p1173262
https://pastebin.com/WSmrFtpL
and the one from Archwiki.

but it does not work:

dmesg | grep -i vfio
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.15.0-20-generic root=UUID=ad7ad043-8c9e-4133-b8f1-64807ba4546f ro iommu=1 amd_iommu=on rd.driver.pre=vfio-pci quiet splash vt.handoff=1
[ 0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.15.0-20-generic root=UUID=ad7ad043-8c9e-4133-b8f1-64807ba4546f ro iommu=1 amd_iommu=on rd.driver.pre=vfio-pci quiet splash vt.handoff=1

lspci:

07:00.0 VGA compatible controller [0300]: NVIDIA Corporation GM206 [GeForce GTX 960] [10de:1401] (rev a1)
Subsystem: Micro-Star International Co., Ltd. [MSI] GM206 [GeForce GTX 960] [1462:3205]
Kernel driver in use: nouveau

What am I doing wrong? :/



I think my GPU does not support UEFI:

sudo ./rom-parser /tmp/image.rom
Valid ROM signature found @0h, PCIR offset 1a0h
PCIR: type 0 (x86 PC-AT), vendor: 10de, device: 1401, class: 030000
PCIR: revision 0, vendor revision: 1
Valid ROM signature found @e400h, PCIR offset 77ddh
Speicherzugriffsfehler

Do I need to flash the GPU-BIOS? The Isolation should work despite this, right?
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

mint_user1234 wrote: Wed Sep 19, 2018 4:23 pm Can someone help me?
I am having Problem isolating the GPU. I tried
viewtopic.php?f=231&t=212692&start=40#p1173262
https://pastebin.com/WSmrFtpL
and the one from Archwiki.

but it does not work:

dmesg | grep -i vfio
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.15.0-20-generic root=UUID=ad7ad043-8c9e-4133-b8f1-64807ba4546f ro iommu=1 amd_iommu=on rd.driver.pre=vfio-pci quiet splash vt.handoff=1
[ 0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.15.0-20-generic root=UUID=ad7ad043-8c9e-4133-b8f1-64807ba4546f ro iommu=1 amd_iommu=on rd.driver.pre=vfio-pci quiet splash vt.handoff=1

lspci:

07:00.0 VGA compatible controller [0300]: NVIDIA Corporation GM206 [GeForce GTX 960] [10de:1401] (rev a1)
Subsystem: Micro-Star International Co., Ltd. [MSI] GM206 [GeForce GTX 960] [1462:3205]
Kernel driver in use: nouveau

What am I doing wrong? :/



I think my GPU does not support UEFI:

sudo ./rom-parser /tmp/image.rom
Valid ROM signature found @0h, PCIR offset 1a0h
PCIR: type 0 (x86 PC-AT), vendor: 10de, device: 1401, class: 030000
PCIR: revision 0, vendor revision: 1
Valid ROM signature found @e400h, PCIR offset 77ddh
Speicherzugriffsfehler

Do I need to flash the GPU-BIOS? The Isolation should work despite this, right?
Let me get this right: Do you have 2 identical GPU (2x GTX 960)?

If not, just follow the regular guide here: https://heiko-sieger.info/running-windo ... assthrough.

This tutorial uses UEFI passthrough. Check https://www.techpowerup.com/vgabios/ to see if your card has an UEFI BIOS. Also see my tutorial to check for the current BIOS used in the GPU.

You may find an UEFI BIOS for your card under the above link.

If your card doesn't support UEFI and there is no UEFI BIOS, you can still make it work using Seabios. The differences to my tutorial are relatively minor. However, there are disadvantages to using the Seabios approach.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

I've added a short tutorial for running a Linux VM with VGA passthrough here: viewtopic.php?f=231&t=280540.

If, like me, you use the more powerful GPU for your Windows guest, installing a Linux VM with passthrough allows you to run demanding Linux games with your dedicated gaming GPU. It's real neat.

I also use the Linux VM to test new software or settings.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

I've updated and fixed my tutorial. Note the following changes to the qemu script:

Code: Select all

-usb \
-device usb-host,vendorid=0x045e,productid=0x076c \
-device usb-host,vendorid=0x045e,productid=0x0750 \
-usb enables USB support and -device usb-host… assigns the USB host devices mouse (045e:076c) and keyboard (045e:0750) to the guest. Replace the device IDs with the ones you found using the lsusb command in Part 3 above!
Note the new syntax. There are also many more options that you can find here: file:///usr/share/doc/qemu-system-common/qemu-doc.html.

There are three options to assign host devices to guests. Here the syntax:

Code: Select all

-usb \
-device usb-kbd \
-device usb-mouse \
passes through the keyboard and mouse to the VM. When using this option, remove the -vga none and -nographic options from the script to enable switching back and forth between Windows VM and Linux host using CTRL+ALT.

Code: Select all

-usb \
-device usb-host,hostbus=bus,hostaddr=addr \
passes through the host device identified by bus and addr.

-

Code: Select all

usb \
-device usb-host,vendorid=vendor,productid=product \
passes through the host device identified by vendor and product ID.

Please let me know how it works.

I've also written a post on SSD/HDD drive performance tuning. See the new Qemu drive options here: Tuning VM Disk Performance.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

I made some important updates to my tutorial. Again and again users reported that they get a black screen when the Windows VM boots. This seems to be a common issue with the new Ryzen low and midrange boards. It also happens when you try to pass through the primary graphics card (the one used by the host).

It has to do with the system creating a shadow BIOS of the GPU you want to pass through, and handing that shadow BIOS to the VM. Unfortunately the shadow BIOS is not a 1:1 copy of the original BIOS, so the guest cannot boot with it. The solution is either to prevent the system from initializing the passthrough GPU at host boot. Or to return the passthrough CPU to its "virgin" state by booting the guest with the original BIOS using the romfile=/path/to/GPU_BIOS.dump option.

How to dump the GPU BIOS into a file and then load it via the VM start script is described here: https://heiko-sieger.info/running-windo ... assthrough.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
Gebonimo

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by Gebonimo »

I'm having problem. The Win10.iso is not detected by your script.

I've change this line in my script

Code: Select all

-drive file=/home/gebo/Documents/vm/win10.iso , index=1, media=cdrom \
and it's says "No bootable device found" and
Boot failed: Could not read from CD ROM (code 0003)
But when i do the

Code: Select all

qemu-system-x86_64 -cdrom /home/gebo/Documents/vm/win10.iso
command, the CD is starting.

What should I change in your script ?

I've search around for the "-driver" part but find nothing helpful.

Thanks.

EDIT : Also, the terminal returns the line
./vm.sh: ligne 23: -smp : commande introuvable
after executing your script.
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

1. You can also use the -cdrom option.
2. Remove the spaces on your -drive ..., ..., line like:

Code: Select all

-drive file=/home/gebo/Documents/vm/win10.iso,index=1,media=cdrom \
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
Gebonimo

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by Gebonimo »

OK thanks I did and it's working fine. I can install W10.

BUt as soon as I try to install my AMD Radeon R9 270X/370 driver I have BSOD. I'm searching on the internet a solution since I've tried you fix.

Thanks dude

EDIT : I was wondering also, how can i make snapshot of my vm using you script ?

Thanks
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

@Gebonima:

By "tried your fix", do you mean https://heiko-sieger.info/running-windo ... er_Windows?

Did you run all the tests prior to running the script? Are your IOMMU groups good?

If your passthrough GPU is in PCIe slot 1, some motherboards may initialize that GPU at boot as primary VGA. In this case, you can either swap the GPUs - put your passthrough GPU in slot 2 and the host GPU in slot 1 - or follow the instructions here: https://heiko-sieger.info/running-windo ... assthrough.

When you run the script, do you see any errors? Also, please post your script (only the qemu... part).

Good luck!

Heiko
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
Gebonimo

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by Gebonimo »

powerhouse wrote: Mon Jan 07, 2019 7:07 am @Gebonima:

By "tried your fix", do you mean https://heiko-sieger.info/running-windo ... er_Windows?

Did you run all the tests prior to running the script? Are your IOMMU groups good?

If your passthrough GPU is in PCIe slot 1, some motherboards may initialize that GPU at boot as primary VGA. In this case, you can either swap the GPUs - put your passthrough GPU in slot 2 and the host GPU in slot 1 - or follow the instructions here: https://heiko-sieger.info/running-windo ... assthrough.

When you run the script, do you see any errors? Also, please post your script (only the qemu... part).

Good luck!

Heiko
@powerhouse

Hi thanks for you answer.

Here is my script :

Code: Select all

qemu-system-x86_64 \
-name $vmname,process=$vmname \
-machine type=pc,accel=kvm \
-cpu host \
-smp 4,sockets=1,cores=2,threads=2 \
-m 8G \
-balloon none \
-rtc clock=host,base=localtime \
-serial none \
-parallel none \
-soundhw hda \
-usb \
-device usb-kbd \
-device usb-mouse \
-device ioh3420,bus=pci.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1 \
-device vfio-pci,host=01:00.0,bus=root.1,addr=00.0,multifunction=on \
-device vfio-pci,host=01:00.1,bus=root.1,addr=00.1 \
-drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd \
-drive if=pflash,format=raw,file=/tmp/my_vars.fd \
-boot order=dc \
-drive file=/home/gebo/Documents/vm/win10.iso,index=1,media=cdrom \
-drive id=disk0,if=virtio,cache=none,format=raw,file=/media/gebo/win10.img \
-netdev type=tap,id=net0,ifname=vmtap0,vhost=on \
-device virtio-net-pci,netdev=net0,mac=00:16:3e:00:01:01
exit 0
fi
I have to mention that I have only one GPU, so it's on the PCI1 slot on my motherboard.

Here are all the results of the checking config

Code: Select all

gebo@gebo-H87-HD3:~$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
gebo@gebo-H87-HD3:~$ lsmod | grep kvm 
kvm_intel             212992  0
kvmgt                  28672  0
mdev                   24576  2 kvmgt,vfio_mdev
vfio                   32768  4 kvmgt,vfio_mdev,vfio_iommu_type1,vfio_pci
kvm                   630784  2 kvmgt,kvm_intel
irqbypass              16384  2 vfio_pci,kvm
gebo@gebo-H87-HD3:~$ lsmod | grep vfio
vfio_pci               49152  0
vfio_virqfd            16384  1 vfio_pci
vfio_mdev              16384  0
mdev                   24576  2 kvmgt,vfio_mdev
vfio_iommu_type1       28672  0
vfio                   32768  4 kvmgt,vfio_mdev,vfio_iommu_type1,vfio_pci
irqbypass              16384  2 vfio_pci,kvm
gebo@gebo-H87-HD3:~$ qemu-system-x86_64 --version
QEMU emulator version 2.11.1(Debian 1:2.11+dfsg-1ubuntu7.9)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
gebo@gebo-H87-HD3:~$ lspci -kn | grep -A 2 01:00
01:00.0 0300: 1002:6810
	Subsystem: 174b:e271
	Kernel driver in use: vfio-pci
--
01:00.1 0403: 1002:aab0
	Subsystem: 174b:aab0
	Kernel driver in use: vfio-pci
gebo@gebo-H87-HD3:~$ dmesg | grep VFIO
[    1.399747] VFIO - User Level meta-driver version: 0.3
So here everything is fine.

I just realised that I have one more device in my IOMMU group :

Code: Select all

/sys/kernel/iommu_groups/1/devices/0000:00:01.0
/sys/kernel/iommu_groups/1/devices/0000:01:00.0
/sys/kernel/iommu_groups/1/devices/0000:01:00.1
My GPU is 0000:01:00.x
I'll follow your guide to solve this but it might comes from here no ? That's the only thing that is not correct imo.
This is th device in IOMMU group

Code: Select all

lspci -s 00:01.0
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller (rev 06)
  
Thanks dude.

EDIT : I've changed the slot so now it's ok I have my GPU in its own IOMMU group but still when I'm booting my VM it's the default graphic card loaded. And always when I try to disable it, it freeze my VM, just like I need to plug the GPU physically into the screen.
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

@Gebonimo:
I have to mention that I have only one GPU, so it's on the PCI1 slot on my motherboard.
My tutorial and script is for 2 GPU - one for the host (Linux), the other for the VM.

Obviously when you boot the host, you have a working display, which means your GPU is initialized by Linux. If you want to pass it to the VM, you need to reset it and bind it to the vfio-pci driver.

The good news is that there is a script and instructions that can handle single GPU setups - I have linked to it under References, here is the direct link: https://gitlab.com/YuriAlek/vfio/wikis/Use/#windows.

Please be aware that the instructions given there are for Arch Linux. You should be fine with what you installed when you followed my tutorial. Please bear in mind that Yuri's script and wiki is still a work in progress. You will have to add the variables.

You will also need a copy of your vBIOS. Here is an excellent video on how to obtain it and fix it for KVM: https://www.youtube.com/watch?v=1IP-h9IKof0.

The simplest thing you can do: install a low-cost (perhaps an old/spare) graphics card for your host. Linux will work fine with it.

I you need a powerful GPU for Linux, for example for gaming under Linux, read my post Linux Virtual Gaming Machine.

I hope this helps.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
Gebonimo

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by Gebonimo »

When I mean I have only one GPu it's besides my motherboard Graphic Card.

I've change the AMD GPU to the "Crossfire" Slot to let it have its own IOMMU groupe (now it's 5:00.0/1)

Actually my linux distro is booting on the Intel Graphic Card (set up in BIOS). So my AMG GPU is not in use when I'm launching the VM. As you can see here :

Code: Select all

gebo@gebo-H87-HD3:~$ lspci -kn | grep -A 2 05:00
05:00.0 0300: 1002:6810
	Subsystem: 174b:e271
	Kernel driver in use: vfio-pci
--
05:00.1 0403: 1002:aab0
	Subsystem: 174b:aab0
	Kernel driver in use: vfio-pci
I'm looking for solution in W10 because it seems like it has trouble with some GPU. My VM use the Microsoft Default Card and doesn't want to use the AMD Radeon one. And everytime I try to install a NEW driver, it has BSOD. For the old ones it's ok.

I'll try to add driver manually by adding the .inf from the device manager. I think the problem is here.
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

Gebonimo wrote: Wed Jan 09, 2019 8:10 am When I mean I have only one GPu it's besides my motherboard Graphic Card.

I've change the AMD GPU to the "Crossfire" Slot to let it have its own IOMMU groupe (now it's 5:00.0/1)

Actually my linux distro is booting on the Intel Graphic Card (set up in BIOS). So my AMG GPU is not in use when I'm launching the VM. As you can see here :

Code: Select all

gebo@gebo-H87-HD3:~$ lspci -kn | grep -A 2 05:00
05:00.0 0300: 1002:6810
	Subsystem: 174b:e271
	Kernel driver in use: vfio-pci
--
05:00.1 0403: 1002:aab0
	Subsystem: 174b:aab0
	Kernel driver in use: vfio-pci
I'm looking for solution in W10 because it seems like it has trouble with some GPU. My VM use the Microsoft Default Card and doesn't want to use the AMD Radeon one. And everytime I try to install a NEW driver, it has BSOD. For the old ones it's ok.

I'll try to add driver manually by adding the .inf from the device manager. I think the problem is here.
Some AMD cards don't behave nice. Since you already tried the AMD workaround I described in my tutorial and it doesn't work, search your specific card and the term "passthrough" on the web and see if others report issues.

EDIT: Check to see if there is a motherboard BIOS update. What's your motherboard?

If you can't find a working solution, create a VGA BIOS dump following my instructions here: https://heiko-sieger.info/running-windo ... assthrough. Add the romfile=/path/to/GPU_BIOS.dump option to the line:

Code: Select all

-device ioh3420,bus=pci.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1
something like:

Code: Select all

-device ioh3420,bus=pci.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1,romfile=/path/to/GPU_BIOS.dump
In some cases the video BIOS needs to be loaded. If the above doesn't work, download the vBIOS for your card from techpowerup (see my tutorial for link), then edit it as shown in the video I linked to under https://heiko-sieger.info/running-windo ... th_Windows.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
powerhouse
Level 6
Level 6
Posts: 1144
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by powerhouse »

I've rewritten the part that deals with vfio-pci binding to the passthrough graphics card - see https://heiko-sieger.info/running-windo ... assthrough. My preferred method now is "module alias" as described in the tutorial.

I've also written a post on different methods to bind the vfio-pci driver to the graphics card, see https://heiko-sieger.info/blacklisting-graphics-driver/. This includes a script that works when identical graphics cards are used with both the host and the guest.

I did test these different methods, and all of the methods work for me. But that doesn't mean it will work on your system.

Please provide feedback on how it worked for you.

Specifically I need to know if my suggested "module alias" method works without blacklisting graphics drivers. Please let me know.
Subjects of interest: Linux, vfio passthrough virtualization, photography
See my blog on virtualization, including tutorials: https://www.heiko-sieger.info/category/ ... alization/
Tech-Junk1e

Re: HOW-TO make dual-boot obsolete using kvm VGA passthrough

Post by Tech-Junk1e »

Hello
I am relatively new to Linux, and completely new to Mint.

I can't seem to get GPU passthrough to work. slot one has host nvidia GT710 and slot 3 is my GTX 1660Ti for passthrough

Code: Select all

root@TJs-WorkHorse:~# lspci | grep VGA
09:00.0 VGA compatible controller: NVIDIA Corporation Device 2182 (rev a1)
42:00.0 VGA compatible controller: NVIDIA Corporation GK208B [GeForce GT 710] (rev a1)

Code: Select all

root@TJs-WorkHorse:~# sudo /home/tech-junk1e/Documents/win7VM.sh
QEMU 2.11.1 monitor - type 'help' for more information
(qemu) qemu-system-x86_64: -device vfio-pci,host=09:00.0,multifunction=on: vfio error: 0000:09:00.0: group 14 is not viable
Please ensure all devices within the iommu_group are bound to their vfio bus driver.
The GPU is in its own iommu group but the GPU seems to contain a USB controller

Code: Select all

root@TJs-WorkHorse:~# lspci -nn | grep 09:00
09:00.0 VGA compatible controller [0300]: NVIDIA Corporation Device [10de:2182] (rev a1)
09:00.1 Audio device [0403]: NVIDIA Corporation Device [10de:1aeb] (rev a1)
09:00.2 USB controller [0c03]: NVIDIA Corporation Device [10de:1aec] (rev a1)
09:00.3 Serial bus controller [0c80]: NVIDIA Corporation Device [10de:1aed] (rev a1)

Code: Select all

root@TJs-WorkHorse:~# lspci -kn | grep -A 2 09:00
09:00.0 0300: 10de:2182 (rev a1)
	Subsystem: 3842:1263
	Kernel driver in use: vfio-pci
--
09:00.1 0403: 10de:1aeb (rev a1)
	Subsystem: 3842:1263
	Kernel driver in use: vfio-pci
--
09:00.2 0c03: 10de:1aec (rev a1)
	Subsystem: 3842:1263
	Kernel driver in use: xhci_hcd
09:00.3 0c80: 10de:1aed (rev a1)
	Subsystem: 3842:1263
	Kernel driver in use: vfio-pci
it is in its own iommu group

Code: Select all

root@TJs-WorkHorse:~# for a in /sys/kernel/iommu_groups/*; do find $a -type l; done | sort --version-sort
/sys/kernel/iommu_groups/0/devices/0000:00:01.0
/sys/kernel/iommu_groups/1/devices/0000:00:01.1
/sys/kernel/iommu_groups/2/devices/0000:00:02.0
/sys/kernel/iommu_groups/3/devices/0000:00:03.0
/sys/kernel/iommu_groups/4/devices/0000:00:03.1
/sys/kernel/iommu_groups/5/devices/0000:00:04.0
/sys/kernel/iommu_groups/6/devices/0000:00:07.0
/sys/kernel/iommu_groups/7/devices/0000:00:07.1
/sys/kernel/iommu_groups/8/devices/0000:00:08.0
/sys/kernel/iommu_groups/9/devices/0000:00:08.1
/sys/kernel/iommu_groups/10/devices/0000:00:14.0
/sys/kernel/iommu_groups/10/devices/0000:00:14.3
/sys/kernel/iommu_groups/11/devices/0000:00:18.0
/sys/kernel/iommu_groups/11/devices/0000:00:18.1
/sys/kernel/iommu_groups/11/devices/0000:00:18.2
/sys/kernel/iommu_groups/11/devices/0000:00:18.3
/sys/kernel/iommu_groups/11/devices/0000:00:18.4
/sys/kernel/iommu_groups/11/devices/0000:00:18.5
/sys/kernel/iommu_groups/11/devices/0000:00:18.6
/sys/kernel/iommu_groups/11/devices/0000:00:18.7
/sys/kernel/iommu_groups/12/devices/0000:00:19.0
/sys/kernel/iommu_groups/12/devices/0000:00:19.1
/sys/kernel/iommu_groups/12/devices/0000:00:19.2
/sys/kernel/iommu_groups/12/devices/0000:00:19.3
/sys/kernel/iommu_groups/12/devices/0000:00:19.4
/sys/kernel/iommu_groups/12/devices/0000:00:19.5
/sys/kernel/iommu_groups/12/devices/0000:00:19.6
/sys/kernel/iommu_groups/12/devices/0000:00:19.7
/sys/kernel/iommu_groups/13/devices/0000:01:00.0
/sys/kernel/iommu_groups/13/devices/0000:01:00.1
/sys/kernel/iommu_groups/13/devices/0000:01:00.2
/sys/kernel/iommu_groups/13/devices/0000:02:00.0
/sys/kernel/iommu_groups/13/devices/0000:02:01.0
/sys/kernel/iommu_groups/13/devices/0000:02:02.0
/sys/kernel/iommu_groups/13/devices/0000:02:03.0
/sys/kernel/iommu_groups/13/devices/0000:02:04.0
/sys/kernel/iommu_groups/13/devices/0000:02:09.0
/sys/kernel/iommu_groups/13/devices/0000:05:00.0
/sys/kernel/iommu_groups/13/devices/0000:06:00.0
/sys/kernel/iommu_groups/13/devices/0000:08:00.0
/sys/kernel/iommu_groups/14/devices/0000:09:00.0
/sys/kernel/iommu_groups/14/devices/0000:09:00.1
/sys/kernel/iommu_groups/14/devices/0000:09:00.2
/sys/kernel/iommu_groups/14/devices/0000:09:00.3
/sys/kernel/iommu_groups/15/devices/0000:0a:00.0
/sys/kernel/iommu_groups/16/devices/0000:0a:00.2
/sys/kernel/iommu_groups/17/devices/0000:0a:00.3
/sys/kernel/iommu_groups/18/devices/0000:0b:00.0
/sys/kernel/iommu_groups/19/devices/0000:0b:00.2
/sys/kernel/iommu_groups/20/devices/0000:0b:00.3
/sys/kernel/iommu_groups/21/devices/0000:40:01.0
/sys/kernel/iommu_groups/22/devices/0000:40:01.3
/sys/kernel/iommu_groups/23/devices/0000:40:02.0
/sys/kernel/iommu_groups/24/devices/0000:40:03.0
/sys/kernel/iommu_groups/25/devices/0000:40:03.1
/sys/kernel/iommu_groups/26/devices/0000:40:04.0
/sys/kernel/iommu_groups/27/devices/0000:40:07.0
/sys/kernel/iommu_groups/28/devices/0000:40:07.1
/sys/kernel/iommu_groups/29/devices/0000:40:08.0
/sys/kernel/iommu_groups/30/devices/0000:40:08.1
/sys/kernel/iommu_groups/31/devices/0000:41:00.0
/sys/kernel/iommu_groups/32/devices/0000:42:00.0
/sys/kernel/iommu_groups/32/devices/0000:42:00.1
/sys/kernel/iommu_groups/33/devices/0000:43:00.0
/sys/kernel/iommu_groups/34/devices/0000:43:00.2
/sys/kernel/iommu_groups/35/devices/0000:43:00.3
/sys/kernel/iommu_groups/36/devices/0000:44:00.0
/sys/kernel/iommu_groups/37/devices/0000:44:00.2

Code: Select all

#!/bin/bash

vmname="windows7vm"

if ps -ef | grep qemu-system-x86_64 | grep -q multifunction=on; then
echo "A passthrough VM is already running." &
exit 1

else

# use pulseaudio
export QEMU_AUDIO_DRV=pa
export QEMU_PA_SAMPLES=8192
export QEMU_AUDIO_TIMER_PERIOD=99
export QEMU_PA_SERVER=/run/user/1000/pulse/native

cp /usr/share/OVMF/OVMF_VARS.fd /tmp/my_vars.fd

qemu-system-x86_64 \
-name $vmname,process=$vmname \
-machine type=pc,accel=kvm \
-cpu host,kvm=off \
-smp 20,sockets=1,cores=20,threads=1 \
-m 24G \
-balloon none \
-rtc clock=host,base=localtime \
-vga none \
-nographic \
-serial none \
-parallel none \
-soundhw hda \
-usb \
-device usb-host,vendorid=0x1e7d,productid=0x3214 \
-device usb-host,vendorid=0x1e7d,productid=0x2e4b \
-device vfio-pci,host=09:00.0,multifunction=on \
-device vfio-pci,host=09:00.1 \
-device vfio-pci,host=09:00.2 \
-device vfio-pci,host=09:00.3 \
-drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd \
-drive if=pflash,format=raw,file=/tmp/my_vars.fd \
-boot order=dc \
-drive id=disk0,if=virtio,cache=none,format=raw,file=/media/tech-junk1e/win.img \
-drive file=/home/tech-junk1e/Downloads/WINDOWS_7_ALL_IN_ONE_PRE-ACTIVATED.ISO,index=1,media=cdrom \
-drive file=/home/tech-junk1e/Downloads/virtio-win-0.1.164.iso,index=2,media=cdrom \
-netdev type=tap,id=net0,ifname=vmtap0,vhost=on \
-device virtio-net-pci,netdev=net0,mac=00:16:3e:00:5d:5b

exit 0
fi

##-vga none \
##
i have tried disabling passthrough and running software emulation and get error 0003 and cannot load my win7 iso

I am Running:
AMD Threadripper 1920X
ASUS X399 Prime motherboard
Two Corsair Dominator Platnium 16GB 3000 CL 15 for 32 GB of RAM
Nvidia GT 710 Host GPU
Nvidia GTX 1660Ti for passthrough
Seagate Ironwolf 4TB 5900RPM HDD

If there is anything else needed please let me know as I am still new to this

EDIT: Sorry, I forgot to mention, I am using Mint 19.1 kernel 4.15.0-47 generic. fresh install, and I followed the new tutorial linked at the beginning of thread. I also have the latest bios for my motherboard.
Locked

Return to “Virtual Machines”