fctools/
lib.rs

1//! `fctools` is a highly modular and exhaustive SDK for developing high-performance asynchronous production applications that
2//! leverage the capabilities of Firecracker microVMs.
3//!
4//! Binary crates using fctools will need to enable a syscall backend. Libraries should not enable any syscall backend
5//! feature, and must instead expect binary crates to do so. The fctools crate without such a backend will compile but panic at runtime
6//! with the message "No syscall backend was enabled for fctools". Binary crate developers must choose either the "nix-syscall-backend" or
7//! the "rustix-syscall-backend" feature. If the latter is enabled, the former is ignored, as only one syscall backend can exist at a time.
8//! The two features use their two respective crates: "nix" or "rustix". As such, they are functionally equivalent, with the only
9//! difference being that "nix" uses C FFI to call into libc and perform syscalls, while "rustix" invokes syscalls directly without any FFI.
10//!
11//! By default, only the [runtime] module that provides traits for supporting any asynchronous runtime is enabled. Binary
12//! crates using `fctools` should usually pull in either a built-in implementation of a [Runtime](runtime::Runtime) via either
13//! the `tokio-runtime` or `smol-runtime` features, or install a third-party crate with its own implementation.
14//!
15//! The rest of the crate that provides actual functionality is structured in a vertical fashion, with each layer introducing more
16//! useful and high-level features than the one preceding it. There are 6 such layers, from lowest to highest level of abstraction:
17//!
18//! 1. The process spawner layer, enabled via the `process-spawner` feature. It provides functionality for invoking the microVM process.
19//! 2. The VMM core layer, enabled via the `vmm-core` feature. It provides basic facilities for managing a VMM.
20//! 3. The VMM executor layer, enabled via the `vmm-executor` feature. It provides an executor trait that handles a VMM's lifecycle, as
21//!    well as introducing handling of VMM ownership models.
22//! 4. The VMM process layer, enabled via the `vmm-process` feature. It provides a VMM process abstraction over an underlying executor,
23//!    introducing various useful features like making requests to the VMM's HTTP API server.
24//! 5. The VM layer, enabled via the `vm` feature. It provides a wide range of high-level and opinionated facilities that build on top of
25//!    a VMM process. These address concerns such as: high-level API server bindings, making snapshots, initializing VMs, shutting them
26//!    down in a graceful and controlled fashion with timeouts and so on.
27//! 6. The extension layer, enabled via various features ending with `-extension`. These small extensions, each typically spanning under
28//!    500 lines of code, provide various real-world utilities useful for a microVM-based application.
29//!
30//! Each higher layer is more opinionated and high-level than its predecessor, while offering more useful features. Depending on the needs
31//! of your application or library, you should decide which layers make sense for your use-case. Enabling the VM layer and all necessary
32//! extensions is usually a good start.
33
34#![cfg_attr(docsrs, feature(doc_cfg))]
35
36#[cfg(not(target_os = "linux"))]
37compile_error!("The Firecracker microVM manager does not support non-Linux operating systems");
38
39#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
40compile_error!("The Firecracker microVM manager does not support any CPU architectures other than x86_64 and aarch64");
41
42#[cfg(feature = "vmm-core")]
43#[cfg_attr(docsrs, doc(cfg(feature = "vmm-core")))]
44pub mod vmm;
45
46pub mod extension;
47
48pub mod runtime;
49
50#[cfg(feature = "process-spawner")]
51#[cfg_attr(docsrs, doc(cfg(feature = "process-spawner")))]
52pub mod process_spawner;
53
54#[cfg(feature = "vm")]
55#[cfg_attr(docsrs, doc(cfg(feature = "vm")))]
56pub mod vm;
57
58pub(crate) mod syscall;