From c744d724dc5832ab9eebb9b857b66e0995c45c80 Mon Sep 17 00:00:00 2001 From: Fedor Korotkov Date: Tue, 28 Oct 2025 21:01:46 -0700 Subject: [PATCH] Added suspendable field --- api/openapi.yaml | 4 ++++ internal/command/create/vm.go | 3 +++ internal/command/get/vm.go | 1 + internal/worker/vmmanager/vm.go | 3 +++ pkg/resource/v1/v1.go | 1 + 5 files changed, 12 insertions(+) diff --git a/api/openapi.yaml b/api/openapi.yaml index 64c9b97..17bc97a 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -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 diff --git a/internal/command/create/vm.go b/internal/command/create/vm.go index 49eff4e..919bb03 100644 --- a/internal/command/create/vm.go +++ b/internal/command/create/vm.go @@ -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, diff --git a/internal/command/get/vm.go b/internal/command/get/vm.go index b9243f7..aa287ee 100644 --- a/internal/command/get/vm.go +++ b/internal/command/get/vm.go @@ -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)) diff --git a/internal/worker/vmmanager/vm.go b/internal/worker/vmmanager/vm.go index e0b936b..0f1aa15 100644 --- a/internal/worker/vmmanager/vm.go +++ b/internal/worker/vmmanager/vm.go @@ -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())) diff --git a/pkg/resource/v1/v1.go b/pkg/resource/v1/v1.go index b8b43b4..0c80eb3 100644 --- a/pkg/resource/v1/v1.go +++ b/pkg/resource/v1/v1.go @@ -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"`