diff mbox series

[vfio] vfio/virtio: Enable support for virtio-block live migration

Message ID 20250224121830.229905-1-yishaih@nvidia.com (mailing list archive)
State New
Headers show
Series [vfio] vfio/virtio: Enable support for virtio-block live migration | expand

Commit Message

Yishai Hadas Feb. 24, 2025, 12:18 p.m. UTC
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.

Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
---
 drivers/vfio/pci/virtio/Kconfig     | 6 +++---
 drivers/vfio/pci/virtio/legacy_io.c | 4 +++-
 drivers/vfio/pci/virtio/main.c      | 5 +++--
 3 files changed, 9 insertions(+), 6 deletions(-)

Comments

Tian, Kevin Feb. 26, 2025, 8:06 a.m. UTC | #1
> From: Yishai Hadas <yishaih@nvidia.com>
> Sent: Monday, February 24, 2025 8:19 PM
> 
>  config VIRTIO_VFIO_PCI
> -	tristate "VFIO support for VIRTIO NET PCI VF devices"
> +	tristate "VFIO support for VIRTIO NET,BLOCK 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,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.

Probably just describe it as "VFIO support for VIRTIO PCI VF devices"?
Anyway one needs to check out the specific id table in the driver for
which devices are supported. and the config option is called as
VIRTIO_VFIO_PCI

>  MODULE_DESCRIPTION(
> -	"VIRTIO VFIO PCI - User Level meta-driver for VIRTIO NET devices");
> +	"VIRTIO VFIO PCI - User Level meta-driver for VIRTIO NET,BLOCK
> devices");

Same here.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Yishai Hadas Feb. 26, 2025, 11:51 a.m. UTC | #2
On 26/02/2025 10:06, Tian, Kevin wrote:
>> From: Yishai Hadas <yishaih@nvidia.com>
>> Sent: Monday, February 24, 2025 8:19 PM
>>
>>   config VIRTIO_VFIO_PCI
>> -	tristate "VFIO support for VIRTIO NET PCI VF devices"
>> +	tristate "VFIO support for VIRTIO NET,BLOCK 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,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.
> 
> Probably just describe it as "VFIO support for VIRTIO PCI VF devices"?
> Anyway one needs to check out the specific id table in the driver for
> which devices are supported. and the config option is called as
> VIRTIO_VFIO_PCI

I'm OK with that as well, both can work.

Alex,
Any preference here ?

> 
>>   MODULE_DESCRIPTION(
>> -	"VIRTIO VFIO PCI - User Level meta-driver for VIRTIO NET devices");
>> +	"VIRTIO VFIO PCI - User Level meta-driver for VIRTIO NET,BLOCK
>> devices");
> 
> Same here.
> 
> Reviewed-by: Kevin Tian <kevin.tian@intel.com>

Thanks for your RB.

Yishai
Alex Williamson Feb. 27, 2025, 10:54 p.m. UTC | #3
On Wed, 26 Feb 2025 13:51:17 +0200
Yishai Hadas <yishaih@nvidia.com> wrote:

> On 26/02/2025 10:06, Tian, Kevin wrote:
> >> From: Yishai Hadas <yishaih@nvidia.com>
> >> Sent: Monday, February 24, 2025 8:19 PM
> >>
> >>   config VIRTIO_VFIO_PCI
> >> -	tristate "VFIO support for VIRTIO NET PCI VF devices"
> >> +	tristate "VFIO support for VIRTIO NET,BLOCK 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,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.  
> > 
> > Probably just describe it as "VFIO support for VIRTIO PCI VF devices"?
> > Anyway one needs to check out the specific id table in the driver for
> > which devices are supported. and the config option is called as
> > VIRTIO_VFIO_PCI  
> 
> I'm OK with that as well, both can work.
> 
> Alex,
> Any preference here ?

What's actually the proposal?  It's fine with me if we want to make the
tristate summary more generic, but I'd keep the mention of the specific
devices in the help text.  I don't know many users that preemptively
look at the id table.

I might replace "NET,BLOCK" with "NET and BLOCK" for readability though.
Thanks,

Alex
Tian, Kevin Feb. 28, 2025, 6:43 a.m. UTC | #4
> From: Alex Williamson <alex.williamson@redhat.com>
> Sent: Friday, February 28, 2025 6:55 AM
> 
> On Wed, 26 Feb 2025 13:51:17 +0200
> Yishai Hadas <yishaih@nvidia.com> wrote:
> 
> > On 26/02/2025 10:06, Tian, Kevin wrote:
> > >> From: Yishai Hadas <yishaih@nvidia.com>
> > >> Sent: Monday, February 24, 2025 8:19 PM
> > >>
> > >>   config VIRTIO_VFIO_PCI
> > >> -	tristate "VFIO support for VIRTIO NET PCI VF devices"
> > >> +	tristate "VFIO support for VIRTIO NET,BLOCK 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,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.
> > >
> > > Probably just describe it as "VFIO support for VIRTIO PCI VF devices"?
> > > Anyway one needs to check out the specific id table in the driver for
> > > which devices are supported. and the config option is called as
> > > VIRTIO_VFIO_PCI
> >
> > I'm OK with that as well, both can work.
> >
> > Alex,
> > Any preference here ?
> 
> What's actually the proposal?  It's fine with me if we want to make the
> tristate summary more generic, but I'd keep the mention of the specific
> devices in the help text.  I don't know many users that preemptively
> look at the id table.
> 

I proposed to remove specific devices from both the summary and
the description. Fine to do it only for the summary.
diff mbox series

Patch

diff --git a/drivers/vfio/pci/virtio/Kconfig b/drivers/vfio/pci/virtio/Kconfig
index 2770f7eb702c..a279cb2b8b8a 100644
--- a/drivers/vfio/pci/virtio/Kconfig
+++ b/drivers/vfio/pci/virtio/Kconfig
@@ -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 NET,BLOCK 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,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.
diff --git a/drivers/vfio/pci/virtio/legacy_io.c b/drivers/vfio/pci/virtio/legacy_io.c
index 20382ee15fac..832af5ba267c 100644
--- a/drivers/vfio/pci/virtio/legacy_io.c
+++ b/drivers/vfio/pci/virtio/legacy_io.c
@@ -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)
diff --git a/drivers/vfio/pci/virtio/main.c b/drivers/vfio/pci/virtio/main.c
index d534d48c4163..ab1129a20e4d 100644
--- a/drivers/vfio/pci/virtio/main.c
+++ b/drivers/vfio/pci/virtio/main.c
@@ -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,BLOCK devices");