VM boot & setup timeouts

This commit is contained in:
AlexSSD7 2023-08-29 11:51:06 +01:00
commit 970664429a
6 changed files with 89 additions and 19 deletions

View file

@ -53,6 +53,7 @@ func NewBuildContext(logger *slog.Logger, baseISOPath string, outPath string, sh
Drives: []vm.DriveConfig{{
Path: outPath,
}},
MemoryAlloc: 512,
UnrestrictedNetworking: true,
ShowDisplay: showVMDisplay,
InstallBaseUtilities: true,

View file

@ -26,7 +26,9 @@ func Execute() {
var vmDebugFlag bool
var unrestrictedNetworkingFlag bool
var vmMemAllocFlag uint64
var vmMemAllocFlag uint32
var vmSSHSetupTimeoutFlag uint32
var vmOSUpTimeoutFlag uint32
// TODO: Version command.
@ -39,5 +41,7 @@ func init() {
rootCmd.PersistentFlags().BoolVar(&vmDebugFlag, "vmdebug", 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(&unrestrictedNetworkingFlag, "unrestricted-networking", false, "Enables unrestricted networking. This will allow the VM to connect to the internet.")
rootCmd.PersistentFlags().Uint64Var(&vmMemAllocFlag, "vm-mem-alloc", 512, "Specifies the VM memory allocation in KiB")
rootCmd.PersistentFlags().Uint32Var(&vmMemAllocFlag, "vm-mem-alloc", 512, "Specifies the VM memory allocation in KiB")
rootCmd.PersistentFlags().Uint32Var(&vmOSUpTimeoutFlag, "vm-os-up-timeout", 30, "Specifies the VM OS-up timeout in seconds.")
rootCmd.PersistentFlags().Uint32Var(&vmSSHSetupTimeoutFlag, "vm-ssh-setup-timeout", 60, "Specifies the VM SSH server setup timeout in seconds. This cannot be lower than the OS-up timeout.")
}

View file

@ -10,6 +10,7 @@ import (
"runtime"
"sync"
"syscall"
"time"
"log/slog"
@ -69,6 +70,9 @@ func runVM(passthroughArg string, fn func(context.Context, *vm.VM, *vm.FileManag
USBDevices: passthroughConfig,
ExtraPortForwardingRules: forwardPortsRules,
OSUpTimeout: time.Duration(vmOSUpTimeoutFlag) * time.Second,
SSHUpTimeout: time.Duration(vmSSHSetupTimeoutFlag) * time.Second,
UnrestrictedNetworking: unrestrictedNetworking,
ShowDisplay: vmDebugFlag,
}