diff --git a/proxmox/nodes/vms/vms.go b/proxmox/nodes/vms/vms.go index 4bec31a6..38f86977 100644 --- a/proxmox/nodes/vms/vms.go +++ b/proxmox/nodes/vms/vms.go @@ -334,7 +334,7 @@ func (c *Client) ShutdownVMAsync(ctx context.Context, d *ShutdownRequestBody) (* // StartVM starts a virtual machine. // Returns the task log if the VM had warnings at startup, or fails to start. func (c *Client) StartVM(ctx context.Context, timeout int) ([]string, error) { - taskID, err := c.StartVMAsync(ctx) + taskID, err := c.StartVMAsync(ctx, timeout) if err != nil { return nil, err } @@ -362,10 +362,13 @@ func (c *Client) StartVM(ctx context.Context, timeout int) ([]string, error) { } // StartVMAsync starts a virtual machine asynchronously. -func (c *Client) StartVMAsync(ctx context.Context) (*string, error) { +func (c *Client) StartVMAsync(ctx context.Context, timeout int) (*string, error) { + reqBody := &StartRequestBody{ + TimeoutSeconds: &timeout, + } resBody := &StartResponseBody{} - err := c.DoRequest(ctx, http.MethodPost, c.ExpandPath("status/start"), nil, resBody) + err := c.DoRequest(ctx, http.MethodPost, c.ExpandPath("status/start"), reqBody, resBody) if err != nil { return nil, fmt.Errorf("error starting VM: %w", err) } diff --git a/proxmox/nodes/vms/vms_types.go b/proxmox/nodes/vms/vms_types.go index 89aaae9a..0cb7148d 100644 --- a/proxmox/nodes/vms/vms_types.go +++ b/proxmox/nodes/vms/vms_types.go @@ -699,6 +699,19 @@ type ShutdownResponseBody struct { Data *string `json:"data,omitempty"` } +// StartRequestBody contains the body for a VM start request. +type StartRequestBody struct { + ForceCPU *string `json:"force-cpu,omitempty" url:"force-cpu,omitempty"` + Machine *string `json:"machine,omitempty" url:"machine,omitempty"` + MigrateFrom *string `json:"migratefrom,omitempty" url:"migratefrom,omitempty"` + MigrationNetwork *string `json:"migration_network,omitempty" url:"migration_network,omitempty"` + MigrationType *string `json:"migration_type,omitempty" url:"migration_type,omitempty"` + SkipLock *types.CustomBool `json:"skipLock,omitempty" url:"skipLock,omitempty,int"` + StateURI *string `json:"stateuri,omitempty" url:"stateuri,omitempty"` + TargetStorage *string `json:"targetstorage,omitempty" url:"targetstorage,omitempty"` + TimeoutSeconds *int `json:"timeout,omitempty" url:"timeout,omitempty"` +} + // StartResponseBody contains the body from a VM start response. type StartResponseBody struct { Data *string `json:"data,omitempty"`