How do I list a KVM vm guest using virsh command on a Linux based hypervisor?
A hypervisor is nothing but Linux kernel module that isolates operating systems and applications from the underlying server. KVM turn Linux operating system into a hypervisor. This post shows how to list an installed KVM guest VM using virsh command line option.
How to: Linux list a KVM vm guest using virsh command
The syntax is:
vish list --all
virsh list [options]
Let us see some command examples.
Just list domains / KVM VM guest
Simply type the command:
vish list --all
Name is the name of the domain (KVM VM guest name). ID the domain numeric id. State is the run state as follows:
- running – The domain is currently running on a CPU.
- idle – The domain is idle, and not running or runnable. This can be caused because the domain is waiting on IO (a traditional wait state) or has gone to sleep because there was nothing else for it to do.
- paused – The domain has been paused, usually occurring through the administrator running virsh suspend. When in a paused state the domain will still consume allocated resources like memory, but will not be eligible for scheduling by the hypervisor.
- in shutdown – The domain is in the process of shutting down, i.e. the guest operating system has been notified and should be in the process of stopping its operations gracefully.
- shut off – The domain is not running. Usually this indicates the domain has been shut down completely, or has not been started.
- crashed – The domain has crashed, which is always a violent ending. Usually this state can only occur if the domain has been configured not to restart on crash.
- pmsuspended – The domain has been suspended by guest power management, e.g. entered into s3 state.
To list domains with autostart enabled
virsh list --autostart
Id Name State ---------------------------------------------------- 1 openbsd62 running 2 freebsd11-nixcraft running 3 fedora28-nixcraft running 4 rhel7 running 5 centos7-nixcraft running 6 sles12sp3 running
Linux list a KVM vm guest using virsh command with the following options:
vish list --help
NAME list - list domains SYNOPSIS list [--inactive] [--all] [--transient] [--persistent] [--with-snapshot] [--without-snapshot] [--state-running] [--state-paused] [--state-shutoff] [--state-other] [--autostart] [--no-autostart] [--with-managed-save] [--without-managed-save] [--uuid] [--name] [--table] [--managed-save] [--title] DESCRIPTION Returns list of domains.
NAME list – list domains SYNOPSIS list [–inactive] [–all] [–transient] [–persistent] [–with-snapshot] [–without-snapshot] [–state-running] [–state-paused] [–state-shutoff] [–state-other] [–autostart] [–no-autostart] [–with-managed-save] [–without-managed-save] [–uuid] [–name] [–table] [–managed-save] [–title] DESCRIPTION Returns list of domains.
virsh list command options
||list inactive domains
||list inactive & active domains
||list transient domains
||list persistent domains
||list domains with existing snapshot
||list domains without a snapshot
||list domains in running state
||list domains in paused state
||list domains in shutoff state
||list domains in other states
||list domains with autostart enabled
||list domains with autostart disabled
||list domains with managed save state
||list domains without managed save
||list uuid’s only
||list domain names only
||list table (default)
||mark inactive domains with managed save state
||show domain title
And there you have it, you know how to get list of KVM VM/domains using the virsh command. For more info see this page or read man page by typing the following man command:
Posted by: Vivek Gite
The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.