[PATCH 15/22] vfio/pci.h: use QOM casts where appropriate

Mark Cave-Ayland posted 22 patches 4 months ago
Maintainers: Nicholas Piggin <npiggin@gmail.com>, Daniel Henrique Barboza <danielhb413@gmail.com>, Harsh Prateek Bora <harshpb@linux.ibm.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, John Levon <john.levon@nutanix.com>, Thanos Makatos <thanos.makatos@nutanix.com>, Alex Williamson <alex.williamson@redhat.com>, "Cédric Le Goater" <clg@redhat.com>, Steve Sistare <steven.sistare@oracle.com>, Tomita Moeko <tomitamoeko@gmail.com>
[PATCH 15/22] vfio/pci.h: use QOM casts where appropriate
Posted by Mark Cave-Ayland 4 months ago
Use QOM casts to convert between VFIOPCIDevice and PCIDevice instead of
accessing pdev directly.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
---
 hw/vfio/pci.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index 16f092a0c6..c0c3d68742 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -206,7 +206,7 @@ static inline bool vfio_pci_is(VFIOPCIDevice *vdev, uint32_t vendor, uint32_t de
 
 static inline bool vfio_is_vga(VFIOPCIDevice *vdev)
 {
-    PCIDevice *pdev = &vdev->pdev;
+    PCIDevice *pdev = PCI_DEVICE(vdev);
     uint16_t class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
 
     return class == PCI_CLASS_DISPLAY_VGA;
-- 
2.43.0
Re: [PATCH 15/22] vfio/pci.h: use QOM casts where appropriate
Posted by Cédric Le Goater 2 months, 1 week ago
On 7/15/25 11:25, Mark Cave-Ayland wrote:
> Use QOM casts to convert between VFIOPCIDevice and PCIDevice instead of
> accessing pdev directly.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> ---
>   hw/vfio/pci.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
> index 16f092a0c6..c0c3d68742 100644
> --- a/hw/vfio/pci.h
> +++ b/hw/vfio/pci.h
> @@ -206,7 +206,7 @@ static inline bool vfio_pci_is(VFIOPCIDevice *vdev, uint32_t vendor, uint32_t de
>   
>   static inline bool vfio_is_vga(VFIOPCIDevice *vdev)
>   {
> -    PCIDevice *pdev = &vdev->pdev;
> +    PCIDevice *pdev = PCI_DEVICE(vdev);
>       uint16_t class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
>   
>       return class == PCI_CLASS_DISPLAY_VGA;


This patch does not apply anymore. I will drop it.



Thanks,

C.
Re: [PATCH 15/22] vfio/pci.h: use QOM casts where appropriate
Posted by Mark Cave-Ayland 2 months ago
On 08/09/2025 13:41, Cédric Le Goater wrote:

> On 7/15/25 11:25, Mark Cave-Ayland wrote:
>> Use QOM casts to convert between VFIOPCIDevice and PCIDevice instead of
>> accessing pdev directly.
>>
>> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>> ---
>>   hw/vfio/pci.h | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
>> index 16f092a0c6..c0c3d68742 100644
>> --- a/hw/vfio/pci.h
>> +++ b/hw/vfio/pci.h
>> @@ -206,7 +206,7 @@ static inline bool vfio_pci_is(VFIOPCIDevice 
>> *vdev, uint32_t vendor, uint32_t de
>>   static inline bool vfio_is_vga(VFIOPCIDevice *vdev)
>>   {
>> -    PCIDevice *pdev = &vdev->pdev;
>> +    PCIDevice *pdev = PCI_DEVICE(vdev);
>>       uint16_t class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
>>       return class == PCI_CLASS_DISPLAY_VGA;
> 
> 
> This patch does not apply anymore. I will drop it.
>  
> Thanks,
> 
> C.

Thanks for the heads-up - I'll take a look and come up with an updated 
version.


ATB,

Mark.


Re: [PATCH 15/22] vfio/pci.h: use QOM casts where appropriate
Posted by Mark Cave-Ayland 2 months ago
On 09/09/2025 16:10, Mark Cave-Ayland wrote:

> On 08/09/2025 13:41, Cédric Le Goater wrote:
> 
>> On 7/15/25 11:25, Mark Cave-Ayland wrote:
>>> Use QOM casts to convert between VFIOPCIDevice and PCIDevice instead of
>>> accessing pdev directly.
>>>
>>> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>>> ---
>>>   hw/vfio/pci.h | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
>>> index 16f092a0c6..c0c3d68742 100644
>>> --- a/hw/vfio/pci.h
>>> +++ b/hw/vfio/pci.h
>>> @@ -206,7 +206,7 @@ static inline bool vfio_pci_is(VFIOPCIDevice 
>>> *vdev, uint32_t vendor, uint32_t de
>>>   static inline bool vfio_is_vga(VFIOPCIDevice *vdev)
>>>   {
>>> -    PCIDevice *pdev = &vdev->pdev;
>>> +    PCIDevice *pdev = PCI_DEVICE(vdev);
>>>       uint16_t class = pci_get_word(pdev->config + PCI_CLASS_DEVICE);
>>>       return class == PCI_CLASS_DISPLAY_VGA;
>>
>>
>> This patch does not apply anymore. I will drop it.
>>
>> Thanks,
>>
>> C.
> 
> Thanks for the heads-up - I'll take a look and come up with an updated 
> version.

In fact, this patch isn't even needed anymore so no fixup required :)


ATB,

Mark.