Local libvirt/KVM sandbox VM manager for coding agents (Ubuntu 24.04 cloud-image, SSH, optional virtiofs share, optional nftables isolation).
Project description
Read the Docs |
|
Pypi |
A small Python CLI to create and manage a local libvirt/KVM Ubuntu 24.04 VM designed for running coding agents with a stronger boundary than containers.
What it provides
Dedicated libvirt NAT network per aivm configuration
Optional host firewall isolation via nftables
Ubuntu cloud-image VM provisioning via cloud-init
SSH + VS Code Remote-SSH workflows
Optional virtiofs folder sharing (explicit trust extension)
Optional settings sync into the guest user profile
A single config store for defaults, VMs, networks, and attachments
Install
uv pip install .
Fast Start
Recommended for new repos:
Currently aivm config init is required, but we will make that implicit in a future version.
aivm code .
aivm status
aivm status --sudo # optional deeper privileged checks
aivm code . auto-selects/bootstraps VM context from the global config store (~/.config/aivm/config.toml), attaches the current folder if needed, and opens VS Code.
If you prefer an explicit flow, aivm config init is required before aivm vm create.
See also:
Status and sudo behavior
By default, aivm status avoids privileged probes. Use --sudo for network/firewall/libvirt/image checks.
Sudo policy defaults:
read-only sudo probes (inspect/query/status) are auto-approved
state-changing sudo actions still prompt unless --yes/--yes-sudo is set
Use:
--yes to auto-approve all prompts
--yes-sudo to auto-approve only sudo prompts
Config defaults:
[behavior]
yes_sudo = false
auto_approve_readonly_sudo = true # set false for strict "prompt every sudo" mode
Common Workflows
VS Code and SSH
aivm vm ssh_config
aivm code . --sync_settings
aivm vm code --host_src . --sync_settings
aivm vm code . --sync_settings
aivm vm ssh .
Folder attachment
aivm attach .
aivm detach .
aivm vm attach --vm aivm-2404 --host_src .
aivm attach . --mode git
Attachment modes:
shared-root (default for new attachments): one VM-level virtiofs mapping exports /var/lib/libvirt/aivm/<vm>/shared-root; each attached folder is bind-mounted under that root on host and then bind-mounted to guest_dst in guest.
shared: direct per-folder virtiofs mapping from host source to guest. This is simpler but consumes one VM virtiofs device slot per folder.
git: guest-local Git clone, synced via host/guest remotes.
In shared and shared-root modes, attached folders mount to the same absolute path inside the guest by default. In git mode, default guest paths are placed under /home/<vm-user>/... so Git sync can run without guest root privileges. Use --guest_dst to override in any mode. Running VMs are live-attached when possible. aivm code and aivm ssh remount the selected folder and best-effort restore other folders already saved for that VM after guest startup.
Config-store lifecycle (explicit flow)
aivm config init
aivm vm create
aivm vm sync_settings
aivm vm update
aivm config discover
aivm config show
aivm config edit
aivm help plan
aivm help tree
aivm help completion
aivm host doctor
Settings sync configuration
[sync]
enabled = true
overwrite = true
paths = [
"~/.gitconfig",
"~/.gitignore",
"~/.config/Code/User/settings.json",
"~/.config/Code/User/keybindings.json",
"~/.tmux.conf",
"~/.bashrc",
]
Ad hoc override:
aivm vm sync-settings \
--paths "~/.gitconfig,~/.config/Code/User/settings.json,~/.tmux.conf"
When [sync].enabled=true, aivm vm code ... syncs before launching VS Code.
Command Groups
aivm config --help
aivm host --help
aivm host image_fetch --help
aivm help --help
aivm host net --help
aivm host fw --help
aivm vm --help
Safety Notes
This tool assumes Linux + libvirt. It focuses on Debian/Ubuntu hosts for dependency installation.
Security model and threat model details: the Security Model.
NAT alone does not prevent VM -> LAN. Enable firewall isolation if you want “internet-only” access.
To allow specific VM->host or VM->blocked-LAN service ports while firewall isolation is enabled, set [firewall].allow_tcp_ports / allow_udp_ports in config (for example allow_tcp_ports = [22, 5432]).
virtiofs sharing is optional; it’s powerful, but it intentionally exposes that host directory to the VM.
aivm vm code requires VS Code’s code CLI and the Remote - SSH extension.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aivm-0.3.0.tar.gz.
File metadata
- Download URL: aivm-0.3.0.tar.gz
- Upload date:
- Size: 112.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a200652bc0e0b44b1168824a4e4039a3c71150947f2b398e5708aed98089e67c
|
|
| MD5 |
5d35c99b33c30a0f3b4200b0c94e117c
|
|
| BLAKE2b-256 |
1142a4346bb53a06c4050449fb8f6b04c23dc61df74003d5e998f13564f124e3
|
File details
Details for the file aivm-0.3.0-py3-none-any.whl.
File metadata
- Download URL: aivm-0.3.0-py3-none-any.whl
- Upload date:
- Size: 88.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd91eec75c1a15f88189b484afbd626b3cd0f1a346415c1f2ddd8aeccd3854a3
|
|
| MD5 |
7f51167c532d02a0d804877352f7bf2d
|
|
| BLAKE2b-256 |
085e90bbc2ed6cf9985272d9c72d7444794b3f5af02aa8453acac1079a34864f
|