Prepare a VM ------------ Get a CirrOS disk image: $ wget http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img Import it into libvirt: $ virt-install --name cvm1 --ram 1024 \ --disk path=/var/lib/libvirt/images/cirros-0.3.3-x86_64-disk.img,format=qcow2 \ --nographics --import --os-variant fedora21 Live migration with libvirt --------------------------- (1) On source, setup SSH keys and agent and copy the key to the remote host: $ ssh-keygen -t rsa $ eval `ssh-agent` $ ssh-add .ssh/id_rsa $ ssh-copy-id root@devstack3 And, ensure the below are the permissions on both sides: $ ls -lasrt ~/.ssh/ total 24 4 -rw-r--r--. 1 root root 400 Apr 3 02:25 id_rsa.pub 4 -rw-r--r--. 1 root root 824 Apr 3 02:25 known_hosts 4 -rw-r--r--. 1 root root 396 Apr 3 11:04 authorized_keys 4 dr-xr-x---. 6 root root 4096 Apr 3 14:35 .. 4 -rw-------. 1 root root 1679 Apr 3 14:40 id_rsa 4 drwx------. 2 root root 4096 Apr 3 14:40 . (2) So that, the below works without any password prompts: $ virsh -c qemu+ssh://kashyapc@devstack3/system Welcome to virsh, the virtualization interactive terminal. Type: 'help' for help with commands 'quit' to quit virsh # (3) NOTE: Before performing the non-shared live migration, ensure you have the default storage pool exists (/var/lib/libvirt/images). If not, quickly create it and start it as below $ virsh pool-define-as --name default --type dir \ --target /var/lib/libvirt/images/ $ virsh pool-autostart default $ virsh pool-build default $ virsh pool-start defaul (4) Perform non-shared storage migration, there are two ways: (4.1) Managed direct migration: Run as root: $ virsh migrate --verbose --copy-storage-all --persistent \ --live cvm1 qemu+ssh://root@devstack3/system Migration: [100 %] (4.2) Managed peer to peer migration: Having SSH to the remote machine work as 'root' _without_ any password agent is important in this case, because the src libvirtd will not have acces to the SSH agent! $ virsh migrate --verbose --copy-storage-all --p2p --live cvm1 \ qemu+ssh://root@devstack3/system Migration: [100 %] NOTE: In this setup ther libvirt *client* process controls the various phases of migration: http://libvirt.org/migration.html#flowmanageddirect Verify ------ On the source host, the guest should be shut off: SOURCE: virsh list Id Name State ---------------------------------------------------- - cvm1 shut off And, on the destination host, the guest is running and migrated successfully: DEST$ virsh list Id Name State ---------------------------------------------------- 2 cvm1 running (NOTE: If you don't supply --persistent flag in step (4) the libvirt guest on the destination is transient i.e. if you force power off the guest, the libvirt XML definition will be gone, but the disk image will be retained.) Additional notes ---------------- - Don't forget to: virsh undefine --remove-all-storage cvm1 virsh pool-refresh default