aleph-im / aleph-vm

Aleph.im VM execution engine
MIT License
43 stars 18 forks source link

Shutdown an instance properly #330

Open hoh opened 1 year ago

hoh commented 1 year ago

Program VMs are stopped using a custom message via the VSOCK connection to the custom init.

In the case of instances, this is not guaranteed to work as an agent is not required to run within the VM.

Firecracker provides a solution for x86 platforms: an action via the firecracker API that sends the Ctrl-Alt-Del command to the VM. This approach is not supported on arm64.

https://github.com/firecracker-microvm/firecracker/blob/main/docs/api_requests/actions.md#intel-and-amd-only-sendctrlaltdel

hoh commented 1 year ago

Base for development:

        connector = aiohttp.UnixConnector(path=unix_socket)
        headers = {
            "accept": "application/json",
            "Content-Type": "application/json"
        }
        async with aiohttp.ClientSession(connector=connector) as session:
            async with session.put(f"/actions", json={"action_type": "SendCtrlAltDel"}, headers=headers) as response:
                response.raise_for_status()
                data = await response.json()
                print(data)