Added suspendable field

This commit is contained in:
Fedor Korotkov 2025-10-28 21:01:46 -07:00
parent 00d27d1fa0
commit c744d724dc
5 changed files with 12 additions and 0 deletions

View File

@ -517,6 +517,10 @@ components:
type: boolean
description: Enable nested virtualization
default: false
suspendable:
type: boolean
description: Whether to allow suspending the VM via `tart run --suspendable`
default: false
status:
type: string
description: VM status

View File

@ -25,6 +25,7 @@ var netSoftnetBlock []string
var netBridged string
var headless bool
var nested bool
var suspendable bool
var username string
var password string
var resources map[string]string
@ -58,6 +59,7 @@ func newCreateVMCommand() *cobra.Command {
command.Flags().StringVar(&netBridged, "net-bridged", "", "whether to use Bridged network mode")
command.Flags().BoolVar(&headless, "headless", true, "whether to run without graphics")
command.Flags().BoolVar(&nested, "nested", false, "enable nested virtualization")
command.Flags().BoolVar(&suspendable, "suspendable", false, "whether to allow suspending the VM")
command.Flags().StringVar(&username, "username", "admin",
"SSH username to use when executing a startup script on the VM")
command.Flags().StringVar(&password, "password", "admin",
@ -120,6 +122,7 @@ func runCreateVM(cmd *cobra.Command, args []string) error {
NetBridged: netBridged,
Headless: headless,
Nested: nested,
Suspendable: suspendable,
Username: username,
Password: password,
RandomSerial: randomSerial,

View File

@ -98,6 +98,7 @@ func runGetVM(cmd *cobra.Command, args []string) error {
table.AddRow("Bridged networking interface", nonEmptyOrNone(vm.NetBridged))
table.AddRow("Headless mode", vm.Headless)
table.AddRow("Nested virtualization", vm.Nested)
table.AddRow("Suspendable", vm.Suspendable)
table.AddRow("Status", vm.Status)
table.AddRow("Status message", vm.StatusMessage)
table.AddRow("Assigned worker", nonEmptyOrNone(vm.Worker))

View File

@ -356,6 +356,9 @@ func (vm *VM) run(ctx context.Context) error {
if vm.Resource.Nested {
runArgs = append(runArgs, "--nested")
}
if vm.Resource.Suspendable {
runArgs = append(runArgs, "--suspendable")
}
for _, hostDir := range vm.Resource.HostDirs {
runArgs = append(runArgs, fmt.Sprintf("--dir=%s", hostDir.String()))

View File

@ -34,6 +34,7 @@ type VM struct {
NetBridged string `json:"net-bridged,omitempty"`
Headless bool `json:"headless,omitempty"`
Nested bool `json:"nested,omitempty"`
Suspendable bool `json:"suspendable,omitempty"`
// Status field is used to track the lifecycle of the VM associated with this resource.
Status VMStatus `json:"status,omitempty"`