When using PCI-E passthrough to pass a dedicated GPU to a VM, can I use the integrated GPU for the host, so that I can do it with just one graphics card? (or maybe try it on a laptop with Nvidia Optimus)
Also, when I want to play native linux games, and I shut down the VM, can the host use the dedicated GPU, since it’s not used by the VM anymore?
I’m by no means an expert, but I’m using a gtx 1070 passed through to a windows vm with the igpu from an i7-6700k as the gpu for my linux host.
I followed this nice guide step by step with little issue, and got it working in about half an hour.
(I had trouble with LibVirt, so switched to using just qemu and a bash script as I’m more familiar with that)
so short answer, it depends on what cpu you have, and if it supports it, but yes, it is possible.
When using PCI-E passthrough to pass a dedicated GPU to a VM, can I use the integrated GPU for the host, so that I can do it with just one graphics card?
Yes. This is actually a dual GPU setup, and one of the reason I went with a Ryzen 2600.
You can not currently pass through the integrated graphics to the virtual machine, but if you pass the dedicated GPU, you’ll be able to use your integrated one just fine.
Also, when I want to play native linux games, and I shut down the VM, can the host use the dedicated GPU, since it’s not used by the VM anymore?
This depends a little on how you set up the passthrough, but yes. Worst case, it’s doable but you have to script the loading and unloading of some kernel modules when you switch.
Some methods of VFIO passthrough “stub” out the video card. There’s an older module ‘pci_stub’ and a newer one “vfio-pci” the both do (basically) the same thing. They load at boot time in place of your GPU’s kernel modules, so that when the VM is booted, they don’t have to unload.
The “you might have to script something” part comes in here. To hand the GPU back to the host, you’ll need to initialize the GPU with the right modules. This should be fairly sane; unload the vfio-pci module, load the nvidia/amdgpu module, and launch. Check out the man pages or an online wiki for “modprobe” invocation commands.