summaryrefslogtreecommitdiffstats
path: root/arch_init.c
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2012-05-22 00:44:24 +0200
committerJuan Quintela <quintela@redhat.com>2012-06-29 13:28:09 +0200
commit5b3c96388741a99988497d734edec19c4f995cd7 (patch)
tree1cd27ad1526c611b340bf644e0974667234f76f0 /arch_init.c
parentd24981d37e793b0a8fcde1879db19eb11fe0f975 (diff)
downloadhqemu-5b3c96388741a99988497d734edec19c4f995cd7.zip
hqemu-5b3c96388741a99988497d734edec19c4f995cd7.tar.gz
Only calculate expected_time for stage 2
ram_save_remaining() is an expensive operation when there is a lot of memory. So we only call the function when we need it. Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'arch_init.c')
-rw-r--r--arch_init.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/arch_init.c b/arch_init.c
index f106928..3633f4c 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -314,7 +314,6 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque)
ram_addr_t addr;
uint64_t bytes_transferred_last;
double bwidth = 0;
- uint64_t expected_time = 0;
int ret;
if (stage < 0) {
@@ -391,12 +390,16 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque)
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
- expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
+ if (stage == 2) {
+ uint64_t expected_time;
+ expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth;
- DPRINTF("ram_save_live: expected(" PRIu64 ") <= max(" PRIu64 ")?\n",
- expected_time, migrate_max_downtime());
+ DPRINTF("ram_save_live: expected(" PRIu64 ") <= max(" PRIu64 ")?\n",
+ expected_time, migrate_max_downtime());
- return (stage == 2) && (expected_time <= migrate_max_downtime());
+ return expected_time <= migrate_max_downtime();
+ }
+ return 0;
}
static inline void *host_from_stream_offset(QEMUFile *f,
OpenPOWER on IntegriCloud