How To Start / Shutdown / Reboot Guest Operating Systems With virsh Command On KVM

by lifeLinux on January 31, 2013

The virsh command is an alternative command to manage a Red Hat Enterprise Linux 5 KVM environment using a Command Line Interface(CLI). The virsh command is provided as part of the libvirt API which provides a common API to applications requiring standardized access to interact with KVM using a stable interface.

The following are basic and commonly used virsh commands:

help	 print help
list	 list domains
create	 create a domain from an XML file
start	 start a previously created inactive domain
destroy	 destroy a domain
define	 define (but do not start) a domain from an XML file
domid	 convert a domain name or UUID to domain id
domuuid	 convert a domain name or id to domain UUID
dominfo	 domain information
domname	 convert a domain id or UUID to domain name
domstate domain state
quit	 quit this interactive terminal
reboot	 reboot a domain
restore	 restore a domain from a saved state in a file
resume	 resume a domain
save	 save a domain state to a file
shutdown gracefully shutdown a domain
suspend	 suspend a domain
undefine undefine an inactive domain

List running guest VMs

Type the following command:

# virsh list

Sample outputs:

Id  Name                 State
----------------------------------
1   VM01                 running
2   VM02	         running

Staring a guest VM

Type the following command:

# virsh start VM01

Shutddowwn a guest VM

Type the following command:

# virsh shutdown VM01

Or, you can forcefully stop a guest VM with following command:

# virsh destroy VM01

Rebooting a guest VM

Type the following command:

# virsh reboot VM01

Related Posts:

Leave a Comment

Previous post:

Next post: