Add logger debug output
This commit is contained in:
parent
27a52cda1f
commit
639d056abe
7 changed files with 71 additions and 18 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/HikariKnight/quickpassthrough/internal/logger"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/fileio"
|
||||
)
|
||||
|
||||
|
@ -19,6 +20,9 @@ func Set_Dracut() {
|
|||
os.Remove(dracutConf)
|
||||
}
|
||||
|
||||
// Write to logger
|
||||
logger.Printf("Writing to %s:\nadd_drivers+=\" %s \"", dracutConf, strings.Join(vfio_modules(), " "))
|
||||
|
||||
// Write the dracut config file
|
||||
fileio.AppendContent(fmt.Sprintf("add_drivers+=\" %s \"\n", strings.Join(vfio_modules(), " ")), dracutConf)
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/HikariKnight/quickpassthrough/internal/logger"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/fileio"
|
||||
)
|
||||
|
||||
|
@ -30,6 +31,9 @@ func Set_Mkinitcpio() {
|
|||
// Read the mkinitcpio file
|
||||
mkinitcpio_content := fileio.ReadLines(sysfile)
|
||||
|
||||
// Write to logger
|
||||
logger.Printf("Read %s:\n%s", sysfile, strings.Join(mkinitcpio_content, "\n"))
|
||||
|
||||
for _, line := range mkinitcpio_content {
|
||||
// If we are at the line starting with MODULES=
|
||||
if module_line_re.MatchString(line) {
|
||||
|
@ -41,6 +45,9 @@ func Set_Mkinitcpio() {
|
|||
|
||||
// If vendor-reset is in the current modules
|
||||
if strings.Contains(line, "vendor-reset") {
|
||||
// Write to logger
|
||||
logger.Printf("vendor-reset module detected in %s\nMaking sure it will be loaded before vfio", sysfile)
|
||||
|
||||
// Add vendor-reset first
|
||||
modules = append([]string{"vendor-reset"}, modules...)
|
||||
}
|
||||
|
@ -54,6 +61,9 @@ func Set_Mkinitcpio() {
|
|||
}
|
||||
}
|
||||
|
||||
// Write to logger
|
||||
logger.Printf("Replacing line in %s:\n%s\nWith:\nMODULES=(%s)\n", config.Path.MKINITCPIO, line, strings.Join(modules, " "))
|
||||
|
||||
// Write the modules line we generated
|
||||
fileio.AppendContent(fmt.Sprintf("MODULES=(%s)\n", strings.Join(modules, " ")), config.Path.MKINITCPIO)
|
||||
} else {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/HikariKnight/quickpassthrough/internal/logger"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/fileio"
|
||||
)
|
||||
|
||||
|
@ -19,6 +20,8 @@ func Set_Modprobe(gpu_IDs []string) {
|
|||
vfio_pci_options = append(vfio_pci_options, strings.Join(gpu_IDs, ","))
|
||||
|
||||
if strings.Contains(kernel_args, "vfio_pci.disable_vga=1") {
|
||||
// Write to logger
|
||||
logger.Printf("User has disabled vfio video output on host, adding disable_vga=1 to the optional hardcoded vfio_pci options")
|
||||
vfio_pci_options = append(vfio_pci_options, "disable_vga=1")
|
||||
}
|
||||
|
||||
|
@ -31,24 +34,29 @@ func Set_Modprobe(gpu_IDs []string) {
|
|||
os.Remove(conffile)
|
||||
}
|
||||
|
||||
content := fmt.Sprint(
|
||||
"## This is an autogenerated file that stubs your graphic card for use with vfio\n",
|
||||
"## This file should be placed inside /etc/modprobe.d/\n",
|
||||
"# Uncomment the line below to \"hardcode\" your graphic card to be bound to the vfio-pci driver.\n",
|
||||
"# In most cases this should not be neccessary, it will also prevent you from turning off vfio in the bootloader.\n",
|
||||
fmt.Sprintf(
|
||||
"#options vfio_pci ids=%s\n",
|
||||
strings.Join(vfio_pci_options, " "),
|
||||
),
|
||||
"\n",
|
||||
"# Make sure vfio_pci is loaded before these modules: nvidia, nouveau, amdgpu and radeon\n",
|
||||
"softdep nvidia pre: vfio vfio_pci\n",
|
||||
"softdep nouveau pre: vfio vfio_pci\n",
|
||||
"softdep amdgpu pre: vfio vfio_pci\n",
|
||||
"softdep radeon pre: vfio vfio_pci\n",
|
||||
)
|
||||
|
||||
// Write to logger
|
||||
logger.Printf("Writing %s:\n%s", conffile, content)
|
||||
|
||||
// Write the vfio.conf file to our modprobe config
|
||||
fileio.AppendContent(
|
||||
fmt.Sprint(
|
||||
"## This is an autogenerated file that stubs your graphic card for use with vfio\n",
|
||||
"## This file should be placed inside /etc/modprobe.d/\n",
|
||||
"# Uncomment the line below to \"hardcode\" your graphic card to be bound to the vfio-pci driver.\n",
|
||||
"# In most cases this should not be neccessary, it will also prevent you from turning off vfio in the bootloader.\n",
|
||||
fmt.Sprintf(
|
||||
"#options vfio_pci ids=%s\n",
|
||||
strings.Join(vfio_pci_options, " "),
|
||||
),
|
||||
"\n",
|
||||
"# Make sure vfio_pci is loaded before these modules: nvidia, nouveau, amdgpu and radeon\n",
|
||||
"softdep nvidia pre: vfio vfio_pci\n",
|
||||
"softdep nouveau pre: vfio vfio_pci\n",
|
||||
"softdep amdgpu pre: vfio vfio_pci\n",
|
||||
"softdep radeon pre: vfio vfio_pci\n",
|
||||
),
|
||||
content,
|
||||
conffile,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/HikariKnight/ls-iommu/pkg/errorcheck"
|
||||
"github.com/HikariKnight/quickpassthrough/internal/logger"
|
||||
)
|
||||
|
||||
func GenerateVBIOSDumper(vbios_path string) {
|
||||
|
@ -50,6 +51,7 @@ func GenerateVBIOSDumper(vbios_path string) {
|
|||
vbios_path,
|
||||
)
|
||||
|
||||
// Make the script file
|
||||
scriptfile, err := os.Create("utils/dump_vbios.sh")
|
||||
errorcheck.ErrorCheck(err, "Cannot create file \"utils/dump_vbios.sh\"")
|
||||
defer scriptfile.Close()
|
||||
|
@ -58,6 +60,9 @@ func GenerateVBIOSDumper(vbios_path string) {
|
|||
scriptfile.Chmod(0775)
|
||||
errorcheck.ErrorCheck(err, "Could not change permissions of \"utils/dump_vbios.sh\"")
|
||||
|
||||
// Write to logger
|
||||
logger.Printf("Writing utils/dump_vbios.sh")
|
||||
|
||||
// Write the script
|
||||
scriptfile.WriteString(vbios_script)
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package configs
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/HikariKnight/quickpassthrough/internal/logger"
|
||||
"github.com/HikariKnight/quickpassthrough/pkg/fileio"
|
||||
)
|
||||
|
||||
|
@ -10,6 +11,9 @@ func DisableVFIOVideo(i int) {
|
|||
// Get the config
|
||||
config := GetConfig()
|
||||
|
||||
// Write to logger
|
||||
logger.Printf("Adding vfio_pci.disable_vga=%v to %s", i, config.Path.CMDLINE)
|
||||
|
||||
// Add to the kernel arguments that we want to disable VFIO video output on the host
|
||||
fileio.AppendContent(
|
||||
fmt.Sprintf(
|
||||
|
|
|
@ -85,7 +85,12 @@ func InitConfigs() {
|
|||
// If the path exists
|
||||
if fileio.FileExist(syspath) {
|
||||
// Write to log
|
||||
logger.Printf("%s found on the system\nCreating %s", syspath, confpath)
|
||||
logger.Printf(
|
||||
"%s found on the system\n"+
|
||||
"Creating %s",
|
||||
syspath,
|
||||
confpath,
|
||||
)
|
||||
|
||||
// Create the directories for our configs
|
||||
err := os.MkdirAll(confpath, os.ModePerm)
|
||||
|
@ -108,7 +113,12 @@ func InitConfigs() {
|
|||
// If the file exists
|
||||
if fileio.FileExist(sysfile) {
|
||||
// Write to log
|
||||
logger.Printf("%s found on the system\nCreating %s", sysfile, conffile)
|
||||
logger.Printf(
|
||||
"%s found on the system\n"+
|
||||
"Creating %s",
|
||||
sysfile,
|
||||
conffile,
|
||||
)
|
||||
|
||||
// Create the directories for our configs
|
||||
file, err := os.Create(conffile)
|
||||
|
@ -119,6 +129,9 @@ func InitConfigs() {
|
|||
|
||||
// If we now have a config that exists
|
||||
if fileio.FileExist(conffile) {
|
||||
// Write to logger
|
||||
logger.Printf("Getting the header (if it is there) from %s", conffile)
|
||||
|
||||
switch conffile {
|
||||
case config.Path.ETCMODULES:
|
||||
// Read the header
|
||||
|
@ -151,6 +164,9 @@ func vfio_modules() []string {
|
|||
sysinfo := uname.New()
|
||||
kernel_re := regexp.MustCompile(`^(6\.1|6\.0|[1-5]\.)`)
|
||||
if kernel_re.MatchString(sysinfo.Kernel) {
|
||||
// Write to the debug log
|
||||
logger.Printf("Linux kernel version %s detected!\nIncluding vfio_virqfd module")
|
||||
|
||||
// Include the vfio_virqfd module
|
||||
// NOTE: this driver was merged into the vfio module in 6.2
|
||||
modules = append(modules, "vfio_virqfd")
|
||||
|
|
|
@ -10,11 +10,14 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/HikariKnight/ls-iommu/pkg/errorcheck"
|
||||
"github.com/HikariKnight/quickpassthrough/internal/logger"
|
||||
"github.com/charmbracelet/bubbles/list"
|
||||
)
|
||||
|
||||
func getIOMMU(args ...string) []string {
|
||||
var stdout, stderr bytes.Buffer
|
||||
// Write to logger
|
||||
logger.Printf("Executing: utils/ls-iommu %s", strings.Join(args, " "))
|
||||
|
||||
// Configure the ls-iommu command
|
||||
cmd := exec.Command("utils/ls-iommu", args...)
|
||||
|
@ -31,6 +34,9 @@ func getIOMMU(args ...string) []string {
|
|||
var items []string
|
||||
output, _ := io.ReadAll(&stdout)
|
||||
|
||||
// Write to logger
|
||||
logger.Printf("ls-iommu query returned\n%s", string(output))
|
||||
|
||||
// Parse the output line by line
|
||||
scanner := bufio.NewScanner(strings.NewReader(string(output)))
|
||||
for scanner.Scan() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue