{"id":2175436,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2175436/?format=json","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.0/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20251218062643.624796-10-zhenzhong.duan@intel.com>","date":"2025-12-18T06:26:30","name":"[v6,9/9] vfio/migration: Allow live migration with vIOMMU without VFs using device dirty tracking","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"6b1163c1698122388565e199a3a3e16bf811b593","submitter":{"id":81636,"url":"http://patchwork.ozlabs.org/api/1.0/people/81636/?format=json","name":"Duan, Zhenzhong","email":"zhenzhong.duan@intel.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20251218062643.624796-10-zhenzhong.duan@intel.com/mbox/","series":[{"id":485789,"url":"http://patchwork.ozlabs.org/api/1.0/series/485789/?format=json","date":"2025-12-18T06:26:21","name":"vfio: relax the vIOMMU check","version":6,"mbox":"http://patchwork.ozlabs.org/series/485789/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2175436/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256\n header.s=Intel header.b=Wt2tGr5t;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4dX13f0v9cz1xty\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 18 Dec 2025 17:29:34 +1100 (AEDT)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1vW7Uv-0003ih-TH; Thu, 18 Dec 2025 01:28:25 -0500","from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <zhenzhong.duan@intel.com>)\n id 1vW7UP-0003Of-JV\n for qemu-devel@nongnu.org; Thu, 18 Dec 2025 01:27:54 -0500","from mgamail.intel.com ([198.175.65.18])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <zhenzhong.duan@intel.com>)\n id 1vW7UN-00019A-Vl\n for qemu-devel@nongnu.org; Thu, 18 Dec 2025 01:27:53 -0500","from orviesa005.jf.intel.com ([10.64.159.145])\n by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 17 Dec 2025 22:27:51 -0800","from unknown (HELO gnr-sp-2s-612.sh.intel.com) ([10.112.230.229])\n by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 17 Dec 2025 22:27:48 -0800"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1766039272; x=1797575272;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=UWCtB3mKmhaGb5ZJgV5RoDC7vPwTn6VCYeJxGiLsv24=;\n b=Wt2tGr5tH4EEJwM2TNobibAm9UDQGpQlNc7aOcRxdCKFTObpbj+qfml4\n p2sj3SbZkaNSyxr6IJPJNUFNC4S9xzSlcFflMh4KPGgZO4f3VLqMY0pJr\n VRcWXpqkh4ks5OOkeNdOrMgOb79NOalfnkFDQJgLjf1T6thm3F4PlDx+I\n H7GW7hrweMBX5OHye7cqwqMpe4VULwJ+14HXZnhDfsHGTK8co8VDIVm7R\n WaHMLymCLVQxB37AUyftt9x03pCS/KYDD5UB3jecAlB4P1jO0wQSXy9zV\n 67x9yGpmPuJ+0NYcIoagpdNtZ0N4wqCDPzausd8YLYCEs9tIwE9X8Hizi A==;","X-CSE-ConnectionGUID":["clq2ynbeSlq+ZQu+Rzb9bA==","6Tud3Db/RdC+Hxjm4CXuKw=="],"X-CSE-MsgGUID":["Y8ErS0gKSJOhzv57OoAQeg==","NNwQ0riHSYeKlRKMJV9UhQ=="],"X-IronPort-AV":["E=McAfee;i=\"6800,10657,11645\"; a=\"68028580\"","E=Sophos;i=\"6.21,156,1763452800\"; d=\"scan'208\";a=\"68028580\"","E=Sophos;i=\"6.21,156,1763452800\"; d=\"scan'208\";a=\"203569921\""],"X-ExtLoop1":"1","From":"Zhenzhong Duan <zhenzhong.duan@intel.com>","To":"qemu-devel@nongnu.org","Cc":"alex@shazbot.org, clg@redhat.com, mst@redhat.com, jasowang@redhat.com,\n yi.l.liu@intel.com, clement.mathieu--drif@eviden.com,\n eric.auger@redhat.com, joao.m.martins@oracle.com, avihaih@nvidia.com,\n xudong.hao@intel.com, giovanni.cabiddu@intel.com, rohith.s.r@intel.com,\n mark.gross@intel.com, arjan.van.de.ven@intel.com,\n Zhenzhong Duan <zhenzhong.duan@intel.com>,\n Jason Zeng <jason.zeng@intel.com>","Subject":"[PATCH v6 9/9] vfio/migration: Allow live migration with vIOMMU\n without VFs using device dirty tracking","Date":"Thu, 18 Dec 2025 01:26:30 -0500","Message-ID":"<20251218062643.624796-10-zhenzhong.duan@intel.com>","X-Mailer":"git-send-email 2.47.1","In-Reply-To":"<20251218062643.624796-1-zhenzhong.duan@intel.com>","References":"<20251218062643.624796-1-zhenzhong.duan@intel.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=198.175.65.18;\n envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com","X-Spam_score_int":"-43","X-Spam_score":"-4.4","X-Spam_bar":"----","X-Spam_report":"(-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,\n RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"Commit e46883204c38 (\"vfio/migration: Block migration with vIOMMU\")\nintroduces a migration blocker when vIOMMU is enabled, because we need\nto calculate the IOVA ranges for device dirty tracking. But this is\nunnecessary for iommu dirty tracking.\n\nLimit the vfio_viommu_preset() check to those devices which use device\ndirty tracking. This allows live migration with VFIO devices which use\niommu dirty tracking.\n\nSuggested-by: Jason Zeng <jason.zeng@intel.com>\nCo-developed-by: Joao Martins <joao.m.martins@oracle.com>\nSigned-off-by: Joao Martins <joao.m.martins@oracle.com>\nSigned-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>\nReviewed-by: Yi Liu <yi.l.liu@intel.com>\nTested-by: Xudong Hao <xudong.hao@intel.com>\nTested-by: Giovannio Cabiddu <giovanni.cabiddu@intel.com>\nTested-by: Rohith S R <rohith.s.r@intel.com>\n---\n include/hw/vfio/vfio-device.h | 10 ++++++++++\n hw/vfio/container.c           |  5 +----\n hw/vfio/device.c              |  6 ++++++\n hw/vfio/migration.c           |  6 +++---\n 4 files changed, 20 insertions(+), 7 deletions(-)","diff":"diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h\nindex 0bc877ff62..48d00c7bc4 100644\n--- a/include/hw/vfio/vfio-device.h\n+++ b/include/hw/vfio/vfio-device.h\n@@ -148,6 +148,16 @@ bool vfio_device_irq_set_signaling(VFIODevice *vbasedev, int index, int subindex\n \n void vfio_device_reset_handler(void *opaque);\n bool vfio_device_is_mdev(VFIODevice *vbasedev);\n+/**\n+ * vfio_device_dirty_pages_disabled: Check if device dirty tracking will be\n+ * used for a VFIO device\n+ *\n+ * @vbasedev: The VFIODevice to transform\n+ *\n+ * Return: true if either @vbasedev doesn't support device dirty tracking or\n+ * is forcedly disabled from command line, otherwise false.\n+ */\n+bool vfio_device_dirty_pages_disabled(VFIODevice *vbasedev);\n bool vfio_device_hiod_create_and_realize(VFIODevice *vbasedev,\n                                          const char *typename, Error **errp);\n bool vfio_device_attach(char *name, VFIODevice *vbasedev,\ndiff --git a/hw/vfio/container.c b/hw/vfio/container.c\nindex db6f36b952..e7eae5cd83 100644\n--- a/hw/vfio/container.c\n+++ b/hw/vfio/container.c\n@@ -178,10 +178,7 @@ bool vfio_container_devices_dirty_tracking_is_supported(\n     VFIODevice *vbasedev;\n \n     QLIST_FOREACH(vbasedev, &bcontainer->device_list, container_next) {\n-        if (vbasedev->device_dirty_page_tracking == ON_OFF_AUTO_OFF) {\n-            return false;\n-        }\n-        if (!vbasedev->dirty_pages_supported) {\n+        if (vfio_device_dirty_pages_disabled(vbasedev)) {\n             return false;\n         }\n     }\ndiff --git a/hw/vfio/device.c b/hw/vfio/device.c\nindex eff5aab207..71eb069eb6 100644\n--- a/hw/vfio/device.c\n+++ b/hw/vfio/device.c\n@@ -412,6 +412,12 @@ bool vfio_device_is_mdev(VFIODevice *vbasedev)\n     return subsys && (strcmp(subsys, \"/sys/bus/mdev\") == 0);\n }\n \n+bool vfio_device_dirty_pages_disabled(VFIODevice *vbasedev)\n+{\n+    return (!vbasedev->dirty_pages_supported ||\n+            vbasedev->device_dirty_page_tracking == ON_OFF_AUTO_OFF);\n+}\n+\n bool vfio_device_hiod_create_and_realize(VFIODevice *vbasedev,\n                                          const char *typename, Error **errp)\n {\ndiff --git a/hw/vfio/migration.c b/hw/vfio/migration.c\nindex 86e5b7ab55..c0b7d3434f 100644\n--- a/hw/vfio/migration.c\n+++ b/hw/vfio/migration.c\n@@ -1210,8 +1210,7 @@ bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp)\n         return !vfio_block_migration(vbasedev, err, errp);\n     }\n \n-    if ((!vbasedev->dirty_pages_supported ||\n-         vbasedev->device_dirty_page_tracking == ON_OFF_AUTO_OFF) &&\n+    if (vfio_device_dirty_pages_disabled(vbasedev) &&\n         !vbasedev->iommu_dirty_tracking) {\n         if (vbasedev->enable_migration == ON_OFF_AUTO_AUTO) {\n             error_setg(&err,\n@@ -1236,7 +1235,8 @@ bool vfio_migration_realize(VFIODevice *vbasedev, Error **errp)\n         goto out_deinit;\n     }\n \n-    if (vfio_viommu_preset(vbasedev)) {\n+    if (!vfio_device_dirty_pages_disabled(vbasedev) &&\n+        vfio_viommu_preset(vbasedev)) {\n         error_setg(&err, \"%s: Migration is currently not supported \"\n                    \"with vIOMMU enabled\", vbasedev->name);\n         goto add_blocker;\n","prefixes":["v6","9/9"]}