lima
lima copied to clipboard
Does lima support checkpoint backup and restore like normal virtual machine?
Discussed in https://github.com/lima-vm/lima/discussions/1050
Originally posted by f91og September 13, 2022 Just want to quick restore to a certain status after tried several things that caused develop environment broken
It should be possible to create something with the qemu savevm and loadvm commands:
Does qemu emulator have checkpoint function? - Stack Overflow]
Apparently these are missing from (older versions of ?) QMP, so might need be issued differently (monitor?).
https://github.com/digitalocean/go-qemu
https://lore.kernel.org/all/[email protected]/
savevm, loadvm and delvm are some of the few commands that have never been converted to use QMP. The primary reason for this lack of conversion is that they block execution of the thread for as long as they run.
It also hints at the workaround: (HumanMonitorCommand)
Despite this downside, however, libvirt and applications using libvirt has used these commands for as long as QMP has existed, via the "human-monitor-command" passthrough command. IOW, while it is clearly desirable to be able to fix the blocking problem, this is not an immediate obstacle to real world usage.
It seems to work OK, but it's not straight-forward how to list the existing snapshots... (i.e. need to remember the tag)
$ ~/qemu/scripts/qmp/qmp-shell -H ~/.lima/default/qmp.sock
Welcome to the HMP shell!
Connected to QEMU 4.2.1
(QEMU) savevm my-tag
(QEMU) loadvm my-tag
(QEMU)
Once the instance is offline, it is possible to list the existing snapshots: qemu-img snapshot -l ~/.lima/default/diffdisk
qemu-img: Could not open '/home/anders/.lima/default/diffdisk': Failed to get shared "write" lock
Is another process using the image [/home/anders/.lima/default/diffdisk]?
$ qemu-img snapshot -l ~/.lima/default/diffdisk
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 my-tag 1.11 GiB 2022-09-14 19:03:55 00:01:08.816
Beyond backup (savevm) and restore (loadvm), might want to add a third command for removing a snapshot (delvm) ?
As a workaround, it is also possible to do it with qemu-img snapshot -d my-tag ~/.lima/default/diffdisk outside of lima
Newer versions of qemu-img default to read-only images, which means that the command will work on running instances...
For older versions, it is possible to use the --force-share flag with the snapshot -l command (it should still be safe)
Now a single command, with sub-commands:
Usage:
limactl snapshot [command]
Available Commands:
apply Apply (load) a snapshot
create Create (save) a snapshot
delete Delete (del) a snapshot
list List existing snapshots