diff --git a/pkg/compute/guestdrivers/kvm.go b/pkg/compute/guestdrivers/kvm.go index d777f19843..3541098108 100644 --- a/pkg/compute/guestdrivers/kvm.go +++ b/pkg/compute/guestdrivers/kvm.go @@ -277,7 +277,7 @@ func (self *SKVMGuestDriver) GetChangeConfigStatus() ([]string, error) { } func (self *SKVMGuestDriver) GetDeployStatus() ([]string, error) { - return []string{models.VM_READY}, nil + return []string{models.VM_READY, models.VM_RUNNING, models.VM_ADMIN}, nil } func (self *SKVMGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error { diff --git a/pkg/compute/models/guest_actions.go b/pkg/compute/models/guest_actions.go index 19f0397e3e..011e28c134 100644 --- a/pkg/compute/models/guest_actions.go +++ b/pkg/compute/models/guest_actions.go @@ -98,7 +98,7 @@ func (self *SGuest) PerformSaveImage(ctx context.Context, userCred mcclient.Toke return nil, httperrors.NewInputParameterError("No root image") } else { kwargs := data.(*jsonutils.JSONDict) - restart := self.Status == VM_RUNNING + restart := (self.Status == VM_RUNNING) || jsonutils.QueryBoolean(data, "auto_start", false) properties := jsonutils.NewDict() if notes, err := data.GetString("notes"); err != nil && len(notes) > 0 { properties.Add(jsonutils.NewString(notes), "notes") @@ -347,7 +347,8 @@ func (self *SGuest) PerformDeploy(ctx context.Context, userCred mcclient.TokenCr } if utils.IsInStringArray(self.Status, deployStatus) { - if doRestart && self.Status == VM_RUNNING { + if (doRestart && self.Status == VM_RUNNING) || + jsonutils.QueryBoolean(kwargs, "auto_start", false) { kwargs.Set("restart", jsonutils.JSONTrue) } err := self.StartGuestDeployTask(ctx, userCred, kwargs, "deploy", "")