diff --git a/internal/configs/config_bootloaders.go b/internal/configs/config_bootloaders.go index 651f34a..15e6f7d 100644 --- a/internal/configs/config_bootloaders.go +++ b/internal/configs/config_bootloaders.go @@ -60,7 +60,7 @@ func Set_Cmdline(gpu_IDs []string) { fileio.AppendContent(fmt.Sprintf(" vfio_pci.ids=%s", strings.Join(gpu_IDs, ",")), config.Path.CMDLINE) } -// TODO: write functions to configure grub +// TODO: write function to configure grub // TODO3: if unknown bootloader, tell user what to add a kernel arguments // Configures systemd-boot using kernelstub @@ -78,7 +78,7 @@ func Set_KernelStub() { command.Run("sudo", "kernelstub", "-a", kernel_args) } -// Configures grub2 or systemd-boot using grubby +// Configures grub2 and/or systemd-boot using grubby func Set_Grubby() { // Get the config config := GetConfig() @@ -92,3 +92,7 @@ func Set_Grubby() { // Run the command command.Run("sudo", "grubby", "--update-kernel=ALL", fmt.Sprintf("--args=%s", kernel_args)) } + +func Set_Grub2() { + +} diff --git a/internal/ui_main_functions.go b/internal/ui_main_functions.go index b0efdc5..9146ec1 100644 --- a/internal/ui_main_functions.go +++ b/internal/ui_main_functions.go @@ -5,6 +5,7 @@ import ( "os" "regexp" + "github.com/HikariKnight/ls-iommu/pkg/errorcheck" "github.com/HikariKnight/quickpassthrough/internal/configs" "github.com/HikariKnight/quickpassthrough/internal/logger" "github.com/HikariKnight/quickpassthrough/pkg/command" @@ -35,12 +36,28 @@ func (m *model) processSelection() bool { m.focused++ case GPU_GROUP: + // Get the config + config := configs.GetConfig() + // Get the vbios path m.vbios_path = getIOMMU("-g", "-i", m.gpu_group, "--rom")[0] // Generate the VBIOS dumper script once the user has selected a GPU configs.GenerateVBIOSDumper(m.vbios_path) + // Get the device ids for the selected gpu using ls-iommu + m.gpu_IDs = getIOMMU("-gr", "-i", m.gpu_group, "--id") + + // If the kernel_args file already exists + if fileio.FileExist(config.Path.CMDLINE) { + // Delete it as we will have to make a new one anyway + err := os.Remove(config.Path.CMDLINE) + errorcheck.ErrorCheck(err, fmt.Sprintf("Could not remove %s", config.Path.CMDLINE)) + } + + // Write initial kernel_arg file + configs.Set_Cmdline(m.gpu_IDs) + // Change focus to the next view m.focused++ @@ -76,18 +93,6 @@ func (m *model) processSelection() bool { // Get our config struct config := configs.GetConfig() - // Get the device ids for the selected gpu using ls-iommu - gpu_IDs := getIOMMU("-gr", "-i", m.gpu_group, "--id") - - // If the kernel_args file already exists - if fileio.FileExist(config.Path.CMDLINE) { - // Delete it as we will have to make a new one anyway - os.Remove(config.Path.CMDLINE) - } - - // Write initial kernel_arg file - configs.Set_Cmdline(gpu_IDs) - // If user selected yes then if selectedItem.(item).title == "YES" { // Add disable VFIO video to the config @@ -100,7 +105,7 @@ func (m *model) processSelection() bool { // If we have files for modprobe if fileio.FileExist(config.Path.MODPROBE) { // Configure modprobe - configs.Set_Modprobe(gpu_IDs) + configs.Set_Modprobe(m.gpu_IDs) } // If we have a folder for dracut @@ -171,7 +176,10 @@ func (m *model) install(auth string) { // Configure kernelstub configs.Set_Grubby() - } else if config.Bootloader == "unknown" { + } else if config.Bootloader == "grub2" { + // Write to logger + logger.Printf("Configuring grub2 manually") + } else { kernel_args := fileio.ReadFile(config.Path.CMDLINE) fmt.Printf("Unsupported bootloader, please add the below line to your bootloaders kernel arguments\n%s", kernel_args) } diff --git a/internal/ui_model.go b/internal/ui_model.go index da1b3ec..2fad848 100644 --- a/internal/ui_model.go +++ b/internal/ui_model.go @@ -28,6 +28,7 @@ type model struct { fetched []bool lists []list.Model gpu_group string + gpu_IDs []string vbios_path string focused status offsetx []int