Linux,QEMU and passthrough I/O

Foreword

These days many say that 2026 will be the year of Linux.

Linux is evolving and maturing, and we can find MS platform equivalent software and solutions for nearly anything.

Many had enough of Windows OS, they think it takes a turn i the wrong direction for a number of reasons:

-forced updates
-Hardware spec requirements and limitations (as in TPM chip)
-less control
-online subscriptions requrements
-forced Microsoft accounts
-bitlocker and storing of the encryption keys at MS cloud..?

The obvious and good alternative for a technical person would be the transition to Linux.

So maybe you are a Microsoft refugee this year, and taking the leap and running Linux only on your main computers.

If you do, you might still need that one application that is Windows only, and what is the best option then?

Virtualization

For applications that need some hardware power in terms of GPU passthrough I would say QEMU/KVM

QEMU/KVM (Kernel-based virtual machine) is a generic open source machine emulator and virtualizer. It is native to Ubuntu and many other Linux flaovours. For me personally as a Hyper-V specialist, I also find it very interesting to look at how other solutions work

Here is a birds-eye view of what you need to take into account as QEMU can be a little more tech oriented than ex. Virtualbox or VMware.

 

Check your IOMMU groups

For passthrough to work, we want at least two GPU’s and we need to look at the IOMMU groups, which is the routing of the addressing space for your hardware on your chipset/motherboard.

We need to assign virtio drivers to a whole group, so we want to make sure they are as separated as possible. For checking you can run this script:

				
					#!/bin/bash
shopt -s nullglob
for g in $(find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V); do
    echo "IOMMU Group ${g##*/}:"
    for d in $g/devices/*; do
        echo -e "\t$(lspci -nns ${d##*/})"
    done;
done;
				
			

The script will show the layout of your IOMMU groups and we are looking for the GPU and hopefully one of them is placed  in its own group.

-if not you will most likely need a new motherboard/PC. So try  checking the specs/reviews on QEMU groups before you buy. Search for IOMMU layout.

Configure your BIOS for virtualization

In BIOS enable Virtualization and VT-d (these have a little naming differences depending on if you have Intel or AMD CPU)

Find you GPU's Ids

lspci -nn | grep AMD (or NVIDIA ig that is the card you want to passthrough)

Remember that most GPUs have a graphics part and a n Audio over HDMI part, so be sure to note both. Like:

09:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Navi 23 [Radeon RX 6600/6600 XT/6600M] [1002:73ff] (rev c7)
09:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Navi 21/23 HDMI/DP Audio Controller [1002:ab28]

Edit your Grub (bootloader)

Edit /etc/default/grub

Replace the line GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash” with  GRUB_CMDLINE_LINUX_DEFAULT=”amd_iommu=on iommu=pt vfio-pci.ids=1002:73ff,1002:ab28″

(Change to intel_iommu=on  if you have an Intel CPU)

We tell the bootloader to free the resources to be used with virtio

Update your grub: 
sudo grub-mkconfig -o /boot/grub/grub.cfg

 

Edit modules and update initramfs

sudo nano /etc/initramfs-tools/modules
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
vhost-net

Update (for Ubunu:)
sudo update-initramfs -u

Then reboot and check if the virtio driver is being used:
lspci -k
look for Kernel driver in use: vfio-pci

Check your logs:

sudo dmesg | grep -e DMAR -e IOMMU
look for ex: [ 0.354991] DMAR: Intel(R) Virtualization Technology for Directed I/O

Present the hardware to your VM

Add the PCI-E units (Graphics and Audio) to your Windows VM, boot it up and load the AMD or NVIDIA drivers

Additional tips for smoothness

Use RDP for connecting to the host, the MS protocol is using a great compression algortihm and works better than both Spice or virt-manager console. use Remmina as an RDP client.

Dedicate a full blown SSD or M2 disk to the VM rather than using disk image type qcow2. This will give you direct disk i/o.

Consider passing through more hardware if needed, like NIC or USB busses. 

More articles

Free PDF creator

Stirling-PDF creator Why run your own docker instance of Stirling-PDF creator , you say? -No more paying Adobe and their overpriced

Read More »