Make sure we always start with a new file

This commit is contained in:
HikariKnight 2023-04-09 20:47:47 +02:00
parent e93d215669
commit a6fddcd683

View file

@ -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)