Migrate KVM Guest running on LVM to another KVM Hypervizor.

Sharing tutorial how I have migrated vm.belomor.nl…

**///////////////// Create the key pair:

# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
02:39:0b:41:de:2e:1c:65:dd:54:82:5a:64:68:1f:e0 root@source-kvm
The key's randomart image is:
+--[ RSA 2048]----+
| .o +=o+o..      |
| . *oo= ..       |
|  +.E+ .         |
| . +.+.          |
|  o o . S        |
|   .   .         |
|                 |
|                 |
|                 |
+-----------------+

**/////////////////Share pubkey between the two hosts from source server

# ssh-copy-id root@destination-kvm
root@destination-kvm's password: 
Now try logging into the machine, with "ssh 'root@destination-kvm'", and check in:

  .ssh/authorized_keys

to make sure we haven’t added extra keys that you weren’t expecting.

**/////////////////Create Logical Volume on target:

# lvcreate -L 50G -n vm.belomor.nl vol_group_vm</strong>
  Logical volume "vm.belomor.nl" created

**/////////////////Pipe the volume to the target host:

# dd if=/dev/vol_group_vm/vm.belomor.nl | ssh root@destination-kvm 'dd of=/dev/vol_group_vm/vm.belomor.nl'

104857600+0 records in
104857600+0 records out
53687091200 bytes (54 GB) copied, 2632.79 s, 20.4 MB/s

**/////////////////Cofee Brake :)
**/////////////////Cofee Brake :)
**/////////////////Dump the xml definition.

# virsh dumpxml vm.belomor.nl > vm.belomor.nl_dump.xml

**/////////////////Transfer xml-file:

# scp vm.belomor.nl_dump.xml root@destination-kvm:/root/
vm.belomor.nl_dump.xml

**/////////////////Define the machine on target:

# virsh define vm.belomor.nl_dump.xml

Domain vm.belomor.nl defined from vm.belomor.nl_dump.xml

**/////////////////Start transferred machine:

# virsh start vm.belomor.nl

#######################AFTER SUCCESSFUL MIGRATION YOU CAN PROCEED WITH CLEAN UP PROCEDURE:

# virsh undefine vm.belomor.nl
Domain vm.belomor.nl has been undefined

# lvremove /dev/vol_group_vm/vm.belomor.nl 
Do you really want to remove active logical volume vm.belomor.nl? [y/n]: y
  Logical volume "vm.belomor.nl" successfully removed

Done...
# date
Tue Apr  5 13:56:10 AZT 2016

[email protected]; [email protected]