Start & Stop Guest Operating Systems (VM) with virsh Command in KVM

Disclaimer: Accessing the information on this page means you agree to the Sites Privacy Policy & Terms of Use Agreement.


The virsh command is useful command to manage local or remote guest operating systems which are installed in KVM. The command can be used to create, pause, and shutdown VMs. It can also be used to list current VM (Guest) Operating Systems.

List VM (guest OS):
Type below command:

 $ virsh list 

Sample outputs:

 Id Name                                              State
—————————————————————-
  1 DomainController                   running
  2 DB_Server                                     running

$ virsh list –-all 

Sample outputs:

Id Name                                               State
—————————————————————-
  1 DomainController                    running
  2 DB_Server                                     running
  – backup_db                                     shut off

Shutdown a VMs (Guest OS):

 Syntax:  $ virsh shutdown {domain-id, domain-name or domain-uuid}

Follow the below command:

$ virsh list
$ virsh shutdown DomainController
$ virsh shutdown 2

Reboot a VMs (Guest OS):

Syntax:  $ virsh reboot {domain-id, domain-name or domain-uuid}

Follow the below command:

 $ virsh list
$ virsh reboot DomainController
$ virsh reboot 2

Forcefully Stop a VM (Guest OS):
Force a VM (guest) to stop with the virsh command can be not responding or crashed

Syntax:  $ virsh destroy {domain-id, domain-name or domain-uuid} 

Follow the below command:

 $ virsh list
$ virsh destroy DomainController
$ virsh destroy 2

Suspending a VMs (Guest OS):

Syntax:  $ virsh suspend {domain-id, domain-name or domain-uuid} 

Follow the below command:

$ virsh list
$ virsh suspend DomainController
$ virsh suspend 2

When a guest is in a suspended state, it consumes system Memory (RAM) but not the processor. Disk and network Input/Output does not occur while the VM (guest OS) is suspended. This operation is immediate and the guest can be restarted with the optionresume.

Resuming a VM (Guest OS):

Syntax:  $ virsh resume {domain-id, domain-name or domain-uuid}
$ virsh list
$ virsh resume DomainController
$ virsh resume 2

This operation is immediate and the VM (guest OS) parameters are preserved for suspend and resume operations.

Save a VM (Guest OS):

Syntax:  $ virsh save {domain-id, domain-name or domain-uuid} 
$ virsh list
$ virsh save DomainController
$ virsh save 2

This stops the VM and saves the data to a file, which may take some time given the amount of memory in use by your VM (guest). You can restore the state of the guest with the restore option. Save is similar to pause, instead of just pausing a guest the present state of the guest is saved.

Restore a VM (Guest OS):

Syntax:  $ virsh restore Filename 

This restarts the saved guest, which may take some time. The guest’s name and UUID are preserved but are allocated for a new id.


This article is contributed by RootLinuxBlog. If you like RootLinuxBlog and would like to contribute, you can submit an article using contact us from. See your article appearing on the RootLinuxBlog main page and help other Techies.
Please write comments if you found any error with the above article would really help us to serve you a better way. Thank you…


Please follow and like us:
KVM: Start & Stop Guest Operating Systems (VM) with virsh Command

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)

Facebook106
Facebook
LINKEDIN98