[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/32] vfio: Add function to start and stop dirty pages tracking
From: |
Alex Williamson |
Subject: |
[PULL 12/32] vfio: Add function to start and stop dirty pages tracking |
Date: |
Mon, 26 Oct 2020 13:34:10 -0600 |
User-agent: |
StGit/0.21-dirty |
From: Kirti Wankhede <kwankhede@nvidia.com>
Call VFIO_IOMMU_DIRTY_PAGES ioctl to start and stop dirty pages tracking
for 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>
---
hw/vfio/migration.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
index 93f8fe7bd869..ffedbcca179d 100644
--- a/hw/vfio/migration.c
+++ b/hw/vfio/migration.c
@@ -11,6 +11,7 @@
#include "qemu/main-loop.h"
#include "qemu/cutils.h"
#include <linux/vfio.h>
+#include <sys/ioctl.h>
#include "sysemu/runstate.h"
#include "hw/vfio/vfio-common.h"
@@ -391,10 +392,40 @@ static int vfio_load_device_config_state(QEMUFile *f,
void *opaque)
return qemu_file_get_error(f);
}
+static int vfio_set_dirty_page_tracking(VFIODevice *vbasedev, bool start)
+{
+ int ret;
+ VFIOMigration *migration = vbasedev->migration;
+ VFIOContainer *container = vbasedev->group->container;
+ struct vfio_iommu_type1_dirty_bitmap dirty = {
+ .argsz = sizeof(dirty),
+ };
+
+ if (start) {
+ if (migration->device_state & VFIO_DEVICE_STATE_SAVING) {
+ dirty.flags = VFIO_IOMMU_DIRTY_PAGES_FLAG_START;
+ } else {
+ return -EINVAL;
+ }
+ } else {
+ dirty.flags = VFIO_IOMMU_DIRTY_PAGES_FLAG_STOP;
+ }
+
+ ret = ioctl(container->fd, VFIO_IOMMU_DIRTY_PAGES, &dirty);
+ if (ret) {
+ error_report("Failed to set dirty tracking flag 0x%x errno: %d",
+ dirty.flags, errno);
+ return -errno;
+ }
+ return ret;
+}
+
static void vfio_migration_cleanup(VFIODevice *vbasedev)
{
VFIOMigration *migration = vbasedev->migration;
+ vfio_set_dirty_page_tracking(vbasedev, false);
+
if (migration->region.mmaps) {
vfio_region_unmap(&migration->region);
}
@@ -435,6 +466,11 @@ static int vfio_save_setup(QEMUFile *f, void *opaque)
return ret;
}
+ ret = vfio_set_dirty_page_tracking(vbasedev, true);
+ if (ret) {
+ return ret;
+ }
+
qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE);
ret = qemu_file_get_error(f);
- [PULL 02/32] vfio: Add vfio_get_object callback to VFIODeviceOps, (continued)
- [PULL 02/32] vfio: Add vfio_get_object callback to VFIODeviceOps, Alex Williamson, 2020/10/26
- [PULL 03/32] vfio: Add save and load functions for VFIO PCI devices, Alex Williamson, 2020/10/26
- [PULL 04/32] vfio: Add migration region initialization and finalize function, Alex Williamson, 2020/10/26
- [PULL 05/32] vfio: Add VM state change handler to know state of VM, Alex Williamson, 2020/10/26
- [PULL 06/32] vfio: Add migration state change notifier, Alex Williamson, 2020/10/26
- [PULL 07/32] vfio: Register SaveVMHandlers for VFIO device, Alex Williamson, 2020/10/26
- [PULL 09/32] vfio: Add load state functions to SaveVMHandlers, Alex Williamson, 2020/10/26
- [PULL 08/32] vfio: Add save state functions to SaveVMHandlers, Alex Williamson, 2020/10/26
- [PULL 10/32] memory: Set DIRTY_MEMORY_MIGRATION when IOMMU is enabled, Alex Williamson, 2020/10/26
- [PULL 11/32] vfio: Get migration capability flags for container, Alex Williamson, 2020/10/26
- [PULL 12/32] vfio: Add function to start and stop dirty pages tracking,
Alex Williamson <=
- [PULL 13/32] vfio: Add vfio_listener_log_sync to mark dirty pages, Alex Williamson, 2020/10/26
- [PULL 14/32] vfio: Dirty page tracking when vIOMMU is enabled, Alex Williamson, 2020/10/26
- [PULL 15/32] vfio: Add ioctl to get dirty pages bitmap during dma unmap, Alex Williamson, 2020/10/26
- [PULL 16/32] vfio: Make vfio-pci device migration capable, Alex Williamson, 2020/10/26
- [PULL 17/32] qapi: Add VFIO devices migration stats in Migration stats, Alex Williamson, 2020/10/26
- [PULL 19/32] linux-headers: update against 5.10-rc1, Alex Williamson, 2020/10/26
- [PULL 18/32] update-linux-headers: Add vfio_zdev.h, Alex Williamson, 2020/10/26
- [PULL 20/32] s390x/pci: Move header files to include/hw/s390x, Alex Williamson, 2020/10/26
- [PULL 21/32] vfio: Create shared routine for scanning info capabilities, Alex Williamson, 2020/10/26
- [PULL 22/32] vfio: Find DMA available capability, Alex Williamson, 2020/10/26