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 | --inactive | --transient] [--managed-save] [--state-running] [--state-paused] [--state-shutoff] [--state-other] [--state-blocked] [--state-pmsuspended] [--uuid] [--name] [--title] [--persistent] [--autostart] [--domain ] [--raw] [--quiet] [--help]

PARAMETERS

--all
    List all domains (both active and inactive).

--inactive
    List only inactive domains.

--transient
    List transient domains.

--managed-save
    List domains that are in managed save state.

--state-running
    List domains that are in running state.

--state-paused
    List domains that are in paused state.

--state-shutoff
    List domains that are in shutoff state.

--state-other
    List domains that are in other state.

--state-blocked
    List domains that are in blocked state.

--state-pmsuspended
    List domains that are in PMSuspended state.

--uuid
    Display UUID of domains.

--name
    Display name of domains.

--title
    Display the title for the list.

--persistent
    List persistent domains.

--autostart
    List domains configured for autostart.

--domain
    List only the specified domain.

--raw
    Output the domain information in a raw format (e.g., name only).

--quiet
    Suppress headers and other non-essential output.

--help
    Display help information.

DESCRIPTION

The `virsh list` command provides a way to enumerate virtual machines currently managed by the libvirt virtualization management toolkit. Libvirt acts as an abstraction layer, allowing management of various hypervisors (KVM, Xen, QEMU, etc.) through a single interface. The `virsh list` command displays the domain ID, name, and state of running virtual machines. Additional options allow the display of inactive domains (those that are defined but not running) and all domains (both active and inactive). The output is formatted for easy readability, presenting a concise overview of the virtual machine landscape under libvirt's control.

The command relies on the libvirtd daemon to be running and accessible. If the daemon is not running or the user does not have appropriate permissions, the command will fail. It's a critical tool for administrators needing to quickly assess the status of virtual machines within a libvirt-managed environment. Understanding the output and available options allows for efficient monitoring and management of virtualized resources.

CAVEATS

Requires libvirtd to be running and the user to have appropriate permissions to connect to the libvirt daemon. The state of a virtual machine may not always accurately reflect its actual operational status due to caching or other factors.

DOMAIN STATES

Virtual machines can be in various states:
Running: The domain is actively executing.
Paused: The domain's execution is temporarily suspended.
Shut off: The domain is powered off.
Blocked: The domain is blocked on I/O.
PMSuspended: The domain is suspended using power management.

EXIT STATUS

The `virsh list` command returns an exit status:
0: Success.
1: Failure (e.g., unable to connect to libvirt, invalid options).

HISTORY

The `virsh` command, including `virsh list`, has evolved as part of the libvirt project. Libvirt was created to provide a stable and consistent API for managing virtualization technologies. `virsh list` has been a core component since early versions, allowing administrators to quickly assess the virtual machine environment. Its functionality has been extended over time to include more granular filtering and output options, reflecting the increasing complexity of virtualization deployments.

SEE ALSO

virsh(1), virsh-dominfo(1), virsh-start(1), virsh-shutdown(1)

Copied to clipboard