KVM - Move Guest to Another Host

Say you got a new KVM hypervisor (kvm02) and want to move a VM to it from an older host (kvm01). You are OK to shut the VM down while the VM is being transfered (this is not a live migration).

This is what you do:

On the Old Host (kvm01)

  • shutdown the VM
  • dump its definition to /tmp/vm.xml and copy it over to the new host
  • copy the VM's image to the new host
  • undefine the VM and delete its image
virsh shutdown vm

virsh dumpxml vm > /tmp/vm.xml
scp /tmp/vm.xml kvm02:/tmp/vm.xml

scp /var/lib/libvirt/images/vm.qcow2 kvm02:/var/lib/libvirt/images/vm.qcow2

virsh undefine vm
rm /var/lib/libvirt/images/vm.qcow2

On the New Host (kvm02)

  • define the VM from /tmp/vm.xml
  • start the VM
virsh define /tmp/vm.xml
Domain vm defined from /tmp/vm.xml

virsh start vm