refactor and start adding actual functionality
This commit is contained in:
parent
9efa0ee226
commit
82fec3ab58
11 changed files with 158 additions and 33 deletions
|
@ -4,13 +4,16 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/HikariKnight/ls-iommu/pkg/errorcheck"
|
||||
"github.com/HikariKnight/quickpassthrough/internal/configs"
|
||||
lsiommu "github.com/HikariKnight/quickpassthrough/internal/lsiommu"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/command"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/fileio"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/menu"
|
||||
"github.com/gookit/color"
|
||||
)
|
||||
|
||||
func SelectGPU() {
|
||||
func SelectGPU(config *configs.Config) {
|
||||
// Clear the screen
|
||||
command.Clear()
|
||||
|
||||
|
@ -29,11 +32,12 @@ func SelectGPU() {
|
|||
fmt.Println("")
|
||||
os.Exit(0)
|
||||
default:
|
||||
viewGPU(choice)
|
||||
config.Gpu_Group = choice
|
||||
viewGPU(config)
|
||||
}
|
||||
}
|
||||
|
||||
func viewGPU(id string, ext ...int) {
|
||||
func viewGPU(config *configs.Config, ext ...int) {
|
||||
// Clear the screen
|
||||
command.Clear()
|
||||
|
||||
|
@ -46,10 +50,10 @@ func viewGPU(id string, ext ...int) {
|
|||
}
|
||||
|
||||
// Get the IOMMU listings for GPUs
|
||||
group := lsiommu.GetIOMMU("-g", mode, "-i", id, "-F", "vendor:,prod_name,optional_revision:,device_id")
|
||||
group := lsiommu.GetIOMMU("-g", mode, "-i", config.Gpu_Group, "-F", "vendor:,prod_name,optional_revision:,device_id")
|
||||
|
||||
// Write a title
|
||||
color.Bold.Println("This list should only show devices related to your GPU")
|
||||
color.Bold.Println("This list should only show devices related to your GPU (usually 1 video, 1 audio device)")
|
||||
|
||||
// Print all the gpus
|
||||
for _, v := range group {
|
||||
|
@ -64,7 +68,7 @@ func viewGPU(id string, ext ...int) {
|
|||
|
||||
// Change choices depending on if we have done an extended search or not
|
||||
if len(ext) > 0 {
|
||||
choice = menu.YesNo("Use this GPU (any extra devices listed may or may not be linked to it) for passthrough?")
|
||||
choice = menu.YesNoManual("Use this GPU (any extra devices listed may or may not be linked to it) for passthrough?")
|
||||
} else {
|
||||
choice = menu.YesNoEXT("Use this GPU (and related devices) for passthrough?")
|
||||
}
|
||||
|
@ -78,15 +82,47 @@ func viewGPU(id string, ext ...int) {
|
|||
|
||||
case "ext":
|
||||
// Run an extended relative search
|
||||
viewGPU(id, 1)
|
||||
viewGPU(config, 1)
|
||||
|
||||
case "n":
|
||||
// Go back to selecting a gpu
|
||||
SelectGPU()
|
||||
SelectGPU(config)
|
||||
|
||||
case "y":
|
||||
// Go to the select a usb controller
|
||||
//selectUSB()
|
||||
genVBIOS_dumper(id)
|
||||
// Get the device ids for the selected gpu using ls-iommu
|
||||
config.Gpu_IDs = lsiommu.GetIOMMU("-g", mode, "-i", config.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(config.Gpu_IDs)
|
||||
|
||||
// Go to the vbios dumper page
|
||||
genVBIOS_dumper(config)
|
||||
|
||||
case "manual":
|
||||
config.Gpu_IDs = menu.ManualInput(
|
||||
"Please manually enter the vendorID:deviceID for every device to use except PCI Express Switches\n"+
|
||||
"NOTE: All devices sharing the same IOMMU group will still get pulled into the VM!",
|
||||
"xxxx:yyyy,xxxx:yyyy,xxxx:yyyy",
|
||||
)
|
||||
|
||||
// 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(config.Gpu_IDs)
|
||||
|
||||
// Go to the vbios dumper page
|
||||
genVBIOS_dumper(config)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue