[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH QEMU v23 14/18] vfio: Add function to start and stop dirty pa
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [PATCH QEMU v23 14/18] vfio: Add function to start and stop dirty pages tracking |
Date: |
Thu, 21 May 2020 17:50:59 +0100 |
User-agent: |
Mutt/1.13.4 (2020-02-15) |
* Kirti Wankhede (address@hidden) wrote:
> Call VFIO_IOMMU_DIRTY_PAGES ioctl to start and stop dirty pages tracking
> for VFIO devices.
>
> Signed-off-by: Kirti Wankhede <address@hidden>
This does seem to match my reading of your 4/8 ioctl sefinition patch,
so:
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
I must admit I don't see why 'argsz' is needed.
Dave
> ---
> hw/vfio/migration.c | 36 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
>
> diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
> index b9bbe38e539c..7729c90782bd 100644
> --- a/hw/vfio/migration.c
> +++ b/hw/vfio/migration.c
> @@ -9,6 +9,7 @@
>
> #include "qemu/osdep.h"
> #include "qemu/main-loop.h"
> +#include <sys/ioctl.h>
> #include <linux/vfio.h>
>
> #include "sysemu/runstate.h"
> @@ -297,6 +298,32 @@ static int vfio_load_device_config_state(QEMUFile *f,
> void *opaque)
> return qemu_file_get_error(f);
> }
>
> +static int vfio_start_dirty_page_tracking(VFIODevice *vbasedev, bool start)
> +{
> + int ret;
> + VFIOContainer *container = vbasedev->group->container;
> + struct vfio_iommu_type1_dirty_bitmap dirty = {
> + .argsz = sizeof(dirty),
> + };
> +
> + if (start) {
> + if (vbasedev->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 ret;
> +}
> +
> /* ---------------------------------------------------------------------- */
>
> static int vfio_save_setup(QEMUFile *f, void *opaque)
> @@ -327,6 +354,11 @@ static int vfio_save_setup(QEMUFile *f, void *opaque)
> return ret;
> }
>
> + ret = vfio_start_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);
> @@ -342,6 +374,8 @@ static void vfio_save_cleanup(void *opaque)
> VFIODevice *vbasedev = opaque;
> VFIOMigration *migration = vbasedev->migration;
>
> + vfio_start_dirty_page_tracking(vbasedev, false);
> +
> if (migration->region.mmaps) {
> vfio_region_unmap(&migration->region);
> }
> @@ -676,6 +710,8 @@ static void vfio_migration_state_notifier(Notifier
> *notifier, void *data)
> if (ret) {
> error_report("%s: Failed to set state RUNNING", vbasedev->name);
> }
> +
> + vfio_start_dirty_page_tracking(vbasedev, false);
> }
> }
>
> --
> 2.7.0
>
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK
- Re: [PATCH QEMU v23 09/18] vfio: Add save state functions to SaveVMHandlers, (continued)
- [PATCH QEMU v23 10/18] vfio: Add load state functions to SaveVMHandlers, Kirti Wankhede, 2020/05/20
- [PATCH QEMU v23 11/18] iommu: add callback to get address limit IOMMU supports, Kirti Wankhede, 2020/05/20
- [PATCH QEMU v23 12/18] memory: Set DIRTY_MEMORY_MIGRATION when IOMMU is enabled, Kirti Wankhede, 2020/05/20
- [PATCH QEMU v23 13/18] vfio: Get migration capability flags for container, Kirti Wankhede, 2020/05/20
- [PATCH QEMU v23 14/18] vfio: Add function to start and stop dirty pages tracking, Kirti Wankhede, 2020/05/20
- Re: [PATCH QEMU v23 14/18] vfio: Add function to start and stop dirty pages tracking,
Dr. David Alan Gilbert <=
- [PATCH QEMU v23 15/18] vfio: Add vfio_listener_log_sync to mark dirty pages, Kirti Wankhede, 2020/05/20
- [PATCH QEMU v23 16/18] vfio: Add ioctl to get dirty pages bitmap during dma unmap., Kirti Wankhede, 2020/05/20
- [PATCH QEMU v23 17/18] vfio: Make vfio-pci device migration capable, Kirti Wankhede, 2020/05/20
- [PATCH QEMU v23 18/18] qapi: Add VFIO devices migration stats in Migration stats, Kirti Wankhede, 2020/05/20