lima icon indicating copy to clipboard operation
lima copied to clipboard

Implement the snapshot commands

Open afbjorklund opened this issue 3 years ago • 3 comments

For making qcow2 snapshots of the running virtual machine.

It is possible to make multiple snapshots, in the diffdisk.

Closes #1051


limactl start

limactl snapshot create default --tag snap

limactl snapshot list default

limactl snapshot apply default --tag snap

limactl stop

limactl snapshot delete default --tag snap

afbjorklund avatar Sep 15 '22 10:09 afbjorklund

This has similar problems to the pause commands, in that the ssh mux is not too happy about the restore ?

  • https://github.com/lima-vm/lima/pull/642

afbjorklund avatar Sep 15 '22 10:09 afbjorklund

Adding basic implementation of "del" and "list", will rewrite as per comments above.

$ _output/bin/limactl backup --tag tag alpine
INFO[0000] Sending HMP savevm command                   
$ _output/bin/limactl restore --list alpine
Snapshot list:
ID        TAG                     VM SIZE                DATE       VM CLOCK
1         tag                     274 MiB 2022-09-21 19:34:50   00:02:39.937
$ _output/bin/limactl backup --tag tag --rm alpine
INFO[0000] Sending HMP delvm command                    
$ _output/bin/limactl restore --list alpine
$ 

afbjorklund avatar Sep 21 '22 17:09 afbjorklund

Thanks, the CLI design looks good, could you update the docs and integration tests?

AkihiroSuda avatar Oct 03 '22 01:10 AkihiroSuda

Left to do is adding integration tests, for the limactl snapshot sub-commands.

afbjorklund avatar Oct 16 '22 10:10 afbjorklund

Some help with the integration tests for snapshots would be appreciated. 🙏

afbjorklund avatar Nov 03 '22 19:11 afbjorklund

Integration tests can be added like this https://github.com/lima-vm/lima/blob/4a4cc62749c1ad5d781054981dd1da19de1202bf/hack/test-example.sh#L24 https://github.com/lima-vm/lima/blob/4a4cc62749c1ad5d781054981dd1da19de1202bf/hack/test-example.sh#L240-L267

AkihiroSuda avatar Nov 09 '22 05:11 AkihiroSuda

Snapshot worked on default (and alpine, but failed on experimental/9p ?

TEST| [INFO] Testing online snapshots
time="2022-11-16T20:21:20Z" level=info msg="Sending HMP savevm command"
TEST| [INFO] snapshot list: expected=snap1 got=
Error: ERROR] snapshot list did not return expected value

Need to see if there is a better way to return errors, after running HMP/QMP...

afbjorklund avatar Nov 16 '22 20:11 afbjorklund

Now it is at least logging the real problem: "output: Error: Migration is disabled when VirtFS export path '/tmp/lima' is mounted in the guest using mount_tag 'mount1'\r\n"

So this means that snapshots won't work with 9p mounts, while the instance is still running.

EDIT: Disabled the online tests for 9p, still running offline tests.

Trimmed off the extra whitespace, from the output.

afbjorklund avatar Nov 18 '22 12:11 afbjorklund

Could you rebase to rerun the CI?

AkihiroSuda avatar Jan 23 '23 02:01 AkihiroSuda

It would be nice, if the generated command help stayed out of the README....

afbjorklund avatar Feb 11 '23 08:02 afbjorklund

Sorry needs rebase again

AkihiroSuda avatar May 04 '23 11:05 AkihiroSuda

CI failing

+ set +x
TEST| [INFO] Testing online snapshots
time="2023-05-09T05:21:18Z" level=info msg="Sending HMP savevm command"
time="2023-05-09T05:21:26Z" level=info msg="Sending HMP info command"
TEST| [INFO] snapshot list: expected=snap1 got=snap1
time="2023-05-09T05:21:26Z" level=info msg="Sending HMP loadvm command"

Timed out!

AkihiroSuda avatar May 09 '23 06:05 AkihiroSuda

CI for experimental/net-user-v2.yaml seems consistenly failing

AkihiroSuda avatar May 11 '23 06:05 AkihiroSuda

CI for experimental/net-user-v2.yaml seems consistenly failing

Looks like the net-user-v2 does not survive an "online" VM restore.

So it needs to be excluded.

"net-user-v2")
        CHECKS["port-forwards"]=""
        CHECKS["user-v2"]=1
        ;;

It already was, for 9p.

"9p")
        CHECKS["snapshot-online"]=""
        ;;

afbjorklund avatar May 18 '23 07:05 afbjorklund