summaryrefslogtreecommitdiffstats
path: root/hw/vfio
diff options
context:
space:
mode:
authorKirti Wankhede2020-10-26 10:36:27 +0100
committerAlex Williamson2020-11-01 20:30:51 +0100
commit3710586caa5d91a52c0cf247e1c829a50f2e7b98 (patch)
tree4c9b1e449ace7dcd6ff85756a4771dd84305d359 /hw/vfio
parentvfio: Make vfio-pci device migration capable (diff)
downloadqemu-3710586caa5d91a52c0cf247e1c829a50f2e7b98.tar.gz
qemu-3710586caa5d91a52c0cf247e1c829a50f2e7b98.tar.xz
qemu-3710586caa5d91a52c0cf247e1c829a50f2e7b98.zip
qapi: Add VFIO devices migration stats in Migration stats
Added amount of bytes transferred to the VM at destination by all VFIO devices Signed-off-by: Kirti Wankhede <kwankhede@nvidia.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'hw/vfio')
-rw-r--r--hw/vfio/common.c19
-rw-r--r--hw/vfio/migration.c9
2 files changed, 28 insertions, 0 deletions
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 620358a3d8..d41ba67ffb 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -292,6 +292,25 @@ const MemoryRegionOps vfio_region_ops = {
* Device state interfaces
*/
+bool vfio_mig_active(void)
+{
+ VFIOGroup *group;
+ VFIODevice *vbasedev;
+
+ if (QLIST_EMPTY(&vfio_group_list)) {
+ return false;
+ }
+
+ QLIST_FOREACH(group, &vfio_group_list, next) {
+ QLIST_FOREACH(vbasedev, &group->device_list, next) {
+ if (vbasedev->migration_blocker) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
static bool vfio_devices_all_stopped_and_saving(VFIOContainer *container)
{
VFIOGroup *group;
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index a248effb37..3ce285ea39 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -45,6 +45,8 @@
#define VFIO_MIG_FLAG_DEV_SETUP_STATE (0xffffffffef100003ULL)
#define VFIO_MIG_FLAG_DEV_DATA_STATE (0xffffffffef100004ULL)
+static int64_t bytes_transferred;
+
static inline int vfio_mig_access(VFIODevice *vbasedev, void *val, int count,
off_t off, bool iswrite)
{
@@ -255,6 +257,7 @@ static int vfio_save_buffer(QEMUFile *f, VFIODevice *vbasedev, uint64_t *size)
*size = data_size;
}
+ bytes_transferred += data_size;
return ret;
}
@@ -785,6 +788,7 @@ static void vfio_migration_state_notifier(Notifier *notifier, void *data)
case MIGRATION_STATUS_CANCELLING:
case MIGRATION_STATUS_CANCELLED:
case MIGRATION_STATUS_FAILED:
+ bytes_transferred = 0;
ret = vfio_migration_set_state(vbasedev,
~(VFIO_DEVICE_STATE_SAVING | VFIO_DEVICE_STATE_RESUMING),
VFIO_DEVICE_STATE_RUNNING);
@@ -866,6 +870,11 @@ err:
/* ---------------------------------------------------------------------- */
+int64_t vfio_mig_bytes_transferred(void)
+{
+ return bytes_transferred;
+}
+
int vfio_migration_probe(VFIODevice *vbasedev, Error **errp)
{
VFIOContainer *container = vbasedev->group->container;