Overview
VMConfig is a Pydantic model that defines the configuration for creating a microVM. It specifies CPU, memory, kernel, rootfs, and other runtime settings.
Model Definition
Fields
str
default:"auto-generated"
Unique identifier for the VM. Must be lowercase alphanumeric with hyphens or underscores, matching the pattern
^[a-z0-9][a-z0-9_-]{0,62}[a-z0-9]$ or a single character ^[a-z0-9]$.If omitted or explicitly set to None, Celesto auto-generates an ID in the format vm-<8-char-hex> (for example, vm-a1b2c3d4).int
default:"2"
Number of virtual CPUs. Valid range: 1-32.
int
default:"512"
Memory size in MiB (mebibytes). Valid range: 128-16384.
GuestOS
default:"GuestOS.ALPINE"
The operating system running inside the VM. Used by Celesto to pick the right
QEMU machine type, firmware, and device topology.Valid values:
GuestOS.ALPINE— Alpine Linux (default).GuestOS.UBUNTU— Ubuntu Linux.GuestOS.WINDOWS— Windows 11. Requiresboot_mode="firmware"andbackend="qemu", and only runs on Linux hosts. See Windows guests.
Literal['direct_kernel', 'firmware']
default:"direct_kernel"
How the VM boots:
"direct_kernel"— Boot a Linux kernel directly. Requireskernel_path. Used by every Linux sandbox."firmware"— Boot through UEFI firmware reading the disk’s own boot manager. Required for Windows guests.kernel_pathmust beNone.
Path | None
required
Path to the kernel image file. The path must exist and point to a valid file. Set to
None (and omitted) when boot_mode="firmware".Path
required
Path to the root filesystem image. The path must exist and point to a valid file.
Literal["raw-ext4", "qcow2"] | None
default:"None"
Declared format of
rootfs_path. New configs should set this explicitly:"raw-ext4"— a raw ext4 filesystem image (the default forImageBuilderandDockerRootfsBuilder)."qcow2"— a QEMU qcow2 disk image (used by Ubuntu and Windows cloud images).
.qcow2 ⇒ qcow2, anything else ⇒ raw-ext4). Setting this correctly matters because Celesto uses it to pick the right QEMU drive format, backing-file format, and disk-resize strategy.str
default:"console=ttyS0 reboot=k panic=1 pci=off"
Kernel boot arguments. For SSH-capable VMs built with ImageBuilder, include
init=/init.str | None
default:"None"
Runtime backend override. Valid options:
"firecracker": Use Firecracker VMM"qemu": Use QEMU"libkrun": Accepted by the source API, with limited public documentationNoneor"auto": Auto-detect based on host capabilities
Literal['slirp', 'tap']
default:"slirp"
How the QEMU backend connects the guest to the network. Ignored when
backend="firecracker" (Firecracker always uses a host TAP device)."slirp"— Userspace NAT with host port forwards. It needs no administrator setup, works on macOS and Linux, and supportsopenandoffinternet modes. This is the default."tap"— Give the guest a private IP through a host TAP device. On Linux this supportsopen,off, and IPv4restrictedmodes, plus host access by guest IP orexpose_local(). It requiresip,nft, and sudo; see network configuration.
InternetSettings | None
default:"None"
Outbound access policy. Open access is the default. QEMU supports off mode with
qemu_network="slirp" on macOS and Linux; restricted IPv4 destinations require qemu_network="tap" on Linux. See Network controls.Literal['isolated', 'shared']
default:"isolated"
Disk lifecycle mode:
"isolated": Clone rootfs per VM for sandbox isolation. Each VM gets its own copy."shared": Boot directly fromrootfs_path. Multiple VMs can share the same disk image.
int | None
default:"None"
Target size in MiB for the per-VM disk. Celesto only grows the disk — pick a value at least as large as the current rootfs size, otherwise creation fails with a clear error. Requires
disk_mode="isolated"; shared base images are never resized. Works for both raw-ext4 and qcow2 rootfs formats.bool
default:"False"
Grow the guest filesystem to fill the resized disk during VM creation. Only supported for
rootfs_format="raw-ext4" images and requires e2fsprogs (e2fsck, resize2fs) on the host. For qcow2 images, leave this False and grow the partition or filesystem from inside the guest instead.bool
default:"False"
Whether to keep the isolated VM disk after deletion. When
True, a later create operation with the same VM ID can reuse prior disk state.Only applies when disk_mode="isolated".dict[str, str]
default:"{}"
Environment variables to inject into the guest after boot via SSH. Keys must be valid shell identifiers (matching
^[a-zA-Z_][a-zA-Z0-9_]*$).Variables are persisted in /etc/profile.d/smolvm_env.sh and affect new SSH sessions/login shells.Requires an SSH-capable image (boot args must contain init=/init).int | None
default:"None"
Optional network bandwidth limit in megabits per second. When set, Celesto caps the guest’s outbound traffic to this rate. Must be at least 1.
list[PortForwardConfig]
default:"[]"
Host-to-guest TCP port forwards configured at VM launch. This setting is supported by QEMU
slirp; TAP applications use their guest IP or expose_local(). Each entry maps a host_port to a guest_port. Host and guest ports must be unique within the list.list[Path]
default:"[]"
Additional block-device image paths to attach at boot. Each path must exist and point to a valid file.
Validation Rules
Path Validation
Bothkernel_path and rootfs_path are validated to ensure:
- The path exists on the filesystem
- The path points to a file (not a directory)
Environment Variable Validation
All keys inenv_vars must be valid shell identifiers:
- Start with a letter or underscore
- Contain only letters, numbers, and underscores
- Pattern:
^[a-zA-Z_][a-zA-Z0-9_]*$
ValidationError during model instantiation.
VM ID Validation
Thevm_id must:
- Be lowercase
- Start and end with alphanumeric characters
- Contain only lowercase letters, numbers, hyphens, and underscores
- Be 1-64 characters long
Usage Examples
Basic Configuration
Custom VM ID and Resources
SSH-Capable VM with Environment Variables
Shared Disk Mode
Persistent Isolated Disk
Windows guest
Boot a pre-installed Windows 11 image. Requiresboot_mode="firmware" and the QEMU backend; Celesto enforces both invariants.
Celesto(os="windows", image=...). Celesto handles the QEMU firmware settings and per-VM qcow2 disk setup for you.
QEMU Backend
Immutability
VMConfig instances are frozen and cannot be modified after creation:Integration with Celesto
Pass VMConfig to the Celesto constructor:Building Images for VMConfig
UseImageBuilder to create kernel and rootfs images:
