Steps of live migration under QEMU&&KVM.

A is the source host, B is the destination host.

1. launch source VM on A

1
<qemu-command-line>
1
2
3
4
5
6
7
8
9
#! /bin/bash -x
qemu-system-x86_64 \
-enable-kvm \
-m 4096 \
-smp 2 \
-cpu host \
-drive format=raw,file=laag.img \
-serial mon:stdio \
-vnc :3

2. launch destination VM on B

Start the VM on B with the exact same parameters as the VM on A, in migration-listen mode:

1
<qemu-command-line> -incoming tcp:0:4444
1
2
3
4
5
6
7
8
9
10
#! /bin/bash -x
qemu-system-x86_64 \
-enable-kvm \
-m 4096 \
-smp 2 \
-cpu host \
-drive format=raw,file=laag.img \
-serial mon:stdio \
-vnc :4 \
-incoming tcp:0:4444

3. start the migration (on A only)

1
(qemu)migrate -d tcp:<host B IP>:4444
1
(qemu)migrate -d tcp:localhost:4444

4. check the status (on A only)

1
(qemu) info migrate

When completed, get can the info: Migration status: completed. The source VM will stop at the end.

5. misc

1
2
3
4
5
(qemu) help migrate
migrate [-d] [-b] [-i] [-r] uri -- migrate to URI (using -d to not wait for completion)
-b for migration without shared storage with full copy of disk
-i for migration without shared storage with incremental copy of disk (base image shared between src and destination)
-r to resume a paused migration

The ‘-d’ will let you query the status of the migration. With no ‘-d’ the monitor prompt returns when the migration completes.


参考资料:

  1. page/Migration
  2. qemu热迁移简介