From 34ab9e9743aeaf265929d930747f101fa5c76fea Mon Sep 17 00:00:00 2001 From: Xiao Guangrong Date: Fri, 30 Mar 2018 15:51:22 +0800 Subject: migration: detect compression and decompression errors Currently the page being compressed is allowed to be updated by the VM on the source QEMU, correspondingly the destination QEMU just ignores the decompression error. However, we completely miss the chance to catch real errors, then the VM is corrupted silently To make the migration more robuster, we copy the page to a buffer first to avoid it being written by VM, then detect and handle the errors of both compression and decompression errors properly Reviewed-by: Peter Xu Signed-off-by: Xiao Guangrong Message-Id: <20180330075128.26919-5-xiaoguangrong@tencent.com> Signed-off-by: Dr. David Alan Gilbert --- migration/qemu-file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'migration/qemu-file.c') diff --git a/migration/qemu-file.c b/migration/qemu-file.c index bafe3a0..0463f4c 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -710,9 +710,9 @@ ssize_t qemu_put_compression_data(QEMUFile *f, z_stream *stream, blen = qemu_compress_data(stream, f->buf + f->buf_index + sizeof(int32_t), blen, p, size); if (blen < 0) { - error_report("Compress Failed!"); - return 0; + return -1; } + qemu_put_be32(f, blen); if (f->ops->writev_buffer) { add_to_iovec(f, f->buf + f->buf_index, blen, false); -- cgit v1.1