LinuxCommandLibrary

virsh-list

List virtual machines

TLDR

List information about running virtual machines

$ virsh list
copy

List information about virtual machines regardless of state
$ virsh list --all
copy

List information about virtual machines with autostart either enabled or disabled
$ virsh list --all --[autostart|no-autostart]
copy

List information about virtual machines either with or without snapshots
$ virsh list --all --[with-snapshot|without-snapshot]
copy

SYNOPSIS

virsh list [--all | --active | --inactive] [--detail] [--state <state>] [--persistent | --transient] [--autostart | --no-autostart]

PARAMETERS

--all | -all
    List all domains, including both active (running) and inactive (e.g., shut off) ones. This provides a comprehensive view of all configured VMs.

--active | -active
    List only active (running) domains. This is the default behavior when no options are specified.

--inactive | -inactive
    List only inactive domains, which are configured but currently not running (e.g., 'shut off', 'crashed').

--persistent
    List only persistent domains. These domains have their configuration saved and are designed to survive host reboots.

--transient
    List only transient domains. These domains' configurations are not saved persistently and are typically destroyed when they shut down or the host reboots.

--autostart
    List only domains configured to automatically start when the Libvirt daemon or host boots.

--no-autostart
    List only domains that are explicitly not configured for autostart.

--state <state>
    Filter domains by a specific operational state. Common states include running, paused, shutoff, crashed, pmsuspended, and nostate.

--detail
    Display more detailed information about each domain, such as virtual CPUs, memory allocation, and current time, in addition to the standard ID, Name, and State.

DESCRIPTION

virsh list is a fundamental subcommand of the virsh command-line utility, which serves as the primary management interface for the Libvirt virtualization library. This command is used to display a concise summary of virtual machines, also known as 'domains', currently managed by the Libvirt daemon on the connected host. By default, virsh list shows active (running) domains, including their unique numeric ID, name, and current state (e.g., 'running', 'paused'). The 'Id' column represents a transient identifier assigned by Libvirt while the VM is active. The 'Name' is the domain's user-defined name, and 'State' indicates its operational status. Options allow users to filter the list by state (e.g., inactive, all) or by configuration (e.g., autostart). It's an essential tool for administrators to quickly ascertain the status of their virtualized environments.

CAVEATS

virsh list requires the Libvirt daemon (libvirtd) to be running and accessible. Users must have appropriate permissions, typically by being root or a member of the 'libvirt' user group, to interact with the daemon. The 'Id' column for running VMs is a dynamic identifier and may change across reboots or when VMs are stopped and restarted. This command only shows VMs managed by the currently connected Libvirt instance; if multiple hypervisors or remote Libvirt hosts are in use, separate connections might be needed to view all VMs.

INTERPRETING OUTPUT COLUMNS

When executing virsh list, the default output typically includes three columns:
Id: A unique, transient integer identifier for the domain while it is running. This ID can change.
Name: The user-defined name of the virtual machine, which is persistent.
State: The current operational status of the VM, such as 'running', 'paused', 'shut off', 'crashed', etc.
For inactive domains, the 'Id' column will often display a '-' as they are not currently assigned an active runtime ID.

CONNECTING TO REMOTE LIBVIRT

By default, virsh list connects to the local Libvirt daemon. To list VMs on a remote host, you can specify the connection URI using the -c or --connect option with the virsh command, e.g., virsh -c qemu+ssh://user@remotehost/system list --all. This allows centralized management of virtual environments.

HISTORY

The virsh command-line tool, including its list subcommand, emerged as part of the broader Libvirt project, which began development in 2005. Libvirt was created to provide a single, stable, and long-term API for managing various virtualization technologies on Linux. As virtualization became a cornerstone of data centers and cloud computing, virsh quickly became an indispensable tool for system administrators and developers to interact with and oversee their virtual environments directly from the command line, offering consistent control across different hypervisors like KVM, Xen, and LXC.

SEE ALSO

virsh(1), virsh dominfo(1), virsh start(1), virsh shutdown(1), virsh destroy(1), libvirtd(8), virt-manager(1)

Copied to clipboard