The most convenient is simply:
# virt-clone --connect=qemu://example.com/system -o this-vm -n that-vm --auto-clone
Which will make a copy of this-vm
, named that-vm
, and takes care of duplicating storage devices. Nothing new here except details.
More to the point, What the FAQ is saying is that the XML domain descriptions are not directly editable, you need to go through libvirt. To complete the steps taken by the virt-clone
command, you could:
source_vm=vm_name
new_vm=new_vm_name
# You cannot "clone" a running vm, stop it. suspend and destroy
# are also valid options for less graceful cloning
virsh shutdown "$source_vm"
# copy the storage image.
cp /var/lib/libvirt/images/{"$source_vm","$new_vm"}.img
# dump the xml for the original
virsh dumpxml "$source_vm" > "/tmp/$new_vm.xml"
# hardware addresses need to be removed, libvirt will assign
# new addresses automatically
sed -i /uuid/d "/tmp/$new_vm.xml"
sed -i '/mac address/d' "/tmp/$new_vm.xml"
# and actually rename the vm:
#(this also updates the storage path)
sed -i "s/$source_vm/$new_vm/" "/tmp/$new_vm.xml"
# finally, create the new vm
virsh define "/tmp/$new_vm.xml"
virsh start "$source_vm"
virsh start "$new_vm"