[PATCH rfcv2 07/18] vfio/container: Implement host_iommu_device_init callback in legacy mode

Zhenzhong Duan posted 18 patches 9 months, 4 weeks ago
Maintainers: Yi Liu <yi.l.liu@intel.com>, Eric Auger <eric.auger@redhat.com>, Zhenzhong Duan <zhenzhong.duan@intel.com>, "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Peter Xu <peterx@redhat.com>, Jason Wang <jasowang@redhat.com>, Thomas Huth <thuth@redhat.com>, Alex Williamson <alex.williamson@redhat.com>, "Cédric Le Goater" <clg@redhat.com>, Tony Krowiak <akrowiak@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Jason Herne <jjherne@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>
There is a newer version of this series
[PATCH rfcv2 07/18] vfio/container: Implement host_iommu_device_init callback in legacy mode
Posted by Zhenzhong Duan 9 months, 4 weeks ago
This callback will be used to initialize base and public elements
in IOMMULegacyDevice.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
 hw/vfio/container.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/vfio/container.c b/hw/vfio/container.c
index bd25b9fbad..8fafd4b4e5 100644
--- a/hw/vfio/container.c
+++ b/hw/vfio/container.c
@@ -1120,6 +1120,12 @@ out_single:
     return ret;
 }
 
+static void vfio_legacy_host_iommu_device_init(VFIODevice *vbasedev)
+{
+    host_iommu_base_device_init(&vbasedev->base_hdev, HID_LEGACY,
+                                sizeof(IOMMULegacyDevice));
+}
+
 static void vfio_iommu_legacy_class_init(ObjectClass *klass, void *data)
 {
     VFIOIOMMUClass *vioc = VFIO_IOMMU_CLASS(klass);
@@ -1132,6 +1138,7 @@ static void vfio_iommu_legacy_class_init(ObjectClass *klass, void *data)
     vioc->set_dirty_page_tracking = vfio_legacy_set_dirty_page_tracking;
     vioc->query_dirty_bitmap = vfio_legacy_query_dirty_bitmap;
     vioc->pci_hot_reset = vfio_legacy_pci_hot_reset;
+    vioc->host_iommu_device_init = vfio_legacy_host_iommu_device_init;
 };
 
 static const TypeInfo types[] = {
-- 
2.34.1
Re: [PATCH rfcv2 07/18] vfio/container: Implement host_iommu_device_init callback in legacy mode
Posted by Eric Auger 9 months, 1 week ago
Hi Zhenzhong,
On 2/1/24 08:28, Zhenzhong Duan wrote:
> This callback will be used to initialize base and public elements
> in IOMMULegacyDevice.
>
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> ---
>  hw/vfio/container.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/hw/vfio/container.c b/hw/vfio/container.c
> index bd25b9fbad..8fafd4b4e5 100644
> --- a/hw/vfio/container.c
> +++ b/hw/vfio/container.c
> @@ -1120,6 +1120,12 @@ out_single:
>      return ret;
>  }
>  
> +static void vfio_legacy_host_iommu_device_init(VFIODevice *vbasedev)
> +{
> +    host_iommu_base_device_init(&vbasedev->base_hdev, HID_LEGACY,
> +                                sizeof(IOMMULegacyDevice));
To me this should allocate a new

 IOMMULegacyDevice and set the VFIODevice base_hdev handle to its base @

Thanks

Eric

> +}
> +
>  static void vfio_iommu_legacy_class_init(ObjectClass *klass, void *data)
>  {
>      VFIOIOMMUClass *vioc = VFIO_IOMMU_CLASS(klass);
> @@ -1132,6 +1138,7 @@ static void vfio_iommu_legacy_class_init(ObjectClass *klass, void *data)
>      vioc->set_dirty_page_tracking = vfio_legacy_set_dirty_page_tracking;
>      vioc->query_dirty_bitmap = vfio_legacy_query_dirty_bitmap;
>      vioc->pci_hot_reset = vfio_legacy_pci_hot_reset;
> +    vioc->host_iommu_device_init = vfio_legacy_host_iommu_device_init;
>  };
>  
>  static const TypeInfo types[] = {
RE: [PATCH rfcv2 07/18] vfio/container: Implement host_iommu_device_init callback in legacy mode
Posted by Duan, Zhenzhong 9 months ago

>-----Original Message-----
>From: Eric Auger <eric.auger@redhat.com>
>Subject: Re: [PATCH rfcv2 07/18] vfio/container: Implement
>host_iommu_device_init callback in legacy mode
>
>Hi Zhenzhong,
>On 2/1/24 08:28, Zhenzhong Duan wrote:
>> This callback will be used to initialize base and public elements
>> in IOMMULegacyDevice.
>>
>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>> ---
>>  hw/vfio/container.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/hw/vfio/container.c b/hw/vfio/container.c
>> index bd25b9fbad..8fafd4b4e5 100644
>> --- a/hw/vfio/container.c
>> +++ b/hw/vfio/container.c
>> @@ -1120,6 +1120,12 @@ out_single:
>>      return ret;
>>  }
>>
>> +static void vfio_legacy_host_iommu_device_init(VFIODevice *vbasedev)
>> +{
>> +    host_iommu_base_device_init(&vbasedev->base_hdev, HID_LEGACY,
>> +                                sizeof(IOMMULegacyDevice));
>To me this should allocate a new
>
> IOMMULegacyDevice and set the VFIODevice base_hdev handle to its base

Sure, will do.

Thanks
Zhenzhong