diff options
author | Juan Quintela <quintela@redhat.com> | 2023-10-25 11:11:07 +0200 |
---|---|---|
committer | Juan Quintela <quintela@redhat.com> | 2023-10-31 08:44:33 +0100 |
commit | 2d897237e01a7ed0dd8b9ac3b3a8234900145350 (patch) | |
tree | 38ba5e4bb447a3526386c947bc19cc69bf514305 /migration | |
parent | cc8bf57d56ef22a66711100f5d94861a627e9b9f (diff) | |
download | qemu-2d897237e01a7ed0dd8b9ac3b3a8234900145350.zip qemu-2d897237e01a7ed0dd8b9ac3b3a8234900145350.tar.gz qemu-2d897237e01a7ed0dd8b9ac3b3a8234900145350.tar.bz2 |
qemu_file: Use a stat64 for qemu_file_transferred
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>
Diffstat (limited to 'migration')
-rw-r--r-- | migration/migration-stats.h | 4 | ||||
-rw-r--r-- | migration/qemu-file.c | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/migration/migration-stats.h b/migration/migration-stats.h index 2358caa..b7795e7 100644 --- a/migration/migration-stats.h +++ b/migration/migration-stats.h @@ -82,6 +82,10 @@ typedef struct { */ Stat64 precopy_bytes; /* + * Number of bytes transferred with QEMUFile. + */ + Stat64 qemu_file_transferred; + /* * Amount of transferred data at the start of current cycle. */ Stat64 rate_limit_start; diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 6814c56..384985f 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -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); @@ -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)); @@ -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) |