]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches-0.12.1/live-migration-fixes.diff
bump version to 2.9.0-1~rc2+5
[pve-qemu-kvm.git] / debian / patches-0.12.1 / live-migration-fixes.diff
1 Index: qemu-kvm/vl.c
2 ===================================================================
3 --- qemu-kvm.orig/vl.c 2009-09-30 10:35:45.000000000 +0200
4 +++ qemu-kvm/vl.c 2009-09-30 10:47:05.000000000 +0200
5 @@ -3175,9 +3175,10 @@
6 static int ram_save_live(QEMUFile *f, int stage, void *opaque)
7 {
8 ram_addr_t addr;
9 - uint64_t bytes_transferred_last;
10 double bwidth = 0;
11 uint64_t expected_time = 0;
12 + static int64_t starttime = 0;
13 + double timediff;
14
15 if (cpu_physical_sync_dirty_bitmap(0, TARGET_PHYS_ADDR_MAX) != 0) {
16 qemu_file_set_error(f);
17 @@ -3195,10 +3196,9 @@
18 cpu_physical_memory_set_dirty_tracking(1);
19
20 qemu_put_be64(f, last_ram_offset | RAM_SAVE_FLAG_MEM_SIZE);
21 - }
22
23 - bytes_transferred_last = bytes_transferred;
24 - bwidth = get_clock();
25 + starttime = get_clock();
26 + }
27
28 while (!qemu_file_rate_limit(f)) {
29 int ret;
30 @@ -3209,8 +3209,8 @@
31 break;
32 }
33
34 - bwidth = get_clock() - bwidth;
35 - bwidth = (bytes_transferred - bytes_transferred_last) / bwidth;
36 + timediff = get_clock() - starttime;
37 + bwidth = bytes_transferred / timediff;
38
39 /* if we haven't transferred anything this round, force expected_time to a
40 * a very high value, but without crashing */
41 @@ -3230,6 +3230,10 @@
42
43 qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
44
45 + if ((stage == 2) && (bytes_transferred > 2*ram_bytes_total())) {
46 + return 1;
47 + }
48 +
49 expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
50
51 return (stage == 2) && (expected_time <= migrate_max_downtime());