From a6fddcd683ed521742cd8c84753e89100afa4930 Mon Sep 17 00:00:00 2001 From: HikariKnight <2557889+HikariKnight@users.noreply.github.com> Date: Sun, 9 Apr 2023 20:47:47 +0200 Subject: [PATCH] Make sure we always start with a new file --- internal/configs/config_dracut.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/configs/config_dracut.go b/internal/configs/config_dracut.go index 1c145d2..52a6507 100644 --- a/internal/configs/config_dracut.go +++ b/internal/configs/config_dracut.go @@ -2,6 +2,7 @@ package configs import ( "fmt" + "os" "strings" "github.com/HikariKnight/quickpassthrough/pkg/fileio" @@ -10,8 +11,16 @@ import ( func Set_Dracut() { config := GetConfig() + // Set the dracut config file + dracutConf := fmt.Sprintf("%s/vfio.conf", config.Path.DRACUT) + + // If the file already exists then delete it + if fileio.FileExist(dracutConf) { + os.Remove(dracutConf) + } + // Write the dracut config file - fileio.AppendContent(fmt.Sprintf("add_drivers+=\" %s \"\n", strings.Join(vfio_modules(), " ")), fmt.Sprintf("%s/vfio.conf", config.Path.DRACUT)) + fileio.AppendContent(fmt.Sprintf("add_drivers+=\" %s \"\n", strings.Join(vfio_modules(), " ")), dracutConf) // Add to our kernel arguments file that vfio_pci should load early (dracut does this using kernel arguments) fileio.AppendContent(" rd.driver.pre=vfio_pci", config.Path.CMDLINE)