firecracker-node
    Preparing search index...

    Class FirecrackerMicroVM

    Represents a firecracker microVM instance.

    • Before calling any API methods, ensure that the firecracker process is spawned using spawnFirecrackerProcess().
    • After finishing with the instance, call stopFirecrackerProcess() to clean up the process.

    This makes API calls for each configuration change. Use FirecrackerLauncher for easier microVM setup.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    firecrackerProcess?: ChildProcess

    The spawned Firecracker process.

    initParams: FirecrackerInitParams = DefaultFirecrackerInitParams

    Initialization parameters for the Firecracker process. Defaults are taken from DefaultFirecrackerInitParams.

    undiciClient: Client

    The Undici HTTP client configured to connect over the provided Unix socket.

    Methods

      • Does not attempt to parse response body.
      • Calls request() internally

      Parameters

      • options: RequestOptions
      • validStatusCodes: number[]

      Returns Promise<void>

    • Partially updates the Machine Configuration of the VM. Pre-boot only.

      • If any of the parameters has an incorrect value, the whole update fails.
      • Same as setMachineConfig, expect that this accepts partial updates. Kept for covering the firecracker API.

      Parameters

      Returns Promise<void>

      with the fault_message from the API

    • Makes a request to the API.

      • Assumes JSON request body.
      • Checks that the response status code is in the validStatusCodes array.
      • If not, throws an Error with the fault_message from the API error response.

      Parameters

      • options: RequestOptions

        the options for the request. Everything will work except the 'Content-Type' header, which is always set to 'application/json'.

      • validStatusCodes: number[]

        array of valid status codes for the response

      Returns Promise<ResponseData<null>>

      the response from the API

      with the fault_message from the API if the response status code is not valid

    • Updates the Machine Configuration of the VM. Pre-boot only.

      • Firecracker starts with default values for vCPU count (=1) and memory size (=128 MiB).
      • The vCPU count is restricted to the [1, 32] range.
      • With SMT enabled, the vCPU count is required to be either 1 or an even number in the range. otherwise there are no restrictions regarding the vCPU count.
      • If 2M hugetlbfs pages are specified, then mem_size_mib must be a multiple of 2.
      • If any of the parameters has an incorrect value, the whole update fails.
      • All parameters that are optional and are not specified are set to their default values (smt = false, track_dirty_pages = false, cpu_template = None, huge_pages = None).

      Parameters

      Returns Promise<void>

      with the fault_message from the API

    • Spawns a firecracker process

      • Does nothing if the process is already spawned.
      • Waits until the Firecracker API is ready to accept requests before returning.
      • If the API does not become ready within 5 seconds, throws an error.

      Parameters

      • removeExistingSocket: boolean

        whether to remove an existing socket file before starting the process. This is useful to ensure that a stale socket does not prevent the Firecracker process from starting.

      Returns Promise<void>

    • Kills the Firecracker process and waits for it to exit.

      • If the process is not running, does nothing.

      Returns Promise<void>