Commit f77dcdbc authored by Wen Congyang's avatar Wen Congyang Committed by Juan Quintela
Browse files

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: default avatarWen Congyang <wency@cn.fujitsu.com>
Reviewed-by: default avatarJuan Quintela <quintela@redhat.com>
Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: default avatarJuan Quintela <quintela@redhat.com>
parent 1d741439
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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 */