Message ID | 1449201190-22825-2-git-send-email-liang.z.li@intel.com |
---|---|
State | New |
Headers | show |
On (Fri) 04 Dec 2015 [11:53:09], Liang Li wrote: > There are some flaws in qemu_put_compression_data, this patch tries > to fix it. Now it can be used by other code. Can you please write a better description here? What are the flaws? What is being fixed? What other users, and how is it now safer for the other users to use this code? Thanks, Amit
> On (Fri) 04 Dec 2015 [11:53:09], Liang Li wrote: > > There are some flaws in qemu_put_compression_data, this patch tries to > > fix it. Now it can be used by other code. > > Can you please write a better description here? What are the flaws? > What is being fixed? What other users, and how is it now safer for the other > users to use this code? > no problem, will add it in next version. Thanks, Liang > Thanks, > > Amit
diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 0bbd257..ef9cd4a 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -616,7 +616,9 @@ ssize_t qemu_put_compression_data(QEMUFile *f, const uint8_t *p, size_t size, ssize_t blen = IO_BUF_SIZE - f->buf_index - sizeof(int32_t); if (blen < compressBound(size)) { - return 0; + if (f->ops->writev_buffer || f->ops->put_buffer) { + qemu_fflush(f); + } } if (compress2(f->buf + f->buf_index + sizeof(int32_t), (uLongf *)&blen, (Bytef *)p, size, level) != Z_OK) { @@ -624,7 +626,13 @@ ssize_t qemu_put_compression_data(QEMUFile *f, const uint8_t *p, size_t size, return 0; } qemu_put_be32(f, blen); + if (f->ops->writev_buffer) { + add_to_iovec(f, f->buf + f->buf_index, blen); + } f->buf_index += blen; + if (f->buf_index == IO_BUF_SIZE) { + qemu_fflush(f); + } return blen + sizeof(int32_t); }
There are some flaws in qemu_put_compression_data, this patch tries to fix it. Now it can be used by other code. Signed-off-by: Liang Li <liang.z.li@intel.com> --- migration/qemu-file.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)