aboutsummaryrefslogtreecommitdiff
path: root/migration/block.c
diff options
context:
space:
mode:
authorWen Congyang <wency@cn.fujitsu.com>2015-11-20 17:37:13 +0800
committerJuan Quintela <quintela@redhat.com>2015-11-25 15:27:28 +0100
commitf77dcdbc76dbf9bade9739e85e1013639e535835 (patch)
treea9a7e78b4dcca4d788940ef876e1522bf671aad6 /migration/block.c
parent1d7414396f926651c4d7a673eb3a10aca5246d76 (diff)
block-migration: limit the memory usage
If we set migration speed in a very large value, block-migration will try to read all data to the memory. Because (block_mig_state.submitted + block_mig_state.read_done) * BLOCK_SIZE will be overflow, and it will be always less than rate limit. There is no need to read too many data into memory when the rate limit is very large. So limit the memory usage can fix the overflow problem. Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'migration/block.c')
-rw-r--r--migration/block.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/migration/block.c b/migration/block.c
index 310e2b36dc..656f38f341 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -36,6 +36,8 @@
#define MAX_IS_ALLOCATED_SEARCH 65536
+#define MAX_INFLIGHT_IO 512
+
//#define DEBUG_BLK_MIGRATION
#ifdef DEBUG_BLK_MIGRATION
@@ -665,7 +667,10 @@ static int block_save_iterate(QEMUFile *f, void *opaque)
blk_mig_lock();
while ((block_mig_state.submitted +
block_mig_state.read_done) * BLOCK_SIZE <
- qemu_file_get_rate_limit(f)) {
+ qemu_file_get_rate_limit(f) &&
+ (block_mig_state.submitted +
+ block_mig_state.read_done) <
+ MAX_INFLIGHT_IO) {
blk_mig_unlock();
if (block_mig_state.bulk_completed == 0) {
/* first finish the bulk phase */