lima-vm / lima

Linux virtual machines, with a focus on running containers
https://lima-vm.io/
Apache License 2.0
15.19k stars 596 forks source link

Implement suspend and resume of VM #598

Open afbjorklund opened 2 years ago

afbjorklund commented 2 years ago

Description

Seems like QMP has these nice commands:

stop Suspend execution of VM

cont Reverse a previous stop command - resume execution of VM.

https://en.wikibooks.org/wiki/QEMU/Monitor#Virtual_machine

Allows you to suspend and resume the VM, through qmp.sock:

Welcome to the QMP low-level shell!
Connected to QEMU 4.2.1
(QEMU) stop
{"return": {}}
(QEMU) cont
{"return": {}}
cfstras commented 1 month ago

This would be super awesome for people on the go - easily free up some battery capacity by suspending the docker VM. We could even detect "no containers running" and do it automatically at some point.

I see @afbjorklund has taken a stab at implementing this in https://github.com/lima-vm/lima/pull/642, is that something lima would consider merging today if brought up-to-date?

afbjorklund commented 4 weeks ago

I can rebase it, but the main issue was that Lima lacked a "reconnect" option to bring the ssh socket back to life again.

EDIT: Rebased the PR