From nobody Mon Nov 17 09:48:37 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=nvidia.com ARC-Seal: i=1; a=rsa-sha256; t=1603452418; cv=none; d=zohomail.com; s=zohoarc; b=ayOsktBrdHBTKgGFzYCUCbMO/Ey8+05tNhw6Q8/TFoq0sjln+EnWratASny0EqK5cBCS/1mp1f4vf1iNuWbuUQwb0pYQXB08Zy7CgPSGhm7FvPX2SisWYrQvdJkGTMb2GYTdWEthBY6388ACsL4A2mlI4c99sU2Lc5NE/3xF1Dk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603452418; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=F7oQvVz4HetGlrDeqw4kDGM52WJWvmOCrkYIXCeHAXE=; b=RbeOCc+nrs24CUjU9O3EQlHucsn2z4kvQyfZYsf3w9Gw+wgZwqW44aPmoeVA9yXTBLjDThnLgPt4oklrM4yofMAuOVPKHcG8HTdvDhQYRjR70uYiJVcVUUasHjI/UER7LTBwawnNdI36G5N73K+ZJa+1dASLU40LU0AaP1BD0M4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603452418622133.47593193049954; Fri, 23 Oct 2020 04:26:58 -0700 (PDT) Received: from localhost ([::1]:36414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVvDl-0006IA-JT for importer@patchew.org; Fri, 23 Oct 2020 07:26:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVv39-0001mU-2T for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:16:00 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:15366) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVv37-0007nL-5E for qemu-devel@nongnu.org; Fri, 23 Oct 2020 07:15:58 -0400 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Fri, 23 Oct 2020 04:15:06 -0700 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 23 Oct 2020 11:15:47 +0000 Received: from kwankhede-dev.nvidia.com (172.20.13.39) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Fri, 23 Oct 2020 11:15:39 +0000 From: Kirti Wankhede To: , Subject: [PATCH v28 16/17] vfio: Make vfio-pci device migration capable Date: Fri, 23 Oct 2020 16:10:42 +0530 Message-ID: <1603449643-12851-17-git-send-email-kwankhede@nvidia.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1603449643-12851-1-git-send-email-kwankhede@nvidia.com> References: <1603449643-12851-1-git-send-email-kwankhede@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1603451707; bh=F7oQvVz4HetGlrDeqw4kDGM52WJWvmOCrkYIXCeHAXE=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:X-NVConfidentiality:MIME-Version:Content-Type; b=mtxLo+z5M7JU/FPJWXDO/XQ5F3VIWWZ+gYVL3k1pSj/ElVJFLSurSGC3gMaEZGboQ 8JqMbBO3KYNq7Foog2NOkQGIaB4rlSNgW6GW4W8tqe1/bNjOeZ0sW6yMy/as08GKQ9 lvHMFJsnZstqDM/tJ+JtUZIwnjR6Yj0yJyBZdnfPu5VxvkSSGU96Q0WBCwa+/IEN1A 4rkVsBWORg/AVO/ldRuq2ZXdC9WeRZDnM0/nM8BKkIQ9J/6pzZe+tJZlpzEk1nZKy4 a5feRTLskaapyOV8eKXlJJ7ZdVzbhgKJQDhKGZPa1TdBcdtX7zyCva0d1h4j0fzUeX xGYzUT2aYgtog== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.228.121.64; envelope-from=kwankhede@nvidia.com; helo=hqnvemgate25.nvidia.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 06:23:18 X-ACL-Warn: Detected OS = Windows 7 or 8 [fuzzy] X-Spam_score_int: -70 X-Spam_score: -7.1 X-Spam_bar: ------- X-Spam_report: (-7.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cohuck@redhat.com, zhi.wang.linux@gmail.com, aik@ozlabs.ru, Zhengxiao.zx@Alibaba-inc.com, shuangtai.tst@alibaba-inc.com, qemu-devel@nongnu.org, peterx@redhat.com, Kirti Wankhede , eauger@redhat.com, artemp@nvidia.com, yi.l.liu@intel.com, quintela@redhat.com, ziye.yang@intel.com, armbru@redhat.com, mlevitsk@redhat.com, pasic@linux.ibm.com, felipe@nutanix.com, zhi.a.wang@intel.com, mcrossley@nvidia.com, kevin.tian@intel.com, yan.y.zhao@intel.com, dgilbert@redhat.com, changpeng.liu@intel.com, eskultet@redhat.com, Ken.Xue@amd.com, jonathan.davies@nutanix.com, pbonzini@redhat.com, dnigam@nvidia.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If the device is not a failover primary device, call vfio_migration_probe() and vfio_migration_finalize() to enable migration support for those devices that support it respectively to tear it down again. Removed migration blocker from VFIO PCI device specific structure and use migration blocker from generic structure of VFIO device. Signed-off-by: Kirti Wankhede Reviewed-by: Neo Jia Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Cornelia Huck --- hw/vfio/pci.c | 28 ++++++++-------------------- hw/vfio/pci.h | 1 - 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 92cc25a5489f..d2a2b5756774 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2788,17 +2788,6 @@ static void vfio_realize(PCIDevice *pdev, Error **er= rp) return; } =20 - if (!pdev->failover_pair_id) { - error_setg(&vdev->migration_blocker, - "VFIO device doesn't support migration"); - ret =3D migrate_add_blocker(vdev->migration_blocker, errp); - if (ret) { - error_free(vdev->migration_blocker); - vdev->migration_blocker =3D NULL; - return; - } - } - vdev->vbasedev.name =3D g_path_get_basename(vdev->vbasedev.sysfsdev); vdev->vbasedev.ops =3D &vfio_pci_ops; vdev->vbasedev.type =3D VFIO_DEVICE_TYPE_PCI; @@ -3066,6 +3055,13 @@ static void vfio_realize(PCIDevice *pdev, Error **er= rp) } } =20 + if (!pdev->failover_pair_id) { + ret =3D vfio_migration_probe(&vdev->vbasedev, errp); + if (ret) { + error_report("%s: Migration disabled", vdev->vbasedev.name); + } + } + vfio_register_err_notifier(vdev); vfio_register_req_notifier(vdev); vfio_setup_resetfn_quirk(vdev); @@ -3080,11 +3076,6 @@ out_teardown: vfio_bars_exit(vdev); error: error_prepend(errp, VFIO_MSG_PREFIX, vdev->vbasedev.name); - if (vdev->migration_blocker) { - migrate_del_blocker(vdev->migration_blocker); - error_free(vdev->migration_blocker); - vdev->migration_blocker =3D NULL; - } } =20 static void vfio_instance_finalize(Object *obj) @@ -3096,10 +3087,6 @@ static void vfio_instance_finalize(Object *obj) vfio_bars_finalize(vdev); g_free(vdev->emulated_config_bits); g_free(vdev->rom); - if (vdev->migration_blocker) { - migrate_del_blocker(vdev->migration_blocker); - error_free(vdev->migration_blocker); - } /* * XXX Leaking igd_opregion is not an oversight, we can't remove the * fw_cfg entry therefore leaking this allocation seems like the safest @@ -3127,6 +3114,7 @@ static void vfio_exitfn(PCIDevice *pdev) } vfio_teardown_msi(vdev); vfio_bars_exit(vdev); + vfio_migration_finalize(&vdev->vbasedev); } =20 static void vfio_pci_reset(DeviceState *dev) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index bce71a9ac93f..1574ef983f8f 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -172,7 +172,6 @@ struct VFIOPCIDevice { bool no_vfio_ioeventfd; bool enable_ramfb; VFIODisplay *dpy; - Error *migration_blocker; Notifier irqchip_change_notifier; }; =20 --=20 2.7.0