[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 21/24] vfio/migration: Convert bytes_transferred counter to at
From: |
Maciej S. Szmigiero |
Subject: |
[PATCH v3 21/24] vfio/migration: Convert bytes_transferred counter to atomic |
Date: |
Sun, 17 Nov 2024 20:20:16 +0100 |
From: "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>
So it can be safety accessed from multiple threads.
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
---
hw/vfio/migration.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 4b2b06b45195..683f2ae98d5e 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -391,7 +391,7 @@ static ssize_t vfio_save_block(QEMUFile *f, VFIOMigration
*migration)
qemu_put_be64(f, VFIO_MIG_FLAG_DEV_DATA_STATE);
qemu_put_be64(f, data_size);
qemu_put_buffer(f, migration->data_buffer, data_size);
- bytes_transferred += data_size;
+ qatomic_add(&bytes_transferred, data_size);
trace_vfio_save_block(migration->vbasedev->name, data_size);
@@ -1030,12 +1030,12 @@ static int vfio_block_migration(VFIODevice *vbasedev,
Error *err, Error **errp)
int64_t vfio_mig_bytes_transferred(void)
{
- return bytes_transferred;
+ return qatomic_read(&bytes_transferred);
}
void vfio_reset_bytes_transferred(void)
{
- bytes_transferred = 0;
+ qatomic_set(&bytes_transferred, 0);
}
/*
- [PATCH v3 14/24] migration/multifd: Make MultiFDSendData a struct, (continued)
- [PATCH v3 14/24] migration/multifd: Make MultiFDSendData a struct, Maciej S. Szmigiero, 2024/11/17
- [PATCH v3 15/24] migration/multifd: Add migration_has_device_state_support(), Maciej S. Szmigiero, 2024/11/17
- [PATCH v3 16/24] migration/multifd: Send final SYNC only after device state is complete, Maciej S. Szmigiero, 2024/11/17
- [PATCH v3 17/24] migration: Add save_live_complete_precopy_thread handler, Maciej S. Szmigiero, 2024/11/17
- [PATCH v3 18/24] vfio/migration: Don't run load cleanup if load setup didn't run, Maciej S. Szmigiero, 2024/11/17
- [PATCH v3 19/24] vfio/migration: Add x-migration-multifd-transfer VFIO property, Maciej S. Szmigiero, 2024/11/17
- [PATCH v3 20/24] vfio/migration: Add load_device_config_state_start trace event, Maciej S. Szmigiero, 2024/11/17
- [PATCH v3 22/24] vfio/migration: Multifd device state transfer support - receive side, Maciej S. Szmigiero, 2024/11/17
- [PATCH v3 21/24] vfio/migration: Convert bytes_transferred counter to atomic,
Maciej S. Szmigiero <=
- [PATCH v3 23/24] migration/qemu-file: Define g_autoptr() cleanup function for QEMUFile, Maciej S. Szmigiero, 2024/11/17
- [PATCH v3 24/24] vfio/migration: Multifd device state transfer support - send side, Maciej S. Szmigiero, 2024/11/17