Move some code around to places it makes more sense to do the tasks given
This commit is contained in:
parent
68aec7fdb8
commit
84befa6f85
3 changed files with 29 additions and 16 deletions
|
@ -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)
|
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
|
// TODO3: if unknown bootloader, tell user what to add a kernel arguments
|
||||||
|
|
||||||
// Configures systemd-boot using kernelstub
|
// Configures systemd-boot using kernelstub
|
||||||
|
@ -78,7 +78,7 @@ func Set_KernelStub() {
|
||||||
command.Run("sudo", "kernelstub", "-a", kernel_args)
|
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() {
|
func Set_Grubby() {
|
||||||
// Get the config
|
// Get the config
|
||||||
config := GetConfig()
|
config := GetConfig()
|
||||||
|
@ -92,3 +92,7 @@ func Set_Grubby() {
|
||||||
// Run the command
|
// Run the command
|
||||||
command.Run("sudo", "grubby", "--update-kernel=ALL", fmt.Sprintf("--args=%s", kernel_args))
|
command.Run("sudo", "grubby", "--update-kernel=ALL", fmt.Sprintf("--args=%s", kernel_args))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Set_Grub2() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/HikariKnight/ls-iommu/pkg/errorcheck"
|
||||||
"github.com/HikariKnight/quickpassthrough/internal/configs"
|
"github.com/HikariKnight/quickpassthrough/internal/configs"
|
||||||
"github.com/HikariKnight/quickpassthrough/internal/logger"
|
"github.com/HikariKnight/quickpassthrough/internal/logger"
|
||||||
"github.com/HikariKnight/quickpassthrough/pkg/command"
|
"github.com/HikariKnight/quickpassthrough/pkg/command"
|
||||||
|
@ -35,12 +36,28 @@ func (m *model) processSelection() bool {
|
||||||
m.focused++
|
m.focused++
|
||||||
|
|
||||||
case GPU_GROUP:
|
case GPU_GROUP:
|
||||||
|
// Get the config
|
||||||
|
config := configs.GetConfig()
|
||||||
|
|
||||||
// Get the vbios path
|
// Get the vbios path
|
||||||
m.vbios_path = getIOMMU("-g", "-i", m.gpu_group, "--rom")[0]
|
m.vbios_path = getIOMMU("-g", "-i", m.gpu_group, "--rom")[0]
|
||||||
|
|
||||||
// Generate the VBIOS dumper script once the user has selected a GPU
|
// Generate the VBIOS dumper script once the user has selected a GPU
|
||||||
configs.GenerateVBIOSDumper(m.vbios_path)
|
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
|
// Change focus to the next view
|
||||||
m.focused++
|
m.focused++
|
||||||
|
|
||||||
|
@ -76,18 +93,6 @@ func (m *model) processSelection() bool {
|
||||||
// Get our config struct
|
// Get our config struct
|
||||||
config := configs.GetConfig()
|
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 user selected yes then
|
||||||
if selectedItem.(item).title == "YES" {
|
if selectedItem.(item).title == "YES" {
|
||||||
// Add disable VFIO video to the config
|
// Add disable VFIO video to the config
|
||||||
|
@ -100,7 +105,7 @@ func (m *model) processSelection() bool {
|
||||||
// If we have files for modprobe
|
// If we have files for modprobe
|
||||||
if fileio.FileExist(config.Path.MODPROBE) {
|
if fileio.FileExist(config.Path.MODPROBE) {
|
||||||
// Configure modprobe
|
// Configure modprobe
|
||||||
configs.Set_Modprobe(gpu_IDs)
|
configs.Set_Modprobe(m.gpu_IDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a folder for dracut
|
// If we have a folder for dracut
|
||||||
|
@ -171,7 +176,10 @@ func (m *model) install(auth string) {
|
||||||
// Configure kernelstub
|
// Configure kernelstub
|
||||||
configs.Set_Grubby()
|
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)
|
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)
|
fmt.Printf("Unsupported bootloader, please add the below line to your bootloaders kernel arguments\n%s", kernel_args)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ type model struct {
|
||||||
fetched []bool
|
fetched []bool
|
||||||
lists []list.Model
|
lists []list.Model
|
||||||
gpu_group string
|
gpu_group string
|
||||||
|
gpu_IDs []string
|
||||||
vbios_path string
|
vbios_path string
|
||||||
focused status
|
focused status
|
||||||
offsetx []int
|
offsetx []int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue