[PATCH 01/12] qemu-file: We only call qemu_file_transferred_* on the sending side

Juan Quintela posted 12 patches 2 years, 2 months ago
Maintainers: Stefan Hajnoczi <stefanha@redhat.com>, Fam Zheng <fam@euphon.net>, Juan Quintela <quintela@redhat.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Leonardo Bras <leobras@redhat.com>, Hailiang Zhang <zhanghailiang@xfusion.com>, Li Zhijian <lizhijian@fujitsu.com>
There is a newer version of this series
[PATCH 01/12] qemu-file: We only call qemu_file_transferred_* on the sending side
Posted by Juan Quintela 2 years, 2 months ago
Remove the increase in qemu_file_fill_buffer() and add asserts to
qemu_file_transferred* functions.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration/qemu-file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index 3fb25148d1..6814c562e6 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -337,7 +337,6 @@ static ssize_t coroutine_mixed_fn qemu_fill_buffer(QEMUFile *f)
 
     if (len > 0) {
         f->buf_size += len;
-        f->total_transferred += len;
     } else if (len == 0) {
         qemu_file_set_error_obj(f, -EIO, local_error);
     } else {
@@ -627,6 +626,8 @@ uint64_t qemu_file_transferred_noflush(QEMUFile *f)
     uint64_t ret = f->total_transferred;
     int i;
 
+    g_assert(qemu_file_is_writable(f));
+
     for (i = 0; i < f->iovcnt; i++) {
         ret += f->iov[i].iov_len;
     }
@@ -636,6 +637,7 @@ uint64_t qemu_file_transferred_noflush(QEMUFile *f)
 
 uint64_t qemu_file_transferred(QEMUFile *f)
 {
+    g_assert(qemu_file_is_writable(f));
     qemu_fflush(f);
     return f->total_transferred;
 }
-- 
2.41.0
Re: [PATCH 01/12] qemu-file: We only call qemu_file_transferred_* on the sending side
Posted by Fabiano Rosas 2 years, 2 months ago
Juan Quintela <quintela@redhat.com> writes:

> Remove the increase in qemu_file_fill_buffer() and add asserts to
> qemu_file_transferred* functions.

Patch looks ok, but I would rewrite the whole commit message like this:

Don't increment qemu_file_transferred at qemu_file_fill_buffer

We only call qemu_file_transferred_* on the sending side. Remove the
increment at qemu_file_fill_buffer() and add asserts to
qemu_file_transferred* functions.
Re: [PATCH 01/12] qemu-file: We only call qemu_file_transferred_* on the sending side
Posted by Juan Quintela 2 years, 2 months ago
Fabiano Rosas <farosas@suse.de> wrote:
> Juan Quintela <quintela@redhat.com> writes:
>
>> Remove the increase in qemu_file_fill_buffer() and add asserts to
>> qemu_file_transferred* functions.
>
> Patch looks ok, but I would rewrite the whole commit message like this:
>
> Don't increment qemu_file_transferred at qemu_file_fill_buffer
>
> We only call qemu_file_transferred_* on the sending side. Remove the
> increment at qemu_file_fill_buffer() and add asserts to
> qemu_file_transferred* functions.

Changed the commint text.

Thanks,