···11+# vmx
22+33+A powerful command-line tool and HTTP API for managing and running headless virtual machines using QEMU. Built with Deno and TypeScript, vmx provides a Docker-like experience for VM management with OCI registry support.
44+55+## Features
66+77+### 🚀 Core Functionality
88+99+- **Headless VM Management** - Run VMs in the background without GUI overhead
1010+- **QEMU Integration** - Leverages QEMU for robust virtualization on both x86_64 and ARM64 architectures
1111+- **Docker-like CLI** - Familiar commands for VM lifecycle management (run, start, stop, ps, rm, etc.)
1212+- **Configuration Files** - TOML-based configuration for reproducible VM setups
1313+- **Multiple Input Sources** - Boot from local ISOs, remote URLs, or OCI registry images
1414+1515+### 📦 OCI Registry Support
1616+1717+- **Pull & Push** - Store and retrieve VM images from OCI-compliant registries (GitHub Container Registry, Docker Hub, etc.)
1818+- **Image Management** - List, tag, and remove local VM images
1919+- **Authentication** - Secure login/logout for private registries
2020+- **Cross-platform** - Automatic architecture detection and handling (amd64/arm64)
2121+2222+### 🌐 Networking
2323+2424+- **Bridge Networking** - Create and manage network bridges for VM connectivity
2525+- **Port Forwarding** - Easy SSH and service access with flexible port mapping
2626+- **Multiple Network Modes** - Support for various QEMU networking configurations
2727+2828+### 💾 Storage & Volumes
2929+3030+- **Volume Management** - Create, list, inspect, and delete persistent volumes
3131+- **Multiple Disk Formats** - Support for qcow2 and raw disk images
3232+- **Automatic Provisioning** - Volumes are created automatically from base images
3333+- **Flexible Sizing** - Configurable disk sizes for different workloads
3434+3535+### 🔧 Advanced Features
3636+3737+- **Detached Mode** - Run VMs in the background as daemon processes
3838+- **Live Logs** - Stream VM output and follow logs in real-time
3939+- **VM Inspection** - Detailed information about running and stopped VMs
4040+- **Resource Configuration** - Customizable CPU, memory, and disk settings
4141+- **ARM64 & x86_64 Support** - Native support for both architectures with UEFI firmware
4242+4343+### 🌍 HTTP API
4444+4545+- **RESTful API** - Full-featured HTTP API for programmatic VM management
4646+- **Bearer Authentication** - Secure API access with token-based auth
4747+- **Machines Endpoint** - Create, start, stop, restart, and remove VMs via API
4848+- **Images Endpoint** - List and query VM images
4949+- **Volumes Endpoint** - Manage persistent storage volumes
5050+- **CORS Support** - Cross-origin requests for web-based tools
5151+5252+## Installation
5353+5454+```bash
5555+# Install with Deno
5656+deno install -A -n vmx jsr:@tsiry/vmx
5757+5858+```
5959+6060+### Requirements
6161+6262+- [Deno](https://deno.com) runtime
6363+- [QEMU](https://www.qemu.org/) installed on your system
6464+ - macOS: `brew install qemu`
6565+ - Linux: `apt-get install qemu-system` or `yum install qemu-kvm`
6666+6767+## Quick Start
6868+6969+### Initialize Configuration
7070+7171+Create a default VM configuration file:
7272+7373+```bash
7474+vmx init
7575+```
7676+7777+This creates a `vmconfig.toml` file with sensible defaults.
7878+7979+### Run a VM from ISO
8080+8181+```bash
8282+# From a local ISO file
8383+vmx /path/to/ubuntu.iso
8484+8585+# Download and run from URL
8686+vmx https://cdimage.ubuntu.com/releases/24.04/release/ubuntu-24.04.3-live-server-arm64.iso
8787+8888+# From OCI registry
8989+vmx ghcr.io/tsirysndr/ubuntu:24.04
9090+```
9191+9292+### Pull and Run from Registry
9393+9494+```bash
9595+# Pull an image
9696+vmx pull ghcr.io/tsirysndr/ubuntu:24.04
9797+9898+# Run the image
9999+vmx run ghcr.io/tsirysndr/ubuntu:24.04
100100+101101+# Run with custom resources
102102+vmx run ghcr.io/tsirysndr/ubuntu:24.04 -m 4G -C 4 -d
103103+```
104104+105105+## Usage
106106+107107+### VM Lifecycle Management
108108+109109+```bash
110110+# List running VMs
111111+vmx ps
112112+113113+# List all VMs (including stopped)
114114+vmx ps --all
115115+116116+# Start a VM
117117+vmx start my-vm
118118+119119+# Stop a VM
120120+vmx stop my-vm
121121+122122+# Restart a VM
123123+vmx restart my-vm
124124+125125+# Remove a VM
126126+vmx rm my-vm
127127+128128+# View VM logs
129129+vmx logs my-vm
130130+131131+# Follow logs in real-time
132132+vmx logs -f my-vm
133133+134134+# Inspect VM details
135135+vmx inspect my-vm
136136+```
137137+138138+### Image Management
139139+140140+```bash
141141+# List local images
142142+vmx images
143143+144144+# Pull from registry
145145+vmx pull ghcr.io/tsirysndr/ubuntu:24.04
146146+147147+# Push to registry
148148+vmx push ghcr.io/tsirysndr/my-vm:latest
149149+150150+# Tag an image
151151+vmx tag my-vm ghcr.io/tsirysndr/my-vm:v1.0
152152+153153+# Remove an image
154154+vmx rmi ghcr.io/tsirysndr/ubuntu:24.04
155155+```
156156+157157+### Registry Authentication
158158+159159+```bash
160160+# Login to registry
161161+vmx login -u username ghcr.io
162162+163163+# Login with password from stdin
164164+echo "password" | vmx login -u username ghcr.io
165165+166166+# Logout
167167+vmx logout ghcr.io
168168+```
169169+170170+### Volume Management
171171+172172+```bash
173173+# List volumes
174174+vmx volumes
175175+176176+# Create and attach a volume to VM
177177+vmx run ubuntu:24.04 -v my-data
178178+179179+# Inspect a volume
180180+vmx volume inspect my-data
181181+182182+# Remove a volume
183183+vmx volume rm my-data
184184+```
185185+186186+### Advanced Options
187187+188188+```bash
189189+# Run with custom resources
190190+vmx run ubuntu:24.04 \
191191+ --cpu host \
192192+ --cpus 4 \
193193+ --memory 4G \
194194+ --detach
195195+196196+# With port forwarding (SSH on port 2222)
197197+vmx run ubuntu:24.04 -p 2222:22
198198+199199+# With bridge networking
200200+vmx run ubuntu:24.04 --bridge br0
201201+202202+# With persistent disk
203203+vmx run ubuntu:24.04 \
204204+ --image /path/to/disk.img \
205205+ --size 40G \
206206+ --disk-format qcow2
207207+```
208208+209209+## Configuration File
210210+211211+The `vmconfig.toml` file allows you to define default VM settings:
212212+213213+```toml
214214+[vm]
215215+iso = "https://cdimage.ubuntu.com/releases/24.04/release/ubuntu-24.04.3-live-server-arm64.iso"
216216+cpu = "host"
217217+cpus = 2
218218+memory = "2G"
219219+image = "./vm-disk.img"
220220+disk_format = "raw"
221221+size = "20G"
222222+223223+[network]
224224+bridge = "br0"
225225+port_forward = "2222:22"
226226+227227+[options]
228228+detach = false
229229+```
230230+231231+## HTTP API
232232+233233+Start the API server:
234234+235235+```bash
236236+# Start on default port (8889)
237237+vmx serve
238238+239239+# Start on custom port
240240+vmx serve --port 3000
241241+242242+# With custom API token
243243+export VMX_API_TOKEN=your-secret-token
244244+vmx serve
245245+```
246246+247247+### API Endpoints
248248+249249+#### Machines (VMs)
250250+251251+- `GET /machines` - List all machines
252252+- `GET /machines?all=true` - List all machines including stopped
253253+- `POST /machines` - Create a new machine
254254+- `GET /machines/:id` - Get machine details
255255+- `DELETE /machines/:id` - Remove a machine
256256+- `POST /machines/:id/start` - Start a machine
257257+- `POST /machines/:id/stop` - Stop a machine
258258+- `POST /machines/:id/restart` - Restart a machine
259259+260260+#### Images
261261+262262+- `GET /images` - List all images
263263+- `GET /images/:id` - Get image details
264264+265265+#### Volumes
266266+267267+- `GET /volumes` - List all volumes
268268+- `GET /volumes/:id` - Get volume details
269269+- `POST /volumes` - Create a new volume
270270+- `DELETE /volumes/:id` - Remove a volume
271271+272272+### API Authentication
273273+274274+All API requests require a Bearer token:
275275+276276+```bash
277277+curl -H "Authorization: Bearer your-token" http://localhost:8889/machines
278278+```
279279+280280+### Example API Usage
281281+282282+```bash
283283+# Create a machine
284284+curl -X POST http://localhost:8889/machines \
285285+ -H "Authorization: Bearer your-token" \
286286+ -H "Content-Type: application/json" \
287287+ -d '{
288288+ "image": "ubuntu:24.04",
289289+ "memory": "4G",
290290+ "cpus": 4,
291291+ "portForward": ["2222:22"]
292292+ }'
293293+294294+# Start a machine
295295+curl -X POST http://localhost:8889/machines/{id}/start \
296296+ -H "Authorization: Bearer your-token"
297297+298298+# List all machines
299299+curl http://localhost:8889/machines \
300300+ -H "Authorization: Bearer your-token"
301301+```
302302+303303+## Architecture Support
304304+305305+vmx automatically detects and adapts to your system architecture:
306306+307307+- **x86_64 / amd64** - Full QEMU system emulation
308308+- **ARM64 / aarch64** - Native Apple Silicon and ARM server support with UEFI firmware
309309+310310+## Examples
311311+312312+### Development Environment
313313+314314+```bash
315315+# Initialize configuration
316316+vmx init
317317+318318+# Edit vmconfig.toml to your needs
319319+# Then start the VM
320320+vmx
321321+322322+# SSH into the VM (port forwarding configured)
323323+ssh -p 2222 user@localhost
324324+```
325325+326326+### CI/CD Integration
327327+328328+```bash
329329+# Pull a pre-configured image
330330+vmx pull ghcr.io/company/test-env:latest
331331+332332+# Run tests in detached mode
333333+vmx run ghcr.io/company/test-env:latest -d
334334+335335+# Execute tests and cleanup
336336+vmx stop test-vm
337337+vmx rm test-vm
338338+```
339339+340340+### Multi-VM Setup
341341+342342+```bash
343343+# Start database VM
344344+vmx run postgres:14 -d -p 5432:5432 -v pgdata
345345+346346+# Start application VM
347347+vmx run app:latest -d -p 8080:8080
348348+349349+# List all running VMs
350350+vmx ps
351351+```
352352+353353+## License
354354+355355+Mozilla Public License 2.0 (MPL-2.0)
356356+357357+Copyright (c) 2025 Tsiry Sandratraina
358358+359359+## Contributing
360360+361361+Contributions are welcome! Please feel free to submit issues and pull requests.
362362+363363+## Links
364364+365365+- [Repository](https://github.com/tsirysndr/vmx)
366366+- [Issue Tracker](https://github.com/tsirysndr/vmx/issues)
367367+- [JSR Package](https://jsr.io/@tsiry/vmx)