HikariKnight / quickpassthrough

A project to remove the complexity of setting up GPU passthrough for qemu
MIT License
707 stars 21 forks source link
gpu-passthrough kvm kvm-hypervisor libvirt linux qemu qemu-kvm vfio vfio-passthrough virtualization

QuickPassthrough

A project to simplify setting up GPU passthrough on your Linux host for libvirt/virt-manager Quickpassthrough Preview GIF

You can use it by simply downloading the latest release and run it inside a terminal or by downloading and compiling it yourself with the commands below.

This project is aimed at systems with 2 GPUs and headless servers, where the only GPU is not needed.

Note: Quickpassthrough is not designed to be installed by a package manager! As you would usually have to only run it once, unless you change the GPU.

Features

Features handled by ls-iommu

Build with current dependencies

git clone https://github.com/HikariKnight/quickpassthrough.git
cd quickpassthrough
go mod download
CGO_ENABLED=0 go build -ldflags="-X github.com/HikariKnight/quickpassthrough/internal/version.Version=$(git rev-parse --short HEAD)" -o quickpassthrough cmd/main.go

Build with newest dependencies (may break)

git clone https://github.com/HikariKnight/quickpassthrough.git
cd quickpassthrough
go mod download
go get -u ./cmd
CGO_ENABLED=0 go build -ldflags="-X github.com/HikariKnight/quickpassthrough/internal/version.Version=$(git rev-parse --short HEAD)" -o quickpassthrough cmd/main.go

Does this work on atomic or immutable systems?

Currently no, however Bazzite, Bluefin and Aurora has an ujust command that does a very similar job.

In Bazzite you run ujust setup-virtualization and follow the prompts to Enable Virtualization and Enable VFIO drivers.
In Bluefin and Aurora you run ujust setup-vfio and follow the prompts.

How do I undo the changes?

There is a backup/ folder generated on the first run that will have a copy of all your files (and their paths) from before we edited anything. Compare that folder with the config/ folder to see which files you need to delete in addition to copying the files from backup/ to your system before rebuilding your initramfs and updating your bootloader config.

How do I just disable vfio for 1 boot?

Remove the vfio kernel arguments from your bootloader by pressing E on the boot menu. The kernel arguments added to the bootloader can be found in the config/kernel_args file.
NOTE: You can also just remove them from your bootloader permanently and update your bootloader if you want to keep the config files on your system.

What this project does NOT do

Contributing

This project originally started out as a bash only project, upon completing the proof of concept it became very clear that bash would become very messy with all the weird quirks and regex and inline editing of files.
So the project moved over to golang, this lets us utilize TUI toolkits to build a proper menu system for the project.

If you know golang, passthrough or qemu, you are welcome to help! Just make a pull request!
Just remember to add comments to document the work and explain it for people who are less familiar with the golang syntax or anything else you use. 😄

Also if you know English, you can help by just proof reading. English is not my native language, plus I have dyslexia so I often make spelling mistakes. Proof reading is still contribution!


Why GO?

I wanted to learn it, while also using a language that would potentially not create system dependencies. GO fits this criteria when you compile using CGO_ENABLED=0 as this will statically link the libraries and still produce a fairly small (when compressed with upx) binary.