]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
vfio/virtio: Enable support for virtio-block live migration
authorYishai Hadas <yishaih@nvidia.com>
Sun, 2 Mar 2025 16:27:23 +0000 (18:27 +0200)
committerAlex Williamson <alex.williamson@redhat.com>
Mon, 10 Mar 2025 20:42:50 +0000 (14:42 -0600)
With a functional and tested backend for virtio-block live migration,
add the virtio-block device ID to the pci_device_id table.

Currently, the driver supports legacy IO functionality only for
virtio-net, and it is accounted for in specific parts of the code.

To enforce this limitation, an explicit check for virtio-net, has been
added in virtiovf_support_legacy_io(). Once a backend implements legacy
IO functionality for virtio-block, the necessary support will be added
to the driver, and this additional check should be removed.

The module description was updated accordingly.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
Link: https://lore.kernel.org/r/20250302162723.82578-1-yishaih@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/pci/virtio/Kconfig
drivers/vfio/pci/virtio/legacy_io.c
drivers/vfio/pci/virtio/main.c

index 2770f7eb702cc2fe5b69ec1fabdcc2a3bc91ecd4..33e04e65bec6db3d94f2e8189d9d908e25f2bd43 100644 (file)
@@ -1,11 +1,11 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config VIRTIO_VFIO_PCI
-       tristate "VFIO support for VIRTIO NET PCI VF devices"
+       tristate "VFIO support for VIRTIO PCI VF devices"
        depends on VIRTIO_PCI
        select VFIO_PCI_CORE
        help
-         This provides migration support for VIRTIO NET PCI VF devices
-         using the VFIO framework. Migration support requires the
+         This provides migration support for VIRTIO NET and BLOCK PCI VF
+         devices using the VFIO framework. Migration support requires the
          SR-IOV PF device to support specific VIRTIO extensions,
          otherwise this driver provides no additional functionality
          beyond vfio-pci.
index 20382ee15faca934165cfa593eef9b05540d542b..832af5ba267c49a079009cfe0fa93c15ba7a490f 100644 (file)
@@ -382,7 +382,9 @@ static bool virtiovf_bar0_exists(struct pci_dev *pdev)
 
 bool virtiovf_support_legacy_io(struct pci_dev *pdev)
 {
-       return virtio_pci_admin_has_legacy_io(pdev) && !virtiovf_bar0_exists(pdev);
+       /* For now, the legacy IO functionality is supported only for virtio-net */
+       return pdev->device == 0x1041 && virtio_pci_admin_has_legacy_io(pdev) &&
+              !virtiovf_bar0_exists(pdev);
 }
 
 int virtiovf_init_legacy_io(struct virtiovf_pci_core_device *virtvdev)
index d534d48c416337a9bf2ba4e950c0bde516878bd2..515fe1b9f94d80cfa41cb2a085a086b43289595c 100644 (file)
@@ -187,8 +187,9 @@ static void virtiovf_pci_remove(struct pci_dev *pdev)
 }
 
 static const struct pci_device_id virtiovf_pci_table[] = {
-       /* Only virtio-net is supported/tested so far */
+       /* Only virtio-net and virtio-block are supported/tested so far */
        { PCI_DRIVER_OVERRIDE_DEVICE_VFIO(PCI_VENDOR_ID_REDHAT_QUMRANET, 0x1041) },
+       { PCI_DRIVER_OVERRIDE_DEVICE_VFIO(PCI_VENDOR_ID_REDHAT_QUMRANET, 0x1042) },
        {}
 };
 
@@ -221,4 +222,4 @@ module_pci_driver(virtiovf_pci_driver);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Yishai Hadas <yishaih@nvidia.com>");
 MODULE_DESCRIPTION(
-       "VIRTIO VFIO PCI - User Level meta-driver for VIRTIO NET devices");
+       "VIRTIO VFIO PCI - User Level meta-driver for VIRTIO NET and BLOCK devices");