qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yi Liu <yi.l.liu@intel.com>
To: Zhenzhong Duan <zhenzhong.duan@intel.com>, <qemu-devel@nongnu.org>
Cc: <alex.williamson@redhat.com>, <clg@redhat.com>, <mst@redhat.com>,
	<jasowang@redhat.com>, <clement.mathieu--drif@eviden.com>,
	<eric.auger@redhat.com>, <joao.m.martins@oracle.com>,
	<avihaih@nvidia.com>, <xudong.hao@intel.com>,
	<giovanni.cabiddu@intel.com>, <mark.gross@intel.com>,
	 <arjan.van.de.ven@intel.com>, Jason Zeng <jason.zeng@intel.com>
Subject: Re: [PATCH v2 8/8] vfio/migration: Allow live migration with vIOMMU without VFs using device dirty tracking
Date: Mon, 20 Oct 2025 20:46:07 +0800	[thread overview]
Message-ID: <631f49a8-e39c-48ee-b9e4-f6cdc5633afb@intel.com> (raw)
In-Reply-To: <20251017082234.517827-9-zhenzhong.duan@intel.com>

On 2025/10/17 16:22, Zhenzhong Duan wrote:
> Commit e46883204c38 ("vfio/migration: Block migration with vIOMMU")
> introduces a migration blocker when vIOMMU is enabled, because we need
> to calculate the IOVA ranges for device dirty tracking. But this is
> unnecessary for iommu dirty tracking.
> 
> Limit the vfio_viommu_preset() check to those devices which use device
> dirty tracking. This allows live migration with VFIO devices which use
> iommu dirty tracking.
> 
> Introduce a helper vfio_device_dirty_pages_disabled() to facilicate it.

s/facilicate/facilitate/

Reviewed-by: Yi Liu <yi.l.liu@intel.com>

> 
> Suggested-by: Jason Zeng <jason.zeng@intel.com>
> Co-developed-by: Joao Martins <joao.m.martins@oracle.com>
> Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> Tested-by: Xudong Hao <xudong.hao@intel.com>
> Tested-by: Giovannio Cabiddu <giovanni.cabiddu@intel.com>
> ---
>   include/hw/vfio/vfio-device.h | 10 ++++++++++
>   hw/vfio/container.c           |  5 +----
>   hw/vfio/device.c              |  6 ++++++
>   hw/vfio/migration.c           |  6 +++---
>   4 files changed, 20 insertions(+), 7 deletions(-)
> 
> diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h
> index 7e9aed6d3c..feda521514 100644
> --- a/include/hw/vfio/vfio-device.h
> +++ b/include/hw/vfio/vfio-device.h
> @@ -148,6 +148,16 @@ bool vfio_device_irq_set_signaling(VFIODevice *vbasedev, int index, int subindex
>   
>   void vfio_device_reset_handler(void *opaque);
>   bool vfio_device_is_mdev(VFIODevice *vbasedev);
> +/**
> + * vfio_device_dirty_pages_disabled: Check if device dirty tracking will be
> + * used for a VFIO device
> + *
> + * @vbasedev: The VFIODevice to transform
> + *
> + * Return: true if either @vbasedev doesn't support device dirty tracking or
> + * is forcedly disabled from command line, otherwise false.
> + */
> +bool vfio_device_dirty_pages_disabled(VFIODevice *vbasedev);
>   bool vfio_device_hiod_create_and_realize(VFIODevice *vbasedev,
>                                            const char *typename, Error **errp);
>   bool vfio_device_attach(char *name, VFIODevice *vbasedev,
> diff --git a/hw/vfio/container.c b/hw/vfio/container.c
> index 7706603c1c..8879da78c8 100644
> --- a/hw/vfio/container.c
> +++ b/hw/vfio/container.c
> @@ -178,10 +178,7 @@ bool vfio_container_devices_dirty_tracking_is_supported(
>       VFIODevice *vbasedev;
>   
>       QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) {
> -        if (vbasedev->device_dirty_page_tracking == ON_OFF_AUTO_OFF) {
> -            return false;
> -        }
> -        if (!vbasedev->dirty_pages_supported) {
> +        if (vfio_device_dirty_pages_disabled(vbasedev)) {
>               return false;
>           }
>       }
> diff --git a/hw/vfio/device.c b/hw/vfio/device.c
> index 64f8750389..837872387f 100644
> --- a/hw/vfio/device.c
> +++ b/hw/vfio/device.c
> @@ -400,6 +400,12 @@ bool vfio_device_is_mdev(VFIODevice *vbasedev)
>       return subsys && (strcmp(subsys, "/sys/bus/mdev") == 0);
>   }
>   
> +bool vfio_device_dirty_pages_disabled(VFIODevice *vbasedev)
> +{
> +    return (!vbasedev->dirty_pages_supported ||
> +            vbasedev->device_dirty_page_tracking == ON_OFF_AUTO_OFF);
> +}
> +
>   bool vfio_device_hiod_create_and_realize(VFIODevice *vbasedev,
>                                            const char *typename, Error **errp)
>   {
> diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c
> index 1106ca7857..1093857a34 100644
> --- a/hw/vfio/migration.c
> +++ b/hw/vfio/migration.c
> @@ -1213,8 +1213,7 @@ bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp)
>           return !vfio_block_migration(vbasedev, err, errp);
>       }
>   
> -    if ((!vbasedev->dirty_pages_supported ||
> -         vbasedev->device_dirty_page_tracking == ON_OFF_AUTO_OFF) &&
> +    if (vfio_device_dirty_pages_disabled(vbasedev) &&
>           !vbasedev->iommu_dirty_tracking) {
>           if (vbasedev->enable_migration == ON_OFF_AUTO_AUTO) {
>               error_setg(&err,
> @@ -1232,7 +1231,8 @@ bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp)
>           goto out_deinit;
>       }
>   
> -    if (vfio_viommu_preset(vbasedev)) {
> +    if (!vfio_device_dirty_pages_disabled(vbasedev) &&
> +        vfio_viommu_preset(vbasedev)) {
>           error_setg(&err, "%s: Migration is currently not supported "
>                      "with vIOMMU enabled", vbasedev->name);
>           goto add_blocker;


      reply	other threads:[~2025-10-20 12:40 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-17  8:22 [PATCH v2 0/8] vfio: relax the vIOMMU check Zhenzhong Duan
2025-10-17  8:22 ` [PATCH v2 1/8] vfio/iommufd: Add framework code to support getting dirty bitmap before unmap Zhenzhong Duan
2025-10-20  7:00   ` Cédric Le Goater
2025-10-20 12:44   ` Yi Liu
2025-10-17  8:22 ` [PATCH v2 2/8] vfio/iommufd: Query dirty bitmap before DMA unmap Zhenzhong Duan
2025-10-20  7:00   ` Cédric Le Goater
2025-10-20  8:14   ` Avihai Horon
2025-10-20 10:00     ` Duan, Zhenzhong
2025-10-20 12:45       ` Yi Liu
2025-10-20 13:04         ` Avihai Horon
2025-10-21  3:30           ` Yi Liu
2025-10-20 12:44   ` Yi Liu
2025-10-17  8:22 ` [PATCH v2 3/8] vfio/container-legacy: rename vfio_dma_unmap_bitmap() to vfio_legacy_dma_unmap_get_dirty_bitmap() Zhenzhong Duan
2025-10-20  7:00   ` Cédric Le Goater
2025-10-20 12:45   ` Yi Liu
2025-10-17  8:22 ` [PATCH v2 4/8] vfio: Add a backend_flag parameter to vfio_contianer_query_dirty_bitmap() Zhenzhong Duan
2025-10-20  7:01   ` Cédric Le Goater
2025-10-20 12:44   ` Yi Liu
2025-10-17  8:22 ` [PATCH v2 5/8] vfio/iommufd: Add IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR flag support Zhenzhong Duan
2025-10-20  7:01   ` Cédric Le Goater
2025-10-20 12:45   ` Yi Liu
2025-10-17  8:22 ` [PATCH v2 6/8] intel_iommu: Fix unmap_bitmap failure with legacy VFIO backend Zhenzhong Duan
2025-10-20  7:06   ` Cédric Le Goater
2025-10-20  7:38   ` Yi Liu
2025-10-20  8:03     ` Duan, Zhenzhong
2025-10-20  8:37       ` Yi Liu
2025-10-20 10:01         ` Duan, Zhenzhong
2025-10-17  8:22 ` [PATCH v2 7/8] vfio/migration: Add migration blocker if VM memory is too large to cause unmap_bitmap failure Zhenzhong Duan
2025-10-20  8:39   ` Cédric Le Goater
2025-10-20 10:07     ` Duan, Zhenzhong
2025-10-20 12:44   ` Yi Liu
2025-10-21  8:25     ` Duan, Zhenzhong
2025-10-17  8:22 ` [PATCH v2 8/8] vfio/migration: Allow live migration with vIOMMU without VFs using device dirty tracking Zhenzhong Duan
2025-10-20 12:46   ` Yi Liu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=631f49a8-e39c-48ee-b9e4-f6cdc5633afb@intel.com \
    --to=yi.l.liu@intel.com \
    --cc=alex.williamson@redhat.com \
    --cc=arjan.van.de.ven@intel.com \
    --cc=avihaih@nvidia.com \
    --cc=clement.mathieu--drif@eviden.com \
    --cc=clg@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=giovanni.cabiddu@intel.com \
    --cc=jason.zeng@intel.com \
    --cc=jasowang@redhat.com \
    --cc=joao.m.martins@oracle.com \
    --cc=mark.gross@intel.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=xudong.hao@intel.com \
    --cc=zhenzhong.duan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).