[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/16] qemu_file: Use a stat64 for qemu_file_transferred
From: |
Juan Quintela |
Subject: |
[PATCH 06/16] qemu_file: Use a stat64 for qemu_file_transferred |
Date: |
Tue, 30 May 2023 14:28:03 +0200 |
This way we can read it from any thread.
I checked that it gives the same value than the current one. We never
use to qemu_files at the same time.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
migration/migration-stats.h | 4 ++++
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 2358caad63..b7795e7914 100644
--- a/migration/migration-stats.h
+++ b/migration/migration-stats.h
@@ -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.
*/
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index 5ff3bc40fd..ac7a303142 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -286,6 +286,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);
@@ -628,7 +629,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));
@@ -644,7 +645,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)
--
2.40.1
- [PATCH 11/16] migration: migration_transferred_bytes() don't need the QEMUFile, (continued)
- [PATCH 11/16] migration: migration_transferred_bytes() don't need the QEMUFile, Juan Quintela, 2023/05/30
- [PATCH 12/16] migration: migration_rate_limit_reset() don't need the QEMUFile, Juan Quintela, 2023/05/30
- [PATCH 14/16] migration: Use migration_transferred_bytes(), Juan Quintela, 2023/05/30
- [PATCH 15/16] migration: Remove transferred atomic counter, Juan Quintela, 2023/05/30
- [PATCH 16/16] qemu-file: Make qemu_fflush() return errors, Juan Quintela, 2023/05/30
- [PATCH 02/16] migration: Change qemu_file_transferred to noflush, Juan Quintela, 2023/05/30
- [PATCH 06/16] qemu_file: Use a stat64 for qemu_file_transferred,
Juan Quintela <=
- [PATCH 03/16] migration: Use qemu_file_transferred_noflush() for block migration., Juan Quintela, 2023/05/30
- [PATCH 13/16] qemu-file: Simplify qemu_file_get_error(), Juan Quintela, 2023/05/30
- [PATCH 05/16] qemu-file: We only call qemu_file_transferred_* on the sending side, Juan Quintela, 2023/05/30
- [PATCH 08/16] migration: Use the number of transferred bytes directly, Juan Quintela, 2023/05/30
- [PATCH 09/16] qemu_file: Remove unused qemu_file_transferred(), Juan Quintela, 2023/05/30
- [PATCH 04/16] qemu-file: Don't call qemu_fflush() for read only files, Juan Quintela, 2023/05/30