Quick reference for the 34 newly added API endpoints
GET /libvirt/networks
Returns list of all libvirt networks with status.
GET /libvirt/network?name=<network-name>
Returns detailed network information (UUID, active, bridge, etc.).
POST /libvirt/network/create
Content-Type: application/json
{
"name": "vm-network",
"bridge": "virbr1",
"forward": "nat",
"subnet": "192.168.100.1",
"ip_start": "192.168.100.10",
"ip_end": "192.168.100.100"
}
POST /libvirt/network/delete
Content-Type: application/json
{
"name": "vm-network"
}
POST /libvirt/network/start
Content-Type: application/json
{
"name": "vm-network"
}
POST /libvirt/network/stop
Content-Type: application/json
{
"name": "vm-network"
}
POST /libvirt/interface/attach
Content-Type: application/json
{
"vm_name": "my-vm",
"network": "vm-network",
"model": "virtio"
}
POST /libvirt/interface/detach
Content-Type: application/json
{
"vm_name": "my-vm",
"mac": "52:54:00:12:34:56"
}
GET /libvirt/volume/info?pool=<pool>&volume=<name>
POST /libvirt/volume/create
Content-Type: application/json
{
"pool": "default",
"name": "data-disk",
"format": "qcow2",
"capacity": 50,
"prealloc": false
}
POST /libvirt/volume/clone
Content-Type: application/json
{
"pool": "default",
"source_volume": "vm-disk",
"target_volume": "vm-disk-backup",
"target_pool": "default"
}
POST /libvirt/volume/resize
Content-Type: application/json
{
"pool": "default",
"volume": "data-disk",
"capacity": 100,
"shrink": false
}
POST /libvirt/volume/delete
Content-Type: application/json
{
"pool": "default",
"volume": "old-disk"
}
POST /libvirt/volume/upload
Content-Type: application/json
{
"pool": "default",
"volume": "imported-vm",
"source_path": "/data/vm-disk.vmdk",
"format": "qcow2"
}
POST /libvirt/volume/wipe
Content-Type: application/json
{
"pool": "default",
"volume": "old-disk",
"algorithm": "zero"
}
Wipe Algorithms: zero, nnsa, dod, bsi, gutmann, schneier, pfitzner7, pfitzner33, random
GET /libvirt/stats?name=<vm-name>
Returns comprehensive stats: CPU, memory, disk I/O, network I/O.
GET /libvirt/stats/all
Returns stats for all running VMs.
GET /libvirt/stats/cpu?name=<vm-name>
Returns: vCPUs, CPU time (user, system, total), usage %.
GET /libvirt/stats/memory?name=<vm-name>
Returns: total, used, available, usage %, swap in/out.
GET /libvirt/stats/disk?name=<vm-name>
Returns per-disk: read/write bytes, read/write requests, errors.
GET /libvirt/stats/network?name=<vm-name>
Returns per-interface: RX/TX bytes, packets, errors, dropped.
POST /libvirt/batch/start
Content-Type: application/json
{
"domains": ["vm1", "vm2", "vm3"],
"paused": false
}
POST /libvirt/batch/stop
Content-Type: application/json
{
"domains": ["vm1", "vm2", "vm3"],
"force": false
}
force: true = destroy (immediate), false = shutdown (graceful)
POST /libvirt/batch/reboot
Content-Type: application/json
{
"domains": ["vm1", "vm2"],
"force": false
}
force: true = reset (hard), false = reboot (graceful)
POST /libvirt/batch/snapshot
Content-Type: application/json
{
"domains": ["vm1", "vm2"],
"name_prefix": "backup",
"description": "Pre-upgrade backup",
"atomic": true,
"disk_only": false
}
POST /libvirt/batch/delete
Content-Type: application/json
{
"domains": ["old-vm1", "old-vm2"],
"remove_storage": true,
"snapshots_only": false
}
POST /libvirt/batch/pause
Content-Type: application/json
{
"domains": ["vm1", "vm2"]
}
POST /libvirt/batch/resume
Content-Type: application/json
{
"domains": ["vm1", "vm2"]
}
POST /libvirt/clone
Content-Type: application/json
{
"source": "base-vm",
"target": "cloned-vm",
"files": [],
"new_mac": true,
"auto_clone": true,
"preserve": true
}
POST /libvirt/clone/multiple
Content-Type: application/json
{
"source": "web-template",
"name_prefix": "vm-web",
"count": 5,
"start_index": 1
}
Creates: vm-web-1, vm-web-2, vm-web-3, vm-web-4, vm-web-5
POST /libvirt/template/create
Content-Type: application/json
{
"domain": "base-ubuntu",
"name": "ubuntu-22-template",
"description": "Ubuntu 22.04 base template",
"metadata": {},
"seal": true
}
seal: Uses virt-sysprep to remove machine-specific config
POST /libvirt/template/deploy
Content-Type: application/json
{
"template": "ubuntu-22-template",
"name": "new-webserver",
"memory": 4096,
"vcpus": 2,
"network": "vm-network",
"autostart": true,
"customize": {}
}
GET /libvirt/template/list
Returns all VMs with “template” in their name or shut-off VMs.
POST /libvirt/template/export
Content-Type: application/json
{
"template": "ubuntu-22-template",
"export_path": "/backups/templates",
"compress": true
}
Exports XML definition and disk images, optionally compressed.
All endpoints return JSON responses:
{
"status": "success",
"message": "Operation completed successfully",
"data": { ... },
"timestamp": "2026-01-19T12:30:00Z"
}
{
"error": "Error message here",
"timestamp": "2026-01-19T12:30:00Z"
}
{
"operation": "start",
"total": 4,
"successful": 3,
"failed": 1,
"results": [
{"domain": "vm1", "success": true},
{"domain": "vm2", "success": true},
{"domain": "vm3", "success": true},
{"domain": "vm4", "success": false, "error": "domain not found"}
],
"start_time": "2026-01-19T12:00:00Z",
"end_time": "2026-01-19T12:00:15Z",
"duration": "15s"
}
# Test network listing
curl http://localhost:8080/libvirt/networks
# Test VM stats
curl http://localhost:8080/libvirt/stats?name=my-vm
# Test batch start
curl -X POST http://localhost:8080/libvirt/batch/start \
-H "Content-Type: application/json" \
-d '{"domains":["vm1","vm2"]}'
# Test network creation
http POST http://localhost:8080/libvirt/network/create \
name=vm-network \
bridge=virbr1 \
forward=nat \
subnet=192.168.100.1 \
ip_start=192.168.100.10 \
ip_end=192.168.100.100
# Test volume creation
http POST http://localhost:8080/libvirt/volume/create \
pool=default \
name=data-disk \
format=qcow2 \
capacity:=50
# Test VM cloning
http POST http://localhost:8080/libvirt/clone \
source=base-vm \
target=cloned-vm \
new_mac:=true
| Code | Meaning |
|---|---|
| 200 | Success |
| 201 | Created (for create operations) |
| 400 | Bad Request (invalid JSON, missing parameters) |
| 404 | Not Found (VM, network, or volume doesn’t exist) |
| 405 | Method Not Allowed (wrong HTTP method) |
| 500 | Internal Server Error (virsh command failed) |
Content-Type: application/json headervirt-sysprep packageTotal: 119 endpoints (85 original + 34 new)
# Step 1: Create network
curl -X POST http://localhost:8080/libvirt/network/create \
-H "Content-Type: application/json" \
-d '{
"name": "vm-network",
"bridge": "virbr1",
"forward": "nat",
"subnet": "192.168.100.1",
"ip_start": "192.168.100.10",
"ip_end": "192.168.100.100"
}'
# Step 2: Start network
curl -X POST http://localhost:8080/libvirt/network/start \
-H "Content-Type: application/json" \
-d '{"name": "vm-network"}'
# Step 3: Attach interface to VM
curl -X POST http://localhost:8080/libvirt/interface/attach \
-H "Content-Type: application/json" \
-d '{
"vm_name": "my-vm",
"network": "vm-network",
"model": "virtio"
}'
# Step 1: Clone VM
curl -X POST http://localhost:8080/libvirt/clone \
-H "Content-Type: application/json" \
-d '{
"source": "template-vm",
"target": "new-vm",
"new_mac": true
}'
# Step 2: Start cloned VM
curl -X POST http://localhost:8080/libvirt/domain/start \
-H "Content-Type: application/json" \
-d '{"name": "new-vm"}'
# Step 3: Monitor performance
curl http://localhost:8080/libvirt/stats?name=new-vm
# Step 1: Clone template 10 times
curl -X POST http://localhost:8080/libvirt/clone/multiple \
-H "Content-Type: application/json" \
-d '{
"source": "web-template",
"name_prefix": "web-server",
"count": 10
}'
# Step 2: Start all web servers
curl -X POST http://localhost:8080/libvirt/batch/start \
-H "Content-Type: application/json" \
-d '{
"domains": [
"web-server-1", "web-server-2", "web-server-3",
"web-server-4", "web-server-5", "web-server-6",
"web-server-7", "web-server-8", "web-server-9",
"web-server-10"
]
}'
# Step 3: Monitor all servers
curl http://localhost:8080/libvirt/stats/all
For full documentation, see: CRITICAL_FEATURES_ADDED.md