mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
vfio: Introduce a new header file for external migration services
The migration core subsystem makes use of the VFIO migration API to collect statistics on the number of bytes transferred. These services are declared in "hw/vfio/vfio-common.h" which also contains VFIO internal declarations. Move the migration declarations into a new header file "hw/vfio/vfio-migration.h" to reduce the exposure of VFIO internals. While at it, use a 'vfio_migration_' prefix for these services. To be noted, vfio_migration_add_bytes_transferred() is a VFIO migration internal service which we will be moved in the subsequent patches. Cc: Kirti Wankhede <kwankhede@nvidia.com> Cc: Avihai Horon <avihaih@nvidia.com> Reviewed-by: Prasad Pandit <pjp@fedoraproject.org> Reviewed-by: John Levon <john.levon@nutanix.com> Reviewed-by: Avihai Horon <avihaih@nvidia.com> Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-4-clg@redhat.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
426ffab477
commit
e1d4ea53d6
5 changed files with 30 additions and 15 deletions
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/vfio/vfio-common.h"
|
||||
#include "hw/vfio/vfio-migration.h"
|
||||
#include "migration/misc.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/bswap.h"
|
||||
|
@ -575,7 +576,7 @@ vfio_save_complete_precopy_thread_config_state(VFIODevice *vbasedev,
|
|||
return false;
|
||||
}
|
||||
|
||||
vfio_mig_add_bytes_transferred(packet_len);
|
||||
vfio_migration_add_bytes_transferred(packet_len);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -645,7 +646,7 @@ vfio_multifd_save_complete_precopy_thread(SaveLiveCompletePrecopyThreadData *d,
|
|||
goto thread_exit;
|
||||
}
|
||||
|
||||
vfio_mig_add_bytes_transferred(packet_size);
|
||||
vfio_migration_add_bytes_transferred(packet_size);
|
||||
}
|
||||
|
||||
if (!vfio_save_complete_precopy_thread_config_state(vbasedev,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "system/runstate.h"
|
||||
#include "hw/vfio/vfio-common.h"
|
||||
#include "hw/vfio/vfio-migration.h"
|
||||
#include "migration/misc.h"
|
||||
#include "migration/savevm.h"
|
||||
#include "migration/vmstate.h"
|
||||
|
@ -373,7 +374,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);
|
||||
vfio_mig_add_bytes_transferred(data_size);
|
||||
vfio_migration_add_bytes_transferred(data_size);
|
||||
|
||||
trace_vfio_save_block(migration->vbasedev->name, data_size);
|
||||
|
||||
|
@ -1047,22 +1048,22 @@ static int vfio_block_migration(VFIODevice *vbasedev, Error *err, Error **errp)
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int64_t vfio_mig_bytes_transferred(void)
|
||||
int64_t vfio_migration_bytes_transferred(void)
|
||||
{
|
||||
return MIN(qatomic_read(&bytes_transferred), INT64_MAX);
|
||||
}
|
||||
|
||||
void vfio_mig_reset_bytes_transferred(void)
|
||||
void vfio_migration_reset_bytes_transferred(void)
|
||||
{
|
||||
qatomic_set(&bytes_transferred, 0);
|
||||
}
|
||||
|
||||
void vfio_mig_add_bytes_transferred(unsigned long val)
|
||||
void vfio_migration_add_bytes_transferred(unsigned long val)
|
||||
{
|
||||
qatomic_add(&bytes_transferred, val);
|
||||
}
|
||||
|
||||
bool vfio_mig_active(void)
|
||||
bool vfio_migration_active(void)
|
||||
{
|
||||
VFIODevice *vbasedev;
|
||||
|
||||
|
|
|
@ -290,13 +290,10 @@ extern VFIODeviceList vfio_device_list;
|
|||
extern const MemoryListener vfio_memory_listener;
|
||||
extern int vfio_kvm_device_fd;
|
||||
|
||||
bool vfio_mig_active(void);
|
||||
int vfio_block_multiple_devices_migration(VFIODevice *vbasedev, Error **errp);
|
||||
void vfio_unblock_multiple_devices_migration(void);
|
||||
bool vfio_viommu_preset(VFIODevice *vbasedev);
|
||||
int64_t vfio_mig_bytes_transferred(void);
|
||||
void vfio_mig_reset_bytes_transferred(void);
|
||||
void vfio_mig_add_bytes_transferred(unsigned long val);
|
||||
void vfio_migration_add_bytes_transferred(unsigned long val);
|
||||
bool vfio_device_state_is_running(VFIODevice *vbasedev);
|
||||
bool vfio_device_state_is_precopy(VFIODevice *vbasedev);
|
||||
|
||||
|
|
16
include/hw/vfio/vfio-migration.h
Normal file
16
include/hw/vfio/vfio-migration.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* VFIO migration interface
|
||||
*
|
||||
* Copyright Red Hat, Inc. 2025
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef HW_VFIO_VFIO_MIGRATION_H
|
||||
#define HW_VFIO_VFIO_MIGRATION_H
|
||||
|
||||
bool vfio_migration_active(void);
|
||||
int64_t vfio_migration_bytes_transferred(void);
|
||||
void vfio_migration_reset_bytes_transferred(void);
|
||||
|
||||
#endif /* HW_VFIO_VFIO_MIGRATION_H */
|
|
@ -11,21 +11,21 @@
|
|||
#include CONFIG_DEVICES
|
||||
|
||||
#ifdef CONFIG_VFIO
|
||||
#include "hw/vfio/vfio-common.h"
|
||||
#include "hw/vfio/vfio-migration.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_VFIO
|
||||
void migration_populate_vfio_info(MigrationInfo *info)
|
||||
{
|
||||
if (vfio_mig_active()) {
|
||||
if (vfio_migration_active()) {
|
||||
info->vfio = g_malloc0(sizeof(*info->vfio));
|
||||
info->vfio->transferred = vfio_mig_bytes_transferred();
|
||||
info->vfio->transferred = vfio_migration_bytes_transferred();
|
||||
}
|
||||
}
|
||||
|
||||
void migration_reset_vfio_bytes_transferred(void)
|
||||
{
|
||||
vfio_mig_reset_bytes_transferred();
|
||||
vfio_migration_reset_bytes_transferred();
|
||||
}
|
||||
#else
|
||||
void migration_populate_vfio_info(MigrationInfo *info)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue