]> git.proxmox.com Git - pve-qemu-kvm.git/blame_incremental - debian/patches/live-migration-fixes.diff
include updates from upstream
[pve-qemu-kvm.git] / debian / patches / live-migration-fixes.diff
... / ...
CommitLineData
1Index: new/arch_init.c
2===================================================================
3--- new.orig/arch_init.c 2012-02-09 13:15:26.000000000 +0100
4+++ new/arch_init.c 2012-02-09 13:22:53.000000000 +0100
5@@ -264,6 +264,8 @@
6 uint64_t bytes_transferred_last;
7 double bwidth = 0;
8 uint64_t expected_time = 0;
9+ static int64_t starttime = 0;
10+ double timediff;
11 int ret;
12
13 if (stage < 0) {
14@@ -299,10 +301,10 @@
15 qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr));
16 qemu_put_be64(f, block->length);
17 }
18+
19+ starttime = qemu_get_clock_ns(rt_clock);
20 }
21
22- bytes_transferred_last = bytes_transferred;
23- bwidth = qemu_get_clock_ns(rt_clock);
24
25 while ((ret = qemu_file_rate_limit(f)) == 0) {
26 int bytes_sent;
27@@ -318,8 +320,8 @@
28 return ret;
29 }
30
31- bwidth = qemu_get_clock_ns(rt_clock) - bwidth;
32- bwidth = (bytes_transferred - bytes_transferred_last) / bwidth;
33+ timediff = qemu_get_clock_ns(rt_clock) - starttime;
34+ bwidth = bytes_transferred / timediff;
35
36 /* if we haven't transferred anything this round, force expected_time to a
37 * a very high value, but without crashing */
38@@ -340,6 +342,10 @@
39
40 qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
41
42+ if ((stage == 2) && (bytes_transferred > 2*ram_bytes_total())) {
43+ return 1;
44+ }
45+
46 expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
47
48 return (stage == 2) && (expected_time <= migrate_max_downtime());