Skip to content

vz: implement auto save/restore #2900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/store/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type Instance struct {
// Hostname, not HostName (corresponds to SSH's naming convention)
Hostname string `json:"hostname"`
Status Status `json:"status"`
Saved bool `json:"saved"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can document here what saved mean?

Dir string `json:"dir"`
VMType limayaml.VMType `json:"vmType"`
Arch limayaml.Arch `json:"arch"`
Expand Down Expand Up @@ -147,6 +148,14 @@ func Inspect(instName string) (*Instance, error) {
}

inspectStatus(instDir, inst, y)
_, err = os.Stat(filepath.Join(instDir, filenames.VzMachineState))
if err == nil {
inst.Saved = true
} else if errors.Is(err, os.ErrNotExist) {
inst.Saved = false
} else {
inst.Errors = append(inst.Errors, fmt.Errorf("cannot determine whether the instance is saved: %w", err))
}

tmpl, err := template.New("format").Parse(y.Message)
if err != nil {
Expand Down