Skip to content

Commit

Permalink
qemu_file: Use a stat64 for qemu_file_transferred
Browse files Browse the repository at this point in the history
This way we can read it from any thread.
I checked that it gives the same value as the current one.  We never
use two qemu_files at the same time.

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231025091117.6342-3-quintela@redhat.com>
  • Loading branch information
Juan Quintela committed Oct 31, 2023
1 parent cc8bf57 commit 2d89723
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions migration/migration-stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ typedef struct {
* Number of bytes sent during precopy stage.
*/
Stat64 precopy_bytes;
/*
* Number of bytes transferred with QEMUFile.
*/
Stat64 qemu_file_transferred;
/*
* Amount of transferred data at the start of current cycle.
*/
Expand Down
5 changes: 3 additions & 2 deletions migration/qemu-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ void qemu_fflush(QEMUFile *f)
} else {
uint64_t size = iov_size(f->iov, f->iovcnt);
f->total_transferred += size;
stat64_add(&mig_stats.qemu_file_transferred, size);
}

qemu_iovec_release_ram(f);
Expand Down Expand Up @@ -623,7 +624,7 @@ int coroutine_mixed_fn qemu_get_byte(QEMUFile *f)

uint64_t qemu_file_transferred_noflush(QEMUFile *f)
{
uint64_t ret = f->total_transferred;
uint64_t ret = stat64_get(&mig_stats.qemu_file_transferred);
int i;

g_assert(qemu_file_is_writable(f));
Expand All @@ -639,7 +640,7 @@ uint64_t qemu_file_transferred(QEMUFile *f)
{
g_assert(qemu_file_is_writable(f));
qemu_fflush(f);
return f->total_transferred;
return stat64_get(&mig_stats.qemu_file_transferred);
}

void qemu_put_be16(QEMUFile *f, unsigned int v)
Expand Down

0 comments on commit 2d89723

Please sign in to comment.