refactor and start adding actual functionality
This commit is contained in:
parent
9efa0ee226
commit
82fec3ab58
11 changed files with 158 additions and 33 deletions
|
@ -63,7 +63,7 @@ func GenerateVBIOSDumper(vbios_path string) {
|
|||
errorcheck.ErrorCheck(err, "Could not change permissions of \"utils/dump_vbios.sh\"")
|
||||
|
||||
// Write to logger
|
||||
logger.Printf("Writing utils/dump_vbios.sh")
|
||||
logger.Printf("Writing utils/dump_vbios.sh\n")
|
||||
|
||||
// Write the script
|
||||
scriptfile.WriteString(vbios_script)
|
||||
|
|
|
@ -17,7 +17,7 @@ func DisableVFIOVideo(i int) {
|
|||
config := GetConfig()
|
||||
|
||||
// Write to logger
|
||||
logger.Printf("Adding vfio_pci.disable_vga=%v to %s", i, config.Path.CMDLINE)
|
||||
logger.Printf("Adding vfio_pci.disable_vga=%v to %s\n", i, config.Path.CMDLINE)
|
||||
|
||||
// Get the current kernel arguments we have generated
|
||||
kernel_args := fileio.ReadFile(config.Path.CMDLINE)
|
||||
|
|
|
@ -28,6 +28,8 @@ type Config struct {
|
|||
Bootloader string
|
||||
Cpuvendor string
|
||||
Path *Path
|
||||
Gpu_Group string
|
||||
Gpu_IDs []string
|
||||
}
|
||||
|
||||
// Gets the path to all the config files
|
||||
|
@ -52,6 +54,8 @@ func GetConfig() *Config {
|
|||
Bootloader: "unknown",
|
||||
Cpuvendor: cpuid.CPU.VendorString,
|
||||
Path: GetConfigPaths(),
|
||||
Gpu_Group: "",
|
||||
Gpu_IDs: []string{},
|
||||
}
|
||||
|
||||
// Detect the bootloader we are using
|
||||
|
|
|
@ -39,7 +39,8 @@ func Welcome() {
|
|||
// If yes, go to next page
|
||||
if choice == "y" {
|
||||
configs.InitConfigs()
|
||||
SelectGPU()
|
||||
config := configs.GetConfig()
|
||||
SelectGPU(config)
|
||||
} else {
|
||||
fmt.Println("")
|
||||
os.Exit(0)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,13 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/HikariKnight/quickpassthrough/internal/configs"
|
||||
lsiommu "github.com/HikariKnight/quickpassthrough/internal/lsiommu"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/command"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/menu"
|
||||
)
|
||||
|
||||
func genVBIOS_dumper(id string) {
|
||||
func genVBIOS_dumper(config *configs.Config) {
|
||||
// Clear the scren
|
||||
command.Clear()
|
||||
|
||||
|
@ -23,8 +25,9 @@ func genVBIOS_dumper(id string) {
|
|||
scriptdir, _ = os.Getwd()
|
||||
}
|
||||
|
||||
// Get the vbios path
|
||||
//vbios_path := lsiommu.GetIOMMU("-g", "-i", id, "--rom")[0]
|
||||
// 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)
|
||||
|
||||
// Tell users about the VBIOS dumper script
|
||||
fmt.Print(
|
||||
|
@ -38,13 +41,17 @@ func genVBIOS_dumper(id string) {
|
|||
)
|
||||
|
||||
// Get the OK press
|
||||
choice := menu.Ok("Make sure you run the script with the display-manager stopped using ssh or tty!")
|
||||
choice := menu.OkBack("Make sure you run the script with the display-manager stopped using ssh or tty!")
|
||||
|
||||
// If OK is pressed
|
||||
if choice == "next" {
|
||||
disableVideo()
|
||||
selectUSB()
|
||||
} else {
|
||||
// Parse choice
|
||||
switch choice {
|
||||
case "next":
|
||||
disableVideo(config)
|
||||
|
||||
case "back":
|
||||
SelectGPU(config)
|
||||
|
||||
case "":
|
||||
fmt.Println("")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
|
|
@ -2,13 +2,14 @@ package pages
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/HikariKnight/quickpassthrough/internal/configs"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/command"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/menu"
|
||||
)
|
||||
|
||||
func disableVideo() {
|
||||
func disableVideo(config *configs.Config) {
|
||||
// Clear the screen
|
||||
command.Clear()
|
||||
|
||||
|
@ -22,14 +23,25 @@ func disableVideo() {
|
|||
)
|
||||
|
||||
// Make the yesno menu
|
||||
choice := menu.YesNo("Do you want to force disable video output in linux on this card?")
|
||||
choice := menu.YesNoBack("Do you want to force disable video output in linux on this card?")
|
||||
|
||||
if choice == "Yes" {
|
||||
switch choice {
|
||||
case "y":
|
||||
// Add disable VFIO video to the config
|
||||
configs.DisableVFIOVideo(1)
|
||||
} else {
|
||||
selectUSB(config)
|
||||
|
||||
case "n":
|
||||
// Do not disable VFIO Video
|
||||
configs.DisableVFIOVideo(0)
|
||||
}
|
||||
selectUSB(config)
|
||||
|
||||
case "back":
|
||||
genVBIOS_dumper(config)
|
||||
|
||||
case "":
|
||||
// If ESC is pressed
|
||||
fmt.Println("")
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,13 +4,14 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/HikariKnight/quickpassthrough/internal/configs"
|
||||
lsiommu "github.com/HikariKnight/quickpassthrough/internal/lsiommu"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/command"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/menu"
|
||||
"github.com/gookit/color"
|
||||
)
|
||||
|
||||
func selectUSB() {
|
||||
func selectUSB(config *configs.Config) {
|
||||
// Clear the screen
|
||||
command.Clear()
|
||||
|
||||
|
@ -23,18 +24,20 @@ func selectUSB() {
|
|||
// Parse the choice
|
||||
switch choice {
|
||||
case "back":
|
||||
SelectGPU()
|
||||
disableVideo(config)
|
||||
|
||||
case "":
|
||||
// If ESC is pressed
|
||||
fmt.Println("")
|
||||
os.Exit(0)
|
||||
|
||||
default:
|
||||
// View the selected GPU
|
||||
viewUSB(choice)
|
||||
viewUSB(choice, config)
|
||||
}
|
||||
}
|
||||
|
||||
func viewUSB(id string, ext ...int) {
|
||||
func viewUSB(id string, config *configs.Config, ext ...int) {
|
||||
// Clear the screen
|
||||
command.Clear()
|
||||
|
||||
|
@ -76,9 +79,10 @@ func viewUSB(id string, ext ...int) {
|
|||
// If ESC is pressed
|
||||
fmt.Println("")
|
||||
os.Exit(0)
|
||||
|
||||
case "n":
|
||||
// Go back to selecting a gpu
|
||||
selectUSB()
|
||||
selectUSB(config)
|
||||
|
||||
case "y":
|
||||
// Go to the select a usb controller
|
||||
|
|
5
internal/pages/06_finalize.go
Normal file
5
internal/pages/06_finalize.go
Normal file
|
@ -0,0 +1,5 @@
|
|||
package pages
|
||||
|
||||
func finalize() {
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue