Jaime Frutos Morales's blog


How to manage KVM virtual machines using virsh

Filed under: Linux, SysAdmin, Virtualization — acidborg @ 13:17

Description: virsh is a program which uses libvirt to manage KVM virtual machines (guests). I’m going to show a summary of its main functions (cheat sheet style):

Show guests’ information:

  • Show a list of all the defined guests: virsh list --all
  • Show a guest’s info: virsh dominfo guest's_name

Start and stop guests:

  • Start a guest: virsh start guest's_name
  • Shutdown a guest (gently): virsh shutdown guest's_name
  • Shutdown a guest (wild): virsh destroy guest's_name
  • Suspend a guest: virsh suspend guest's_name
  • Resume a suspended guest: virsh resume guest's_name

Create and modify guests:

  • Create a new guest
  • Create a guest from its XML definition: virsh create xml_file.xml
  • Dump a guest’s definition in XML: virsh dumpxml guest's_name
  • Modify a guest’s definition: virsh edit guest's_name
  • Remove a guest’s definition (it doesn’t remove the image file): virsh undefine guest's_name

Backup and restore guests:

  • Save a guest’s state on a file: virsh save guest's_name guest's_state_file
  • Restore a guest from a state file: virsh restore guest's_state_file

I’m going to explain guests live migration on another post to keep this cheat sheet simple.

1 Comment

  1. i truly adore all your posting style, very useful,
    don’t quit as well as keep penning for the simple reason that it just very well worth to follow it,
    impatient to find out way more of your own articles, thanks šŸ˜‰

    Comment by Tiperroni — 20/03/2010 @ 08:32

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Blog at WordPress.com.

%d bloggers like this: