diff options
author | Juan Quintela <quintela@redhat.com> | 2017-03-16 21:29:34 +0100 |
---|---|---|
committer | Juan Quintela <quintela@redhat.com> | 2017-04-21 12:25:39 +0200 |
commit | 6d358d94943076846328cc292e4f45c31e1d5d96 (patch) | |
tree | f1b63cbd71de5782e86d0f25ae199381834f82cb /migration | |
parent | ce25d33781c6c1d679ff6fd06b43188f4adb9c41 (diff) |
ram: Remove compression_switch and inline its logic
We can calculate its value, so we don't create a variable for it.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
--
After Peter and Dave review, I dropped the variable and just inlined
the condition.
Fix typo
Diffstat (limited to 'migration')
-rw-r--r-- | migration/ram.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/migration/ram.c b/migration/ram.c index 14d54fd052..fa5a2901dc 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -336,7 +336,6 @@ static QemuCond comp_done_cond; /* The empty QEMUFileOps will be used by file in CompressParam */ static const QEMUFileOps empty_ops = { }; -static bool compression_switch; static DecompressParam *decomp_param; static QemuThread *decompress_threads; static QemuMutex decomp_done_lock; @@ -420,7 +419,6 @@ void migrate_compress_threads_create(void) if (!migrate_use_compression()) { return; } - compression_switch = true; thread_count = migrate_compress_threads(); compress_threads = g_new0(QemuThread, thread_count); comp_param = g_new0(CompressParam, thread_count); @@ -1092,7 +1090,6 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, * point. In theory, xbzrle can do better than compression. */ flush_compressed_data(rs); - compression_switch = false; } } /* Didn't find anything this time, but try again on the new block */ @@ -1326,7 +1323,14 @@ static int ram_save_target_page(RAMState *rs, MigrationState *ms, /* Check the pages is dirty and if it is send it */ if (migration_bitmap_clear_dirty(rs, dirty_ram_abs)) { unsigned long *unsentmap; - if (compression_switch && migrate_use_compression()) { + /* + * If xbzrle is on, stop using the data compression after first + * round of migration even if compression is enabled. In theory, + * xbzrle can do better than compression. + */ + + if (migrate_use_compression() + && (rs->ram_bulk_stage || !migrate_use_xbzrle())) { res = ram_save_compressed_page(rs, ms, pss, last_stage); } else { res = ram_save_page(rs, ms, pss, last_stage); |