diff --git a/cmd/root.go b/cmd/root.go index 8d172b4..015470b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -68,7 +68,7 @@ func init() { rootCmd.AddCommand(versionCmd) rootCmd.AddCommand(copyrightCmd) - rootCmd.PersistentFlags().BoolVar(&vmDebugFlag, "vm-debug", false, "Enables the VM debug mode. This will open an accessible VM monitor. You can log in with root user and no password.") + rootCmd.PersistentFlags().BoolVar(&vmDebugFlag, "vm-debug", false, "Enables the VM debug mode. This will open an accessible VM monitor and enable direct QEMU command log passthrough. You can log in with root user and no password.") rootCmd.PersistentFlags().BoolVar(&unrestrictedNetworkingFlag, "vm-unrestricted-networking", false, "Enables unrestricted networking. This will allow the VM to connect to the internet.") rootCmd.PersistentFlags().Uint32Var(&vmMemAllocFlag, "vm-mem-alloc", defaultMemAlloc, fmt.Sprintf("Specifies the VM memory allocation in KiB. (the default is %v in LUKS mode)", defaultMemAllocLUKS)) rootCmd.PersistentFlags().Uint32Var(&vmOSUpTimeoutFlag, "vm-os-up-timeout", 30, "Specifies the VM OS-up timeout in seconds.") diff --git a/cmd/utils.go b/cmd/utils.go index f69ca83..047c7f5 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -206,7 +206,7 @@ func runVM(passthroughArg string, fn runvm.Func, forwardPortsRules []vm.PortForw OSUpTimeout: time.Duration(vmOSUpTimeoutFlag) * time.Second, SSHUpTimeout: time.Duration(vmSSHSetupTimeoutFlag) * time.Second, - ShowDisplay: vmDebugFlag, + Debug: vmDebugFlag, } vi, err := vm.NewVM(slog.Default().With("caller", "vm"), vmCfg) diff --git a/imgbuilder/imgbuilder.go b/imgbuilder/imgbuilder.go index bbff592..bdb224d 100644 --- a/imgbuilder/imgbuilder.go +++ b/imgbuilder/imgbuilder.go @@ -43,7 +43,7 @@ type BuildContext struct { vi *vm.VM } -func NewBuildContext(logger *slog.Logger, baseISOPath string, outPath string, showVMDisplay bool, biosPath string) (*BuildContext, error) { +func NewBuildContext(logger *slog.Logger, baseISOPath string, outPath string, debug bool, biosPath string) (*BuildContext, error) { baseISOPath = filepath.Clean(baseISOPath) outPath = filepath.Clean(outPath) @@ -73,7 +73,7 @@ func NewBuildContext(logger *slog.Logger, baseISOPath string, outPath string, sh MemoryAlloc: 512, UnrestrictedNetworking: true, - ShowDisplay: showVMDisplay, + Debug: debug, InstallBaseUtilities: true, }) if err != nil { diff --git a/vm/cfg.go b/vm/cfg.go index 264e713..eddc618 100644 --- a/vm/cfg.go +++ b/vm/cfg.go @@ -115,7 +115,7 @@ func configureBaseVMCmd(logger *slog.Logger, cfg Config) (string, []qemucli.Arg, args = append(args, biosArg) } - if !cfg.ShowDisplay { + if !cfg.Debug { args = append(args, qemucli.MustNewStringArg("display", "none")) } diff --git a/vm/vm.go b/vm/vm.go index 8c9d74e..8705bc7 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -22,6 +22,7 @@ import ( "context" "fmt" "io" + "os" "os/exec" "sync" "sync/atomic" @@ -99,7 +100,7 @@ type Config struct { SSHUpTimeout time.Duration // Mostly debug-related options. - ShowDisplay bool + Debug bool // This will show the display and forward all QEMU warnings/errors to stderr. InstallBaseUtilities bool } @@ -176,6 +177,10 @@ func NewVM(logger *slog.Logger, cfg Config) (*VM, error) { stderrBuf := bytes.NewBuffer(nil) cmd.Stderr = stderrBuf + if cfg.Debug { + cmd.Stderr = io.MultiWriter(cmd.Stderr, os.Stderr) + } + // This function is OS-specific. osspecifics.SetNewProcessGroupCmd(cmd)