Libvirt
@bad-at-naming/libvirtv2026.05.20.1
01README
Comprehensive libvirt/virsh management — VMs, networks, storage pools, volumes, snapshots, and host info — over SSH OR locally via a connection URI.
Connection modes (per model instance):
- SSH mode: set
host(+ optionaluser) and virsh runs on the remote hypervisor over ssh. No local libvirt client needed. - Local/URI mode: omit
hostand virsh runs on the swamp host againsturi(default qemu:///system; supports qemu+ssh://, qemu+tls://, qemu:///session, etc.).
Models:
@bad-at-naming/libvirt/vm— domain lifecycle, tuning, monitoring, snapshots, guest agent@bad-at-naming/libvirt/network— virtual network lifecycle + DHCP leases@bad-at-naming/libvirt/storage— storage pool and volume management@bad-at-naming/libvirt/host— hypervisor host info, capabilities, node stats
Local/URI connection support is merged from @evrardjp's fork (github.com/evrardjp/swamp-local-libvirt) — see README for credit.
02Models
@bad-at-naming/libvirt/vmv2026.05.20.1libvirt_vm.ts
Global Arguments
| Argument | Type | Description |
|---|---|---|
| host? | string | SSH host/IP of the libvirt hypervisor. If set, virsh runs there over SSH. Omit for local/URI mode. |
| user | string | SSH username (SSH mode only; default: root) |
| uri? | string | Libvirt connection URI. Local mode (no host) defaults to qemu:///system; in SSH mode it is passed to the remote virsh via -c when set. |
fn list()
List all VMs with state, vCPUs, memory, and autostart
fn get(name: string)
Get detailed VM info including disks, NICs, and graphics
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn dumpxml(name: string)
Get raw XML definition of a VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn start(name: string)
Start a VM. Idempotent — succeeds if already running.
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn stop(name: string)
Gracefully shut down a VM (ACPI). Idempotent — succeeds if already stopped.
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn forceStop(name: string)
Force stop a VM (pull the power cord). Idempotent — succeeds if already stopped.
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn restart(name: string)
Reboot a running VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn reset(name: string)
Hard reset a VM (no ACPI, immediate reset)
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn suspend(name: string)
Suspend (pause) a running VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn resume(name: string)
Resume a suspended (paused) VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn autostart(name: string, enabled: boolean)
Enable or disable autostart for a VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| enabled | boolean | true to enable, false to disable |
fn define(xml: string)
Define a VM from XML. Idempotent: undefines an existing domain of the same name first, then redefines.
| Argument | Type | Description |
|---|---|---|
| xml | string | Full libvirt domain XML definition |
fn undefine(name: string, removeStorage: boolean, snapshotsMetadata: boolean, nvram: boolean)
Undefine a VM (remove its persistent configuration)
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| removeStorage | boolean | Also remove all associated storage volumes |
| snapshotsMetadata | boolean | Also remove snapshot metadata |
| nvram | boolean | Also remove NVRAM file (required for UEFI VMs) |
fn rename(name: string, newName: string)
Rename a VM (must be shut off)
| Argument | Type | Description |
|---|---|---|
| name | string | Current VM name |
| newName | string | New VM name |
fn save(name: string, file: string)
Save VM state to a file (like hibernate)
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| file | string | Path on hypervisor to save state to |
fn restore(file: string)
Restore a VM from a saved state file
| Argument | Type | Description |
|---|---|---|
| file | string | Path on hypervisor to restore from |
fn setVcpus(name: string, count: number, maximum: boolean, config: boolean, live: boolean)
Change the number of virtual CPUs
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| count | number | Number of vCPUs |
| maximum | boolean | Set maximum vCPU count instead of current |
| config | boolean | Apply to persistent config (next boot) |
| live | boolean | Apply to running VM (hotplug) |
fn setMemory(name: string, sizeMB: number, maximum: boolean, config: boolean, live: boolean)
Change memory allocation (in MiB)
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| sizeMB | number | Memory in MiB |
| maximum | boolean | Set maximum memory instead of current |
| config | boolean | Apply to persistent config |
| live | boolean | Apply to running VM |
fn attachDisk(name: string, source: string, target: string, driver: enum, cache?: enum, persistent: boolean, config: boolean)
Attach a disk device to a VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| source | string | Disk source path (image file or block device) |
| target | string | Target device name (e.g. vdb, sdb) |
| driver | enum | Disk driver/format |
| cache? | enum | Cache mode |
| persistent | boolean | Make change persistent across reboots (running VMs) |
| config | boolean | Apply to persistent config only (stopped VMs) |
fn detachDisk(name: string, target: string, persistent: boolean, config: boolean)
Detach a disk device from a VM. Idempotent: succeeds if disk not found.
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| target | string | Target device name to detach (e.g. vdb) |
| persistent | boolean | Make change persistent (running VMs) |
| config | boolean | Apply to persistent config only (stopped VMs) |
fn attachInterface(name: string, type: enum, source: string, model: string, persistent: boolean)
Attach a network interface to a VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| type | enum | Interface type |
| source | string | Source bridge/network name (e.g. br0, default) |
| model | string | NIC model (virtio, e1000, rtl8139) |
| persistent | boolean | Make change persistent |
fn detachInterface(name: string, type: enum, mac: string, persistent: boolean)
Detach a network interface from a VM by MAC address
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| type | enum | Interface type |
| mac | string | MAC address of the interface to detach |
| persistent | boolean | Make change persistent |
fn changeMedia(name: string, target: string, source?: string)
Change CD/DVD media for a VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| target | string | Target device (e.g. hda, sda) |
| source? | string | New ISO path (omit to eject) |
fn blockList(name: string)
List all block devices for a VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn interfaceList(name: string)
List all network interfaces for a VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn interfaceAddresses(name: string, source: enum)
Get IP addresses of a VM's interfaces
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| source | enum | Address source: lease (DHCP), agent (guest-agent), arp |
fn blockStats(name: string, device?: string)
Get block device I/O statistics for a VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| device? | string | Specific block device (e.g. vda). Omit for all. |
fn interfaceStats(name: string, interface: string)
Get network interface statistics for a VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| interface | string | Interface device name (e.g. vnet0) |
fn memoryStats(name: string)
Get memory statistics for a VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn cpuStats(name: string)
Get CPU statistics for a VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn domstats(name: string)
Get comprehensive statistics for a VM (state, CPU, balloon, vCPU, net, block)
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn snapshotList(name: string)
List all snapshots for a VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
fn snapshotCreate(name: string, snapshotName: string, description?: string, quiesce: boolean, diskOnly: boolean)
Create a snapshot of a VM
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| snapshotName | string | Name for the snapshot |
| description? | string | Snapshot description |
| quiesce | boolean | Quiesce guest filesystem (requires guest agent) |
| diskOnly | boolean | Disk-only snapshot (no memory) |
fn snapshotInfo(name: string, snapshotName: string)
Get info about a specific snapshot
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| snapshotName | string | Snapshot name |
fn snapshotRevert(name: string, snapshotName: string, running: boolean, paused: boolean)
Revert a VM to a snapshot
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| snapshotName | string | Snapshot name to revert to |
| running | boolean | Start VM after revert |
| paused | boolean | Leave VM paused after revert |
fn snapshotDelete(name: string, snapshotName: string, children: boolean)
Delete a snapshot
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| snapshotName | string | Snapshot name to delete |
| children | boolean | Also delete child snapshots |
fn snapshotDumpxml(name: string, snapshotName: string)
Get raw XML of a snapshot
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| snapshotName | string | Snapshot name |
fn guestInfo(name: string, types?: string)
Query guest information via QEMU guest agent (hostname, OS, IPs, filesystems, etc.)
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| types? | string | Comma-separated types: users, os, timezone, hostname, filesystem, disk, interface (omit for all) |
fn setUserPassword(name: string, username: string, password: string, encrypted: boolean)
Set a user password inside the guest (requires guest agent). NOTE: the password is passed as a virsh argument and is visible in the hypervisor's process list while running — see README limitations.
| Argument | Type | Description |
|---|---|---|
| name | string | VM name |
| username | string | Username inside the guest |
| password | string | New password |
| encrypted | boolean | Password is already encrypted/hashed |
Resources
vm(infinite)— VM list or detail
actionResult(1h)— Result of a VM action (start, stop, etc.)
snapshot(infinite)— Snapshot list or detail
stats(1h)— VM statistics (block, interface, memory, CPU)
@bad-at-naming/libvirt/networkv2026.05.20.1libvirt_network.ts
Global Arguments
| Argument | Type | Description |
|---|---|---|
| host? | string | SSH host/IP of the libvirt hypervisor. If set, virsh runs there over SSH. Omit for local/URI mode. |
| user | string | SSH username (SSH mode only; default: root) |
| uri? | string | Libvirt connection URI. Local mode (no host) defaults to qemu:///system; in SSH mode it is passed to the remote virsh via -c when set. |
fn list()
List all virtual networks
fn get(name: string)
Get detailed info for a virtual network including XML config
| Argument | Type | Description |
|---|---|---|
| name | string | Network name |
fn dumpxml(name: string)
Get raw XML definition of a network
| Argument | Type | Description |
|---|---|---|
| name | string | Network name |
fn start(name: string)
Start (activate) a virtual network
| Argument | Type | Description |
|---|---|---|
| name | string | Network name |
fn stop(name: string)
Stop (deactivate) a virtual network
| Argument | Type | Description |
|---|---|---|
| name | string | Network name |
fn define(xml: string)
Define a virtual network from XML (does not start it)
| Argument | Type | Description |
|---|---|---|
| xml | string | Full libvirt network XML definition |
fn undefine(name: string)
Undefine a virtual network (remove persistent config)
| Argument | Type | Description |
|---|---|---|
| name | string | Network name |
fn autostart(name: string, enabled: boolean)
Enable or disable autostart for a virtual network
| Argument | Type | Description |
|---|---|---|
| name | string | Network name |
| enabled | boolean | true to enable, false to disable |
fn dhcpLeases(name: string)
List DHCP leases for a virtual network
| Argument | Type | Description |
|---|---|---|
| name | string | Network name |
Resources
network(infinite)— Virtual network list or detail
dhcpLeases(1h)— DHCP leases for a network
actionResult(1h)— Result of a network action
@bad-at-naming/libvirt/storagev2026.05.20.1libvirt_storage.ts
Global Arguments
| Argument | Type | Description |
|---|---|---|
| host? | string | SSH host/IP of the libvirt hypervisor. If set, virsh runs there over SSH. Omit for local/URI mode. |
| user | string | SSH username (SSH mode only; default: root) |
| uri? | string | Libvirt connection URI. Local mode (no host) defaults to qemu:///system; in SSH mode it is passed to the remote virsh via -c when set. |
fn poolList()
List all storage pools
fn poolGet(name: string)
Get detailed info for a storage pool including XML
| Argument | Type | Description |
|---|---|---|
| name | string | Pool name |
fn poolStart(name: string)
Start (activate) a storage pool. Idempotent: succeeds if already active.
| Argument | Type | Description |
|---|---|---|
| name | string | Pool name |
fn poolBuild(name: string)
Build a storage pool (creates target directory for dir pools)
| Argument | Type | Description |
|---|---|---|
| name | string | Pool name |
fn poolStop(name: string)
Stop (deactivate) a storage pool
| Argument | Type | Description |
|---|---|---|
| name | string | Pool name |
fn poolDefine(name: string, type: enum, target?: string, sourceHost?: string, sourcePath?: string, sourceFormat?: string)
Define a storage pool from parameters. Idempotent: succeeds if pool already exists.
| Argument | Type | Description |
|---|---|---|
| name | string | Pool name |
| type | enum | Pool type |
| target? | string | Target path (e.g. /var/lib/libvirt/images) |
| sourceHost? | string | Source host for network pools |
| sourcePath? | string | Source path/name |
| sourceFormat? | string | Source format (e.g. nfs, cifs, auto) |
fn poolUndefine(name: string)
Undefine a storage pool (remove persistent config)
| Argument | Type | Description |
|---|---|---|
| name | string | Pool name |
fn poolAutostart(name: string, enabled: boolean)
Enable or disable autostart for a storage pool
| Argument | Type | Description |
|---|---|---|
| name | string | Pool name |
| enabled | boolean | true to enable, false to disable |
fn poolRefresh(name: string)
Refresh a storage pool to discover new volumes
| Argument | Type | Description |
|---|---|---|
| name | string | Pool name |
fn volList(pool: string)
List all volumes in a storage pool
| Argument | Type | Description |
|---|---|---|
| pool | string | Pool name |
fn volGet(name: string, pool: string)
Get detailed info for a storage volume including XML
| Argument | Type | Description |
|---|---|---|
| name | string | Volume name |
| pool | string | Pool name |
fn volCreate(pool: string, name: string, capacity: string, format: enum, allocation?: string)
Create a new storage volume. Idempotent: succeeds if volume already exists.
| Argument | Type | Description |
|---|---|---|
| pool | string | Pool name |
| name | string | Volume name |
| capacity | string | Capacity with unit (e.g. 10G, 500M, 1T) |
| format | enum | Volume format |
| allocation? | string | Initial allocation with unit (for thin provisioning, e.g. 0) |
fn volDelete(name: string, pool: string)
Delete a storage volume
| Argument | Type | Description |
|---|---|---|
| name | string | Volume name |
| pool | string | Pool name |
fn volResize(name: string, pool: string, capacity: string, shrink: boolean)
Resize a storage volume
| Argument | Type | Description |
|---|---|---|
| name | string | Volume name |
| pool | string | Pool name |
| capacity | string | New capacity with unit (e.g. 20G) |
| shrink | boolean | Allow shrinking (data loss risk) |
fn volClone(name: string, pool: string, newName: string)
Clone a storage volume
| Argument | Type | Description |
|---|---|---|
| name | string | Source volume name |
| pool | string | Pool name |
| newName | string | New cloned volume name |
Resources
pool(infinite)— Storage pool list or detail
volume(infinite)— Storage volume list or detail
actionResult(1h)— Result of a storage action
@bad-at-naming/libvirt/hostv2026.05.20.1libvirt_host.ts
Global Arguments
| Argument | Type | Description |
|---|---|---|
| host? | string | SSH host/IP of the libvirt hypervisor. If set, virsh runs there over SSH. Omit for local/URI mode. |
| user | string | SSH username (SSH mode only; default: root) |
| uri? | string | Libvirt connection URI. Local mode (no host) defaults to qemu:///system; in SSH mode it is passed to the remote virsh via -c when set. |
fn info()
Get hypervisor host info (CPU, memory, versions)
fn capabilities()
Get hypervisor capabilities XML
fn sysinfo()
Get host system information (SMBIOS/DMI data)
fn cpuStats()
Get host CPU usage statistics
fn memStats()
Get host memory statistics
fn deviceList(cap?: string)
List node devices (PCI, USB, network, storage controllers, etc.)
| Argument | Type | Description |
|---|---|---|
| cap? | string | Filter by capability: system, pci, usb, usb_device, net, scsi_host, scsi, storage, drm |
fn addRoute(destination: string, gateway: string, replace: boolean)
Add a static route on the hypervisor host (SSH host mode only; runs `ip route` over SSH)
| Argument | Type | Description |
|---|---|---|
| destination | string | Destination CIDR (e.g., 10.244.0.0/16) |
| gateway | string | Gateway IP address |
| replace | boolean | Use 'replace' instead of 'add' to be idempotent |
Resources
info(infinite)— Hypervisor host information
stats(1h)— Host statistics (CPU, memory)
devices(infinite)— Node device list
03Stats
A
100 / 100
Downloads
1
Archive size
42.8 KB
- Has README or module doc2/2earned
- README has a code example1/1earned
- README is substantive1/1earned
- Most symbols documented1/1earned
- No slow types1/1earned
- Has description1/1earned
- Platform support declared (or universal)2/2earned
- License declared1/1earned
- Verified public repository2/2earned
Repository
https://github.com/umag/swamp-workspace04Platforms
05Labels