Overview
VMConfig is a Pydantic model that defines the configuration for creating a microVM. It includes hardware specifications, filesystem paths, boot parameters, and runtime options.
Schema
Attributes
Unique identifier for the VM. Must be lowercase alphanumeric with hyphens, matching pattern:
^[a-z0-9][a-z0-9-]{0,62}[a-z0-9]$ or ^[a-z0-9]$.If omitted, SmolVM auto-generates one in the format vm-{uuid_hex[:8]}.Number of virtual CPUs. Valid range: 1-32.
Memory size in MiB. Valid range: 128-16384.
Path to the kernel image. Must exist and be a file.
Path to the root filesystem image. Must exist and be a file.
Kernel boot arguments. For SSH-capable VMs, include
init=/init.Optional runtime backend override:
"firecracker" or "qemu". If omitted, uses the manager’s default backend.Disk lifecycle mode:
"isolated"(default): clonerootfs_pathper VM for sandbox isolation"shared": boot directly fromrootfs_path(changes persist to source image)
Keep isolated VM disk after delete, so a later create with the same VM ID can reuse prior state. Only applies when
disk_mode="isolated".Environment variables to inject into the guest after boot via SSH. Keys must be valid shell identifiers (matching pattern
^[A-Za-z_][A-Za-z0-9_]*$).Requires an SSH-capable image with init=/init in boot_args.Validation
Path Validation
Bothkernel_path and rootfs_path are validated at creation time:
- Path must exist on the filesystem
- Path must be a file (not a directory)
Example Error
VM ID Validation
Thevm_id must match the pattern for valid identifiers:
- Lowercase letters, numbers, and hyphens only
- Must start and end with alphanumeric character
- 1-64 characters in length
Valid Examples
Invalid Examples
Environment Variable Validation
Environment variable keys are validated as shell identifiers:- Must start with letter or underscore
- Can contain letters, numbers, and underscores
- Case-sensitive
Example
Examples
Immutability
VMConfig is frozen (immutable) after creation. To modify a config, use model_copy() with updates: