< Previous | Contents | Next >
1.5.1. virsh
There are several utilities available to manage virtual machines and libvirt. The virsh utility can be used from the command line. Some examples:
• To list running virtual machines:
virsh list
• To start a virtual machine:
virsh start web_devel
• Similarly, to start a virtual machine at boot:
virsh autostart web_devel
• Reboot a virtual machine with:
virsh reboot web_devel
• The state of virtual machines can be saved to a file in order to be restored later. The following will save the virtual machine state into a file named according to the date:
virsh save web_devel web_devel-022708.state
Once saved the virtual machine will no longer be running.
• A saved virtual machine can be restored using:
virsh restore web_devel-022708.state
• To shutdown a virtual machine do:
virsh shutdown web_devel
• A CDROM device can be mounted in a virtual machine by entering:
virsh attach-disk web_devel /dev/cdrom /media/cdrom
In the above examples replace web_devel with the appropriate virtual machine name, and
web_devel-022708.state with a descriptive file name.
If virsh (or other vir* tools) shall connect to something else than the default qemu-kvm/system hipervisor one can find alternatives for the connect option in man virsh or libvirt doc2