Compare commits

...

7 commits
2.1.0 ... main

Author SHA1 Message Date
jedrw
c1f11ce1c3 fix: avoid potential index out of range error if ls-iommu cannot find a vbios path
Signed-off-by: HikariKnight <2557889+HikariKnight@users.noreply.github.com>
2025-01-06 14:43:55 +01:00
HikariKnight
0efcf4ee19 fix(dracut): force load vfio modules earlier
this should make them load before any gpu drivers
2025-01-06 14:15:45 +01:00
HikariKnight
276cfd953a fix: correct vfio_pci to vfio-pci in rd.driver.pre for dracut 2024-12-29 05:34:03 +01:00
HikariKnight
4f51fd5c5f chore: remove outdated info from readme 2024-09-08 02:08:09 +02:00
HikariKnight
05afa8c543 chore: cleanup the readme 2024-08-10 09:11:03 +02:00
HikariKnight
d1e44d94d5 chore: add quickpassthrough_debug.log to gitignore 2024-08-10 09:02:49 +02:00
HikariKnight
3f934351fc fix: correctly detect kernel 6.10 and newer as a newer kernel 2024-08-10 08:57:54 +02:00
5 changed files with 20 additions and 16 deletions

3
.gitignore vendored
View file

@ -6,4 +6,5 @@ bin/
dist/
main
quickpassthrough
debug.log
debug.log
quickpassthrough_debug.log

View file

@ -5,7 +5,7 @@ A project to simplify setting up GPU passthrough on your Linux host for libvirt/
You can use it by simply downloading the latest [release](https://github.com/HikariKnight/quickpassthrough/releases/) and run it inside a terminal or by downloading and compiling it yourself with the commands below.
This project is aimed at **desktops with 2 GPUs** and **headless servers**, where the only GPU is not needed.
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.
@ -47,16 +47,18 @@ 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 immutable systems?
Currently no, however [Bazzite](https://bazzite.gg) 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`.
## Does this work on atomic or immutable systems?
Currently no, however [Bazzite](https://bazzite.gg), [Bluefin](https://projectbluefin.io) and [Aurora](https://getaurora.dev) 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`.<br>
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. <br>
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. <br>
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
@ -64,7 +66,6 @@ NOTE: You can also just remove them from your bootloader permanently and update
* Optimize your Virtual Machine for Passthrough (again this is your job)
* Optimize your host machine for Passthrough or Virtualization (out of this projects scope)
* Setup and configure GPU Passthrough on systems with 1 graphic card (iGPU counts as 1 Graphic Card by itself, so iGPU with another GPU will work)
* Does not configure passthrough of 3D controllers, [as it will not work](https://lantian.pub/en/article/modify-computer/laptop-intel-nvidia-optimus-passthrough.lantian/) (this is most gaming laptops so do not even think about it). If you try run this on a laptop with a 3D controller, the "2nd GPU" will not show up.
## Contributing
<img src="https://user-images.githubusercontent.com/2557889/156038229-4e70352f-9182-4474-8e32-d14d3ad67566.png" width="250px">

View file

@ -22,18 +22,18 @@ func Set_Dracut() {
}
// Write to logger
logger.Printf("Writing to %s:\nadd_drivers+=\" %s \"\n", dracutConf, strings.Join(vfio_modules(), " "))
logger.Printf("Writing to %s:\nforce_drivers+=\" %s \"\n", dracutConf, strings.Join(vfio_modules(), " "))
// Write the dracut config file
fileio.AppendContent(fmt.Sprintf("add_drivers+=\" %s \"\n", strings.Join(vfio_modules(), " ")), dracutConf)
fileio.AppendContent(fmt.Sprintf("force_drivers+=\" %s \"\n", strings.Join(vfio_modules(), " ")), dracutConf)
// Get the current kernel arguments we have generated
kernel_args := fileio.ReadFile(config.Path.CMDLINE)
// If the kernel argument is not already in the file
if !strings.Contains(kernel_args, "rd.driver.pre=vfio_pci") {
if !strings.Contains(kernel_args, "rd.driver.pre=vfio-pci") {
// Add to our kernel arguments file that vfio_pci should load early (dracut does this using kernel arguments)
fileio.AppendContent(" rd.driver.pre=vfio_pci", config.Path.CMDLINE)
fileio.AppendContent(" rd.driver.pre=vfio-pci", config.Path.CMDLINE)
}
// Make a backup of dracutConf if there is one there

View file

@ -221,7 +221,7 @@ func vfio_modules() []string {
// If we are on a kernel older than 6.2
sysinfo := uname.New()
kernel_re := regexp.MustCompile(`^(6\.1|6\.0|[1-5]\.)`)
kernel_re := regexp.MustCompile(`^(6\.1|6\.0|[1-5]\.\d{1,2})\.`)
if kernel_re.MatchString(sysinfo.Kernel) {
// Write to the debug log
logger.Printf("Linux kernel version %s detected!\nIncluding vfio_virqfd module\n", sysinfo.Kernel)

View file

@ -26,9 +26,11 @@ func genVBIOS_dumper(config *configs.Config) {
scriptdir, _ = os.Getwd()
}
// Get the vbios path and generate the vbios dumping script
vbios_path := lsiommu.GetIOMMU("-g", "-i", config.Gpu_Group, "--rom")[0]
configs.GenerateVBIOSDumper(vbios_path)
// Search for a vbios path and generate the vbios dumping script if found
vbios_paths := lsiommu.GetIOMMU("-g", "-i", config.Gpu_Group, "--rom")
if len(vbios_paths) != 0 {
configs.GenerateVBIOSDumper(vbios_paths[0])
}
// Make the qemu config folder
os.Mkdir(fmt.Sprintf("%s/%s", scriptdir, config.Path.QEMU), os.ModePerm)
@ -51,7 +53,7 @@ func genVBIOS_dumper(config *configs.Config) {
"rom to the VM along with the card in order to get a functional passthrough.\n",
"In many cases you can find your vbios at https://www.techpowerup.com/vgabios/\n",
"\n",
"You can also attempt to dump your own vbios from TTY using the script in\n",
"If we found a romfile for your GPU you can also attempt to dump your own vbios from TTY using the script in\n",
fmt.Sprintf("%s/utils/dump_vbios.sh\n", scriptdir),
"\n",
)