From 291c89038daccbb6697ecc68539acf92a323759e Mon Sep 17 00:00:00 2001 Message-Id: <291c89038daccbb6697ecc68539acf92a323759e.1421272770.git.jen@redhat.com> In-Reply-To: References: From: Juan Quintela Date: Wed, 7 Jan 2015 16:45:11 -0600 Subject: [CHANGE 07/10] migration: move bandwidth calculation to inside stage 2 To: rhvirt-patches@redhat.com, jen@redhat.com RH-Author: Juan Quintela Message-id: <1420649114-17435-8-git-send-email-quintela@redhat.com> Patchwork-id: 63164 O-Subject: [PATCH qemu-kvm RHEL6.7 07/10] migration: move bandwidth calculation to inside stage 2 Bugzilla: 970103 RH-Acked-by: Laszlo Ersek RH-Acked-by: Paolo Bonzini RH-Acked-by: Dr. David Alan Gilbert (git) It is not needed on the other cases Signed-off-by: Juan Quintela --- vl.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) Signed-off-by: Jeff E. Nelson --- vl.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/vl.c b/vl.c index e5d239a..5faf0bb 100644 --- a/vl.c +++ b/vl.c @@ -2859,7 +2859,6 @@ static int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) ram_addr_t addr; uint64_t bytes_transferred_last; uint64_t t0; - double bwidth = 0; int i; int ret; @@ -2931,12 +2930,6 @@ static int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) } t0 = get_clock() - t0; - bwidth = ((double)bytes_transferred - bytes_transferred_last) / t0; - - /* if we haven't transferred anything this round, force expected_time to a - * a very high value, but without crashing */ - if (bwidth == 0) - bwidth = 0.000001; /* try transferring iterative blocks of memory */ if (stage == 3) { @@ -2953,6 +2946,16 @@ static int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) if (stage == 2) { uint64_t expected_time; + double bwidth = 0; + + bwidth = ((double)bytes_transferred - bytes_transferred_last) / t0; + + /* + * if we haven't transferred anything this round, force expected_time to a + * a very high value, but without crashing + */ + if (bwidth == 0) + bwidth = 0.000001; expected_time = ram_bytes_remaining() / bwidth; return expected_time <= migrate_max_downtime(); -- 2.1.0