aleph-im / aleph-vm

Aleph.im VM execution engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shutdown an instance properly

hoh opened this issue · comments

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

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)