Libvirt
01README
Manage libvirt/KVM over SSH: define and undefine virtual networks including the default, clone a golden volume or zvol per node, define domains from a clone, control power, and capture the serial console. The SSH target, libvirt URI and every operand are method arguments, so one definition manages any hypervisor.
02Behaviors
@randybias/libvirtv2026.10.17.1libvirt.ts
fn define_network()
DESTRUCTIVE. Define a network from raw XML or structured inputs, then start and autostart it as asked. With replace=true a differing existing network is destroyed and redefined; otherwise a differing network is left untouched and reported as drift, and an identical one is a no-op.
fn undefine_network()
DESTRUCTIVE. Stop a network if active, then undefine it; use this to remove the default network. Undefining an absent network is a clean no-op.
fn clone_volume()
Idempotent. Clone a golden volume or zvol in a pool to a new volume with virsh vol-clone, which uses the pool driver and so supports zfs-backed pools. A target that already exists is a no-op, never a second clone.
fn define_domain()
DESTRUCTIVE. Define a KVM domain that boots from a pool volume, usually a clone of the golden volume, from rendered XML. An existing domain is a no-op unless replace=true, which destroys and redefines it; start is optional, and the rendered XML wires a pty serial console.
fn power()
DESTRUCTIVE. Start, shut down, destroy, reboot, suspend or resume a domain, idempotent toward the desired state. destroy is an immediate power-off that loses guest state, and a domain already in the target state is a no-op.
fn console()
READ-ONLY. Attach to a domain's serial console under a hard timeout and store the captured text as a sensitive resource. Never blocks past timeout_s; returns the byte count and SHA-256 of the capture, never the text itself.
fn undefine_domain()
DESTRUCTIVE. Destroy the domain if running, then undefine it; remove_volumes also deletes the root volume recorded by define_domain (plus read-only media with remove_attached_media) after detaching every other disk, and refuses before any power-off when no recorded root is attached. Undefining an absent domain is a clean no-op.
fn get()
READ-ONLY. Report network, domain and pool-volume state from virsh list/info. Writes the inventory as host_state and returns the same typed object.
fn sync()
READ-ONLY. Probe the host and report drift between the last recorded inventory and the live networks, domains and pool volumes.
Resources
network_state(infinite)— Recorded state of one libvirt network
volume_state(infinite)— Recorded state of one libvirt storage volume
domain_state(infinite)— Recorded state of one libvirt domain
console_capture(1d)— Bounded serial console capture for one domain
host_state(1d)— Inventory of networks, domains and pool volumes
03Stats
A
93 / 100
Downloads
2
Archive size
56.0 KB
- Has README or module doc2/2earned
- README has a code example1/1earned
- README is substantive1/1earned
- Most symbols documented1/1earned
- No slow types (deprecated)1/1earned
- Dependencies pass trust audit2/2earned
- Has description1/1earned
- Platform support declared (or universal)2/2earned
- License1/2partial
no SPDX license declared
- Verified public repository2/2earned
deno-command1 accepted
Spawns a subprocess with Deno.Command().
- models/_lib/ssh.ts:505 — no reason given
05Platforms
06Labels