This repo contains my personal configs on Libvirt single GPU passthrough, stripped down to the most generic way possible. Here you will find templates and files you can customize if you have similar hardware or take a look to build your own configuration if you don't.
Unfortunately I have only used gpu passthrough on my personal machine, so there is only one motherboard and graphics card listed. I intend to keep this project updated when I eventually upgrade my machine but until then it will probably stay like this. PRs are welcome if you want to contribute with your personal configuration.
All files are located in the sysroot folder exactly where they will be placed when installed to the root of the filesystem.
-
/etc/lsgp.confis the starting script config file - modules to unbind, pre and post run scripts, hugepages allocation and others are configured here. -
/etc/systemd/system/[email protected]is the systemd service that will actually run the starting script. This is necessary to keep the script alive even after the terminal window is closed. This also has the convenient side effect of keeping track of the script log acessible through systemctl status. DO NOT ENABLE THIS SERVICE unless you know what you're doing. -
/usr/bin/lsgpis the starting script, nothing here needs to be changed before running, use/etc/lsgp.confinstead. -
/usr/share/libvirt/lsgp/bootloaderscontains standalone bootloaders, it currently contains only the Clover bootloader (from foxlet/macOS-Simple-KVM). -
/usr/share/libvirt/lsgp/examplescontains xml files and config snippets you can use to build a customized virtual machine, including notes I take as time goes by. These configs require some editting before using for values coupled to specific user needs, things like ram amount, core count, path to disk images and so on. -
/usr/share/libvirt/lsgp/firmwarecontains device firmware blobs required for correct use inside virtual machines, such as graphics card BIOSes. It also contains some specific versions of OVMF I had success using and a version of OVMF tuned for macOS virtual machines (from foxlet/macOS-Simple-KVM). -
/usr/share/libvirt/lsgp/nvramcontains NVRAM presets for the OVMF UEFI firmwares in the/usr/share/libvirt/lsgp/firmware/uefifolder.
- First you need to place all files in their correct folders. Download the latest release, extract it somewhere and then open a terminal in the extracted folder and run:
sudo ./install.sh
-
Customize the configuration file at
/etc/lsgp.confwith the settings you need. -
You need to build an xml file for the VM you want to run. You can use the presets in the
/usr/share/libvirt/lsgp/examplesfolder as a base and add xml from/usr/share/libvirt/lsgp/examples/emulatedfor emulated devices and/usr/share/libvirt/lsgp/examples/physicalfor physical devices grouped by motherboard and category. This probably will not be enough for your VM as this project only has xml for devices I own, so you have to manually add code for devices not included here (but you can use mine as a reference). When the xml is done, define a virtual machine by using:
sudo virsh define file.xml
- Start your virtual machine with the following code, replacing
virtualmachinewith your virtual machine domain name:
sudo systemctl start [email protected]
When you want to return to the host, just turn off the guest OS.