aboutsummaryrefslogtreecommitdiff
path: root/migration/ram.c
diff options
context:
space:
mode:
authorLiang Li <liang.z.li@intel.com>2016-05-05 15:32:54 +0800
committerAmit Shah <amit.shah@redhat.com>2016-06-17 18:24:18 +0530
commitb3be28969b797b27d7f7f806827e9898e4ee08f0 (patch)
tree924057e300d670d991903b374a3ea8bc89d65fd3 /migration/ram.c
parente7bb92e21a47c97dc477dc0dd49acf8ee0e633ad (diff)
qemu-file: Fix qemu_put_compression_data flaw
Current qemu_put_compression_data can only work with no writable QEMUFile, and can't work with the writable QEMUFile. But it does not provide any measure to prevent users from using it with a writable QEMUFile. We should fix this flaw to make it works with writable QEMUFile. Signed-off-by: Liang Li <liang.z.li@intel.com> Suggested-by: Juan Quintela <quintela@redhat.com> Message-Id: <1462433579-13691-5-git-send-email-liang.z.li@intel.com> Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'migration/ram.c')
-rw-r--r--migration/ram.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/migration/ram.c b/migration/ram.c
index 6416e60412..d30c923195 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -821,7 +821,13 @@ static int do_compress_ram_page(CompressParam *param)
RAM_SAVE_FLAG_COMPRESS_PAGE);
blen = qemu_put_compression_data(param->file, p, TARGET_PAGE_SIZE,
migrate_compress_level());
- bytes_sent += blen;
+ if (blen < 0) {
+ bytes_sent = 0;
+ qemu_file_set_error(migrate_get_current()->to_dst_file, blen);
+ error_report("compressed data failed!");
+ } else {
+ bytes_sent += blen;
+ }
return bytes_sent;
}
@@ -965,10 +971,12 @@ static int ram_save_compressed_page(QEMUFile *f, PageSearchStatus *pss,
* first page is sent out before other pages
*/
bytes_xmit = do_compress_ram_page(&comp_param[0]);
- acct_info.norm_pages++;
- qemu_put_qemu_file(f, comp_param[0].file);
- *bytes_transferred += bytes_xmit;
- pages = 1;
+ if (bytes_xmit > 0) {
+ acct_info.norm_pages++;
+ qemu_put_qemu_file(f, comp_param[0].file);
+ *bytes_transferred += bytes_xmit;
+ pages = 1;
+ }
}
} else {
pages = save_zero_page(f, block, offset, p, bytes_transferred);