How to migrate a running KVM (with full disk copy) to another node?

I'm doing tests on KVM, and I'd like to see if I can make a hot migration, I mean the virtual machine won't stop running during the migration (but a few seconds of freeze is ok). I use a small cluster for my test : kvm1, kvm2, and kvmnfs.

  • kvm1 and kvm2 runs the virtual machines
  • kvmnfs is a NFS server, and it's mounted on /KVM on both kvm1 and kvm2

To migrate a VM (only RAM in fact) from kvm1 to kvm2, I run the same kvm command on kvm2 (with -incoming tcp:0:4444) that on kvm1, then I use "migrate -d tcp:kvm2:4444" : It works great, since the VM file is common to both machines.

Now, I wan't to make a full migration (RAM + disk) of a local VM file (no more NFS) of kvm1 to kvm2. I tried to create an empty file, with touch, on kvm2 and use the same kvm command line + the "-incoming ..."). Then on kvm1 I use "migrate -d tcp:kvm2:4444" : It copies everything, then... the VM fails (any I/O disk gives an I/O error) ! And my VM file on kvm2, the one I created with touch, as still a size of 0 bytes.

What am I doing wrong ? What is the exact command to use on kvm2 ? And what is the command to launch, in the monitoring mode, on kvm1 ?


Solution 1:

not possible. you either have a centralised storage (cluster FS + SAN/DAS or NFS) with the image accessible by both hosts, or keep the images in sync with something like drbd

//copied as an answer.

addition: you COULD script this, byt suspending guest to RAM, dd-ing the image over to the other host, dd-ing the memstate, and resuming the VM. but downtime will be comparable to stopping VM, copying it and starting again