Skip to content

Repository files navigation

Laptop VM GPU Passthrough

Laptop VM GPU Passthrough - Windows on the dGPU while Linux stays on the iGPU

Run a Windows VM on a laptop dGPU while the Linux desktop stays on the iGPU.

Shell Libvirt VFIO Looking Glass

What It Does

This repo packages a laptop GPU-passthrough workflow for hybrid graphics systems:

  • Linux keeps the integrated GPU for the host desktop.
  • A Windows 11 VM receives the NVIDIA dGPU through VFIO.
  • libvirt profiles keep safe/debug/GPU modes separate.
  • Looking Glass or SPICE can be used as a fallback display path.
  • Reboot-time VFIO setup and rollback scripts are included for systems where live switching is unreliable.

It is meant as a reproducible starting point, not a universal one-click installer. Laptop VFIO depends on your exact GPU wiring, IOMMU groups, firmware, and display outputs.

Included

win11-gpu-vfio.sh          main VM control script
profiles/                 libvirt XML profiles for safe, GPU, and debug modes
boot-vfio-setup.sh         stage reboot-time VFIO binding
boot-vfio-revert.sh        remove reboot-time VFIO binding
gpu-passthrough-toggle.sh  status and mode helper
looking-glass-client.sh    launch Looking Glass against the running VM
make-looking-glass-tools-iso.sh
looking-glass-tools/       guest setup note for the generated ISO

Requirements

  • Linux with KVM, QEMU, libvirt, and virt-manager or virsh.
  • Hybrid graphics laptop with a host iGPU and a passthrough-capable dGPU.
  • IOMMU enabled in firmware.
  • A Windows VM or physical Windows disk prepared for libvirt use.
  • Optional: supergfxctl for supported hybrid graphics mode switching.
  • Optional: Looking Glass B7 client/host tools.

Useful Arch packages:

sudo pacman -S qemu-full libvirt virt-manager dnsmasq edk2-ovmf bridge-utils

Enable libvirt:

sudo systemctl enable --now libvirtd
sudo usermod -aG libvirt,kvm "$USER"

Log out and back in after changing groups.

Quick Start

Clone the repo:

git clone https://github.com/dakshdoesdev/Laptop-VM-GPU-PASSTHROUGH.git
cd Laptop-VM-GPU-PASSTHROUGH

Check current state:

./win11-gpu-vfio.sh status

Start the safe VM profile first:

./win11-gpu-vfio.sh start --safe

When the safe profile works, try the passthrough profile:

./win11-gpu-vfio.sh stop
./win11-gpu-vfio.sh prepare-gpu
./win11-gpu-vfio.sh start --gpu

Stop and restore the host:

./win11-gpu-vfio.sh stop
./win11-gpu-vfio.sh restore-host

Looking Glass

Use this when you want to view the Windows VM on the laptop screen instead of relying only on an external monitor.

Install the ACL hook once:

sudo ./install-looking-glass-acl-hook.sh

Generate the guest tools ISO:

# Download the Looking Glass B7 host archive from the official project first.
# Save it here as: LookingGlass-Host-B7.exe
./make-looking-glass-tools-iso.sh

Start the VM with the Looking Glass/SPICE profile:

./win11-gpu-vfio.sh stop
./win11-gpu-vfio.sh start --lg
./looking-glass-client.sh

The repository does not include LookingGlass-Host-B7.exe or built client binaries. Download/build those locally.

Reboot-Time VFIO

Use this only if live switching cannot move the dGPU to VFIO cleanly.

Stage VFIO boot:

sudo ./boot-vfio-setup.sh
sudo reboot

After reboot, verify both GPU functions are bound to vfio-pci:

lspci -nnk -s 01:00.0
lspci -nnk -s 01:00.1

Rollback:

sudo ./boot-vfio-revert.sh
sudo reboot

Safety Notes

  • Review the XML profiles before importing them.
  • Update disk paths, PCI addresses, memory, CPU topology, and firmware paths for your machine.
  • Do not run the boot-time VFIO setup until you understand how to revert it.
  • Keep a second login path available when testing GPU handoff.
  • Do not commit VM disks, ISO images, firmware blobs, logs, or Looking Glass binaries.

Verification

The published repo was checked with:

bash -n *.sh
xmllint --noout profiles/*.xml
git diff --check

References

About

Hybrid-laptop VFIO helper for running a Windows VM on the dGPU while Linux stays on the iGPU.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages