Skip to main content

Libvirt

@bad-at-naming/libvirtv2026.05.20.1· 2d agoMODELS
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 (+ optional user) and virsh runs on the remote hypervisor over ssh. No local libvirt client needed.
  • Local/URI mode: omit host and virsh runs on the swamp host against uri (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.

02Models4
@bad-at-naming/libvirt/vmv2026.05.20.1libvirt_vm.ts

Global Arguments

ArgumentTypeDescription
host?stringSSH host/IP of the libvirt hypervisor. If set, virsh runs there over SSH. Omit for local/URI mode.
userstringSSH username (SSH mode only; default: root)
uri?stringLibvirt 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
ArgumentTypeDescription
namestringVM name
fn dumpxml(name: string)
Get raw XML definition of a VM
ArgumentTypeDescription
namestringVM name
fn start(name: string)
Start a VM. Idempotent — succeeds if already running.
ArgumentTypeDescription
namestringVM name
fn stop(name: string)
Gracefully shut down a VM (ACPI). Idempotent — succeeds if already stopped.
ArgumentTypeDescription
namestringVM name
fn forceStop(name: string)
Force stop a VM (pull the power cord). Idempotent — succeeds if already stopped.
ArgumentTypeDescription
namestringVM name
fn restart(name: string)
Reboot a running VM
ArgumentTypeDescription
namestringVM name
fn reset(name: string)
Hard reset a VM (no ACPI, immediate reset)
ArgumentTypeDescription
namestringVM name
fn suspend(name: string)
Suspend (pause) a running VM
ArgumentTypeDescription
namestringVM name
fn resume(name: string)
Resume a suspended (paused) VM
ArgumentTypeDescription
namestringVM name
fn autostart(name: string, enabled: boolean)
Enable or disable autostart for a VM
ArgumentTypeDescription
namestringVM name
enabledbooleantrue 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.
ArgumentTypeDescription
xmlstringFull libvirt domain XML definition
fn undefine(name: string, removeStorage: boolean, snapshotsMetadata: boolean, nvram: boolean)
Undefine a VM (remove its persistent configuration)
ArgumentTypeDescription
namestringVM name
removeStoragebooleanAlso remove all associated storage volumes
snapshotsMetadatabooleanAlso remove snapshot metadata
nvrambooleanAlso remove NVRAM file (required for UEFI VMs)
fn rename(name: string, newName: string)
Rename a VM (must be shut off)
ArgumentTypeDescription
namestringCurrent VM name
newNamestringNew VM name
fn save(name: string, file: string)
Save VM state to a file (like hibernate)
ArgumentTypeDescription
namestringVM name
filestringPath on hypervisor to save state to
fn restore(file: string)
Restore a VM from a saved state file
ArgumentTypeDescription
filestringPath on hypervisor to restore from
fn setVcpus(name: string, count: number, maximum: boolean, config: boolean, live: boolean)
Change the number of virtual CPUs
ArgumentTypeDescription
namestringVM name
countnumberNumber of vCPUs
maximumbooleanSet maximum vCPU count instead of current
configbooleanApply to persistent config (next boot)
livebooleanApply to running VM (hotplug)
fn setMemory(name: string, sizeMB: number, maximum: boolean, config: boolean, live: boolean)
Change memory allocation (in MiB)
ArgumentTypeDescription
namestringVM name
sizeMBnumberMemory in MiB
maximumbooleanSet maximum memory instead of current
configbooleanApply to persistent config
livebooleanApply 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
ArgumentTypeDescription
namestringVM name
sourcestringDisk source path (image file or block device)
targetstringTarget device name (e.g. vdb, sdb)
driverenumDisk driver/format
cache?enumCache mode
persistentbooleanMake change persistent across reboots (running VMs)
configbooleanApply 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.
ArgumentTypeDescription
namestringVM name
targetstringTarget device name to detach (e.g. vdb)
persistentbooleanMake change persistent (running VMs)
configbooleanApply 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
ArgumentTypeDescription
namestringVM name
typeenumInterface type
sourcestringSource bridge/network name (e.g. br0, default)
modelstringNIC model (virtio, e1000, rtl8139)
persistentbooleanMake change persistent
fn detachInterface(name: string, type: enum, mac: string, persistent: boolean)
Detach a network interface from a VM by MAC address
ArgumentTypeDescription
namestringVM name
typeenumInterface type
macstringMAC address of the interface to detach
persistentbooleanMake change persistent
fn changeMedia(name: string, target: string, source?: string)
Change CD/DVD media for a VM
ArgumentTypeDescription
namestringVM name
targetstringTarget device (e.g. hda, sda)
source?stringNew ISO path (omit to eject)
fn blockList(name: string)
List all block devices for a VM
ArgumentTypeDescription
namestringVM name
fn interfaceList(name: string)
List all network interfaces for a VM
ArgumentTypeDescription
namestringVM name
fn interfaceAddresses(name: string, source: enum)
Get IP addresses of a VM's interfaces
ArgumentTypeDescription
namestringVM name
sourceenumAddress source: lease (DHCP), agent (guest-agent), arp
fn blockStats(name: string, device?: string)
Get block device I/O statistics for a VM
ArgumentTypeDescription
namestringVM name
device?stringSpecific block device (e.g. vda). Omit for all.
fn interfaceStats(name: string, interface: string)
Get network interface statistics for a VM
ArgumentTypeDescription
namestringVM name
interfacestringInterface device name (e.g. vnet0)
fn memoryStats(name: string)
Get memory statistics for a VM
ArgumentTypeDescription
namestringVM name
fn cpuStats(name: string)
Get CPU statistics for a VM
ArgumentTypeDescription
namestringVM name
fn domstats(name: string)
Get comprehensive statistics for a VM (state, CPU, balloon, vCPU, net, block)
ArgumentTypeDescription
namestringVM name
fn snapshotList(name: string)
List all snapshots for a VM
ArgumentTypeDescription
namestringVM name
fn snapshotCreate(name: string, snapshotName: string, description?: string, quiesce: boolean, diskOnly: boolean)
Create a snapshot of a VM
ArgumentTypeDescription
namestringVM name
snapshotNamestringName for the snapshot
description?stringSnapshot description
quiescebooleanQuiesce guest filesystem (requires guest agent)
diskOnlybooleanDisk-only snapshot (no memory)
fn snapshotInfo(name: string, snapshotName: string)
Get info about a specific snapshot
ArgumentTypeDescription
namestringVM name
snapshotNamestringSnapshot name
fn snapshotRevert(name: string, snapshotName: string, running: boolean, paused: boolean)
Revert a VM to a snapshot
ArgumentTypeDescription
namestringVM name
snapshotNamestringSnapshot name to revert to
runningbooleanStart VM after revert
pausedbooleanLeave VM paused after revert
fn snapshotDelete(name: string, snapshotName: string, children: boolean)
Delete a snapshot
ArgumentTypeDescription
namestringVM name
snapshotNamestringSnapshot name to delete
childrenbooleanAlso delete child snapshots
fn snapshotDumpxml(name: string, snapshotName: string)
Get raw XML of a snapshot
ArgumentTypeDescription
namestringVM name
snapshotNamestringSnapshot name
fn guestInfo(name: string, types?: string)
Query guest information via QEMU guest agent (hostname, OS, IPs, filesystems, etc.)
ArgumentTypeDescription
namestringVM name
types?stringComma-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.
ArgumentTypeDescription
namestringVM name
usernamestringUsername inside the guest
passwordstringNew password
encryptedbooleanPassword 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

ArgumentTypeDescription
host?stringSSH host/IP of the libvirt hypervisor. If set, virsh runs there over SSH. Omit for local/URI mode.
userstringSSH username (SSH mode only; default: root)
uri?stringLibvirt 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
ArgumentTypeDescription
namestringNetwork name
fn dumpxml(name: string)
Get raw XML definition of a network
ArgumentTypeDescription
namestringNetwork name
fn start(name: string)
Start (activate) a virtual network
ArgumentTypeDescription
namestringNetwork name
fn stop(name: string)
Stop (deactivate) a virtual network
ArgumentTypeDescription
namestringNetwork name
fn define(xml: string)
Define a virtual network from XML (does not start it)
ArgumentTypeDescription
xmlstringFull libvirt network XML definition
fn undefine(name: string)
Undefine a virtual network (remove persistent config)
ArgumentTypeDescription
namestringNetwork name
fn autostart(name: string, enabled: boolean)
Enable or disable autostart for a virtual network
ArgumentTypeDescription
namestringNetwork name
enabledbooleantrue to enable, false to disable
fn dhcpLeases(name: string)
List DHCP leases for a virtual network
ArgumentTypeDescription
namestringNetwork 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

ArgumentTypeDescription
host?stringSSH host/IP of the libvirt hypervisor. If set, virsh runs there over SSH. Omit for local/URI mode.
userstringSSH username (SSH mode only; default: root)
uri?stringLibvirt 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
ArgumentTypeDescription
namestringPool name
fn poolStart(name: string)
Start (activate) a storage pool. Idempotent: succeeds if already active.
ArgumentTypeDescription
namestringPool name
fn poolBuild(name: string)
Build a storage pool (creates target directory for dir pools)
ArgumentTypeDescription
namestringPool name
fn poolStop(name: string)
Stop (deactivate) a storage pool
ArgumentTypeDescription
namestringPool 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.
ArgumentTypeDescription
namestringPool name
typeenumPool type
target?stringTarget path (e.g. /var/lib/libvirt/images)
sourceHost?stringSource host for network pools
sourcePath?stringSource path/name
sourceFormat?stringSource format (e.g. nfs, cifs, auto)
fn poolUndefine(name: string)
Undefine a storage pool (remove persistent config)
ArgumentTypeDescription
namestringPool name
fn poolAutostart(name: string, enabled: boolean)
Enable or disable autostart for a storage pool
ArgumentTypeDescription
namestringPool name
enabledbooleantrue to enable, false to disable
fn poolRefresh(name: string)
Refresh a storage pool to discover new volumes
ArgumentTypeDescription
namestringPool name
fn volList(pool: string)
List all volumes in a storage pool
ArgumentTypeDescription
poolstringPool name
fn volGet(name: string, pool: string)
Get detailed info for a storage volume including XML
ArgumentTypeDescription
namestringVolume name
poolstringPool name
fn volCreate(pool: string, name: string, capacity: string, format: enum, allocation?: string)
Create a new storage volume. Idempotent: succeeds if volume already exists.
ArgumentTypeDescription
poolstringPool name
namestringVolume name
capacitystringCapacity with unit (e.g. 10G, 500M, 1T)
formatenumVolume format
allocation?stringInitial allocation with unit (for thin provisioning, e.g. 0)
fn volDelete(name: string, pool: string)
Delete a storage volume
ArgumentTypeDescription
namestringVolume name
poolstringPool name
fn volResize(name: string, pool: string, capacity: string, shrink: boolean)
Resize a storage volume
ArgumentTypeDescription
namestringVolume name
poolstringPool name
capacitystringNew capacity with unit (e.g. 20G)
shrinkbooleanAllow shrinking (data loss risk)
fn volClone(name: string, pool: string, newName: string)
Clone a storage volume
ArgumentTypeDescription
namestringSource volume name
poolstringPool name
newNamestringNew 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

ArgumentTypeDescription
host?stringSSH host/IP of the libvirt hypervisor. If set, virsh runs there over SSH. Omit for local/URI mode.
userstringSSH username (SSH mode only; default: root)
uri?stringLibvirt 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.)
ArgumentTypeDescription
cap?stringFilter 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)
ArgumentTypeDescription
destinationstringDestination CIDR (e.g., 10.244.0.0/16)
gatewaystringGateway IP address
replacebooleanUse '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
04Platforms
05Labels