Using KVM/libvirt/qemu

Setup KVM in Linux

Install virsh:

$ sudo apt-get install libvirt-bin
This can be local, or even remote. In most cases, if you want to manage VMs running on the local hypervisor:
$ virsh connect qemu:///system
List any existing VMs:
$ virsh list

You can export the XML of an existing virtual machine:

$ virsh dumpxml myoldvm > ~/myoldvm.xml

And then edit myoldvm.xml, which should be rather straightforward. For more information about libvirt XML format, see:
http://libvirt.org/format.html

Once you have an XML file describing the new virtual machine you want to create, import it into virsh, and run it immediately:

$ virsh create ~/myoldvm.xml
See if it worked:
$ virsh list

Working with a Running Virtual Machine:

$ virsh start mynewvm
$ virsh reboot mynewvm
$ virsh shutdown mynewvm
$ virsh suspend mynewvm
$ virsh resume mynewvm

To delete a virtual machine, first terminate it (if running), and then undefine it:

$ virsh destroy mynewvm
$ virsh undefine mynewvm
Posted in KVM