[PATCH 00/22] vfio: improve use of QOM and coding guidelines

Mark Cave-Ayland posted 22 patches 4 months ago
Failed in applying to current master (apply log)
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>
hw/ppc/spapr_pci_vfio.c               |   2 +-
hw/s390x/s390-pci-vfio.c              |  14 +-
hw/vfio-user/container.c              |  26 ++--
hw/vfio-user/container.h              |   7 +-
hw/vfio-user/pci.c                    |  16 +-
hw/vfio/container.c                   |  31 ++--
hw/vfio/cpr-legacy.c                  |  14 +-
hw/vfio/cpr.c                         |  10 +-
hw/vfio/igd.c                         |  38 ++---
hw/vfio/pci-quirks.c                  |  48 +++---
hw/vfio/pci.c                         | 206 +++++++++++++++-----------
hw/vfio/pci.h                         |   5 +-
hw/vfio/spapr.c                       |  16 +-
include/hw/vfio/vfio-container-base.h |  13 +-
include/hw/vfio/vfio-container.h      |   7 +-
15 files changed, 249 insertions(+), 204 deletions(-)
[PATCH 00/22] vfio: improve use of QOM and coding guidelines
Posted by Mark Cave-Ayland 4 months ago
This series attempts to improve use of QOM within the vfio subsystem which
appears to have been added at a later date. It's mostly mechanical changes
that do the following:

  1) Format the QOM structs per our coding guidelines

  2) Ensure the parent object is called parent_obj

  3) Use QOM casts to access the parent object, instead of accessing
     the parent struct member directly

The benefits of this are that the QOM casts included type checking to help
ensure the right object is being passed into the cast, and it also becomes
much easier to infer the class hierarchy from reading the code.

Having produced this series, it feels to me that the readability could be
further improved by renaming the structs as follows:

   VFIOContainer     -> VFIOLegacyContainer
   VFIOContainerBase -> VFIOContainer

However I have left this for now given how close that we are to freeze.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>


Mark Cave-Ayland (22):
  vfio/vfio-container-base.h: update VFIOContainerBase declaration
  vfio/vfio-container.h: update VFIOContainer declaration
  hw/vfio/cpr-legacy.c: use QOM casts where appropriate
  hw/vfio/container.c: use QOM casts where appropriate
  ppc/spapr_pci_vfio.c: use QOM casts where appropriate
  vfio/spapr.c: use QOM casts where appropriate
  vfio/vfio-container.h: rename VFIOContainer bcontainer field to
    parent_obj
  vfio-user/container.h: update VFIOUserContainer declaration
  vfio/container.c: use QOM casts where appropriate
  vfio-user/container.h: rename VFIOUserContainer bcontainer field to
    parent_obj
  vfio-user/pci.c: update VFIOUserPCIDevice declaration
  vfio-user/pci.c: use QOM casts where appropriate
  vfio-user/pci.c: rename VFIOUserPCIDevice device field to parent_obj
  vfio/pci.h: update VFIOPCIDevice declaration
  vfio/pci.h: use QOM casts where appropriate
  vfio/pci.c: use QOM casts where appropriate
  vfio/pci-quirks.c: use QOM casts where appropriate
  vfio/cpr.c: use QOM casts where appropriate
  vfio/igd.c: use QOM casts where appropriate
  vfio-user/pci.c: use QOM casts where appropriate
  s390x/s390-pci-vfio.c: use QOM casts where appropriate
  vfio/pci.h: rename VFIOPCIDevice pdev field to parent_obj

 hw/ppc/spapr_pci_vfio.c               |   2 +-
 hw/s390x/s390-pci-vfio.c              |  14 +-
 hw/vfio-user/container.c              |  26 ++--
 hw/vfio-user/container.h              |   7 +-
 hw/vfio-user/pci.c                    |  16 +-
 hw/vfio/container.c                   |  31 ++--
 hw/vfio/cpr-legacy.c                  |  14 +-
 hw/vfio/cpr.c                         |  10 +-
 hw/vfio/igd.c                         |  38 ++---
 hw/vfio/pci-quirks.c                  |  48 +++---
 hw/vfio/pci.c                         | 206 +++++++++++++++-----------
 hw/vfio/pci.h                         |   5 +-
 hw/vfio/spapr.c                       |  16 +-
 include/hw/vfio/vfio-container-base.h |  13 +-
 include/hw/vfio/vfio-container.h      |   7 +-
 15 files changed, 249 insertions(+), 204 deletions(-)

-- 
2.43.0
Re: [PATCH 00/22] vfio: improve use of QOM and coding guidelines
Posted by Cédric Le Goater 2 months, 1 week ago
On 7/15/25 11:25, Mark Cave-Ayland wrote:
> This series attempts to improve use of QOM within the vfio subsystem which
> appears to have been added at a later date. It's mostly mechanical changes
> that do the following:
> 
>    1) Format the QOM structs per our coding guidelines
> 
>    2) Ensure the parent object is called parent_obj
> 
>    3) Use QOM casts to access the parent object, instead of accessing
>       the parent struct member directly
> 
> The benefits of this are that the QOM casts included type checking to help
> ensure the right object is being passed into the cast, and it also becomes
> much easier to infer the class hierarchy from reading the code.
> 
> Having produced this series, it feels to me that the readability could be
> further improved by renaming the structs as follows:
> 
>     VFIOContainer     -> VFIOLegacyContainer
>     VFIOContainerBase -> VFIOContainer
> 
> However I have left this for now given how close that we are to freeze.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> 
> 
> Mark Cave-Ayland (22):
>    vfio/vfio-container-base.h: update VFIOContainerBase declaration
>    vfio/vfio-container.h: update VFIOContainer declaration
>    hw/vfio/cpr-legacy.c: use QOM casts where appropriate
>    hw/vfio/container.c: use QOM casts where appropriate
>    ppc/spapr_pci_vfio.c: use QOM casts where appropriate
>    vfio/spapr.c: use QOM casts where appropriate
>    vfio/vfio-container.h: rename VFIOContainer bcontainer field to
>      parent_obj
>    vfio-user/container.h: update VFIOUserContainer declaration
>    vfio/container.c: use QOM casts where appropriate
>    vfio-user/container.h: rename VFIOUserContainer bcontainer field to
>      parent_obj
>    vfio-user/pci.c: update VFIOUserPCIDevice declaration
>    vfio-user/pci.c: use QOM casts where appropriate
>    vfio-user/pci.c: rename VFIOUserPCIDevice device field to parent_obj
>    vfio/pci.h: update VFIOPCIDevice declaration
>    vfio/pci.h: use QOM casts where appropriate
>    vfio/pci.c: use QOM casts where appropriate
>    vfio/pci-quirks.c: use QOM casts where appropriate
>    vfio/cpr.c: use QOM casts where appropriate
>    vfio/igd.c: use QOM casts where appropriate
>    vfio-user/pci.c: use QOM casts where appropriate
>    s390x/s390-pci-vfio.c: use QOM casts where appropriate
>    vfio/pci.h: rename VFIOPCIDevice pdev field to parent_obj
> 
>   hw/ppc/spapr_pci_vfio.c               |   2 +-
>   hw/s390x/s390-pci-vfio.c              |  14 +-
>   hw/vfio-user/container.c              |  26 ++--
>   hw/vfio-user/container.h              |   7 +-
>   hw/vfio-user/pci.c                    |  16 +-
>   hw/vfio/container.c                   |  31 ++--
>   hw/vfio/cpr-legacy.c                  |  14 +-
>   hw/vfio/cpr.c                         |  10 +-
>   hw/vfio/igd.c                         |  38 ++---
>   hw/vfio/pci-quirks.c                  |  48 +++---
>   hw/vfio/pci.c                         | 206 +++++++++++++++-----------
>   hw/vfio/pci.h                         |   5 +-
>   hw/vfio/spapr.c                       |  16 +-
>   include/hw/vfio/vfio-container-base.h |  13 +-
>   include/hw/vfio/vfio-container.h      |   7 +-
>   15 files changed, 249 insertions(+), 204 deletions(-)
> 

I did some tests with an IGB device and didn't see any performance
regression.

Applied to vfio-next.

Thanks,

C.
Re: [PATCH 00/22] vfio: improve use of QOM and coding guidelines
Posted by Mark Cave-Ayland 2 months ago
On 08/09/2025 15:19, Cédric Le Goater wrote:

> On 7/15/25 11:25, Mark Cave-Ayland wrote:
>> This series attempts to improve use of QOM within the vfio subsystem 
>> which
>> appears to have been added at a later date. It's mostly mechanical 
>> changes
>> that do the following:
>>
>>    1) Format the QOM structs per our coding guidelines
>>
>>    2) Ensure the parent object is called parent_obj
>>
>>    3) Use QOM casts to access the parent object, instead of accessing
>>       the parent struct member directly
>>
>> The benefits of this are that the QOM casts included type checking to 
>> help
>> ensure the right object is being passed into the cast, and it also 
>> becomes
>> much easier to infer the class hierarchy from reading the code.
>>
>> Having produced this series, it feels to me that the readability could be
>> further improved by renaming the structs as follows:
>>
>>     VFIOContainer     -> VFIOLegacyContainer
>>     VFIOContainerBase -> VFIOContainer
>>
>> However I have left this for now given how close that we are to freeze.
>>
>> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>>
>>
>> Mark Cave-Ayland (22):
>>    vfio/vfio-container-base.h: update VFIOContainerBase declaration
>>    vfio/vfio-container.h: update VFIOContainer declaration
>>    hw/vfio/cpr-legacy.c: use QOM casts where appropriate
>>    hw/vfio/container.c: use QOM casts where appropriate
>>    ppc/spapr_pci_vfio.c: use QOM casts where appropriate
>>    vfio/spapr.c: use QOM casts where appropriate
>>    vfio/vfio-container.h: rename VFIOContainer bcontainer field to
>>      parent_obj
>>    vfio-user/container.h: update VFIOUserContainer declaration
>>    vfio/container.c: use QOM casts where appropriate
>>    vfio-user/container.h: rename VFIOUserContainer bcontainer field to
>>      parent_obj
>>    vfio-user/pci.c: update VFIOUserPCIDevice declaration
>>    vfio-user/pci.c: use QOM casts where appropriate
>>    vfio-user/pci.c: rename VFIOUserPCIDevice device field to parent_obj
>>    vfio/pci.h: update VFIOPCIDevice declaration
>>    vfio/pci.h: use QOM casts where appropriate
>>    vfio/pci.c: use QOM casts where appropriate
>>    vfio/pci-quirks.c: use QOM casts where appropriate
>>    vfio/cpr.c: use QOM casts where appropriate
>>    vfio/igd.c: use QOM casts where appropriate
>>    vfio-user/pci.c: use QOM casts where appropriate
>>    s390x/s390-pci-vfio.c: use QOM casts where appropriate
>>    vfio/pci.h: rename VFIOPCIDevice pdev field to parent_obj
>>
>>   hw/ppc/spapr_pci_vfio.c               |   2 +-
>>   hw/s390x/s390-pci-vfio.c              |  14 +-
>>   hw/vfio-user/container.c              |  26 ++--
>>   hw/vfio-user/container.h              |   7 +-
>>   hw/vfio-user/pci.c                    |  16 +-
>>   hw/vfio/container.c                   |  31 ++--
>>   hw/vfio/cpr-legacy.c                  |  14 +-
>>   hw/vfio/cpr.c                         |  10 +-
>>   hw/vfio/igd.c                         |  38 ++---
>>   hw/vfio/pci-quirks.c                  |  48 +++---
>>   hw/vfio/pci.c                         | 206 +++++++++++++++-----------
>>   hw/vfio/pci.h                         |   5 +-
>>   hw/vfio/spapr.c                       |  16 +-
>>   include/hw/vfio/vfio-container-base.h |  13 +-
>>   include/hw/vfio/vfio-container.h      |   7 +-
>>   15 files changed, 249 insertions(+), 204 deletions(-)
>>
> 
> I did some tests with an IGB device and didn't see any performance
> regression.
> 
> Applied to vfio-next.

That's great news! Thanks for doing a performance check with this 
series, I'm currently investigating what environments are available here 
internally for performance testing.

> Thanks,
> 
> C.


ATB,

Mark.


Re: [PATCH 00/22] vfio: improve use of QOM and coding guidelines
Posted by Cédric Le Goater 4 months ago
On 7/15/25 11:25, Mark Cave-Ayland wrote:
> This series attempts to improve use of QOM within the vfio subsystem which
> appears to have been added at a later date. It's mostly mechanical changes
> that do the following:
> 
>    1) Format the QOM structs per our coding guidelines
> 
>    2) Ensure the parent object is called parent_obj
> 
>    3) Use QOM casts to access the parent object, instead of accessing
>       the parent struct member directly
> 
> The benefits of this are that the QOM casts included type checking to help
> ensure the right object is being passed into the cast, and it also becomes
> much easier to infer the class hierarchy from reading the code.
> 
> Having produced this series, it feels to me that the readability could be
> further improved by renaming the structs as follows:
> 
>     VFIOContainer     -> VFIOLegacyContainer
>     VFIOContainerBase -> VFIOContainer

Yes.

> However I have left this for now given how close that we are to freeze.

I think this is too much of a change to QEMU 10.1 too. Let's keep it
as the first QEMU 10.2 series. Feel free to extend it.

Thanks,

C.


> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> 
> 
> Mark Cave-Ayland (22):
>    vfio/vfio-container-base.h: update VFIOContainerBase declaration
>    vfio/vfio-container.h: update VFIOContainer declaration
>    hw/vfio/cpr-legacy.c: use QOM casts where appropriate
>    hw/vfio/container.c: use QOM casts where appropriate
>    ppc/spapr_pci_vfio.c: use QOM casts where appropriate
>    vfio/spapr.c: use QOM casts where appropriate
>    vfio/vfio-container.h: rename VFIOContainer bcontainer field to
>      parent_obj
>    vfio-user/container.h: update VFIOUserContainer declaration
>    vfio/container.c: use QOM casts where appropriate
>    vfio-user/container.h: rename VFIOUserContainer bcontainer field to
>      parent_obj
>    vfio-user/pci.c: update VFIOUserPCIDevice declaration
>    vfio-user/pci.c: use QOM casts where appropriate
>    vfio-user/pci.c: rename VFIOUserPCIDevice device field to parent_obj
>    vfio/pci.h: update VFIOPCIDevice declaration
>    vfio/pci.h: use QOM casts where appropriate
>    vfio/pci.c: use QOM casts where appropriate
>    vfio/pci-quirks.c: use QOM casts where appropriate
>    vfio/cpr.c: use QOM casts where appropriate
>    vfio/igd.c: use QOM casts where appropriate
>    vfio-user/pci.c: use QOM casts where appropriate
>    s390x/s390-pci-vfio.c: use QOM casts where appropriate
>    vfio/pci.h: rename VFIOPCIDevice pdev field to parent_obj
> 
>   hw/ppc/spapr_pci_vfio.c               |   2 +-
>   hw/s390x/s390-pci-vfio.c              |  14 +-
>   hw/vfio-user/container.c              |  26 ++--
>   hw/vfio-user/container.h              |   7 +-
>   hw/vfio-user/pci.c                    |  16 +-
>   hw/vfio/container.c                   |  31 ++--
>   hw/vfio/cpr-legacy.c                  |  14 +-
>   hw/vfio/cpr.c                         |  10 +-
>   hw/vfio/igd.c                         |  38 ++---
>   hw/vfio/pci-quirks.c                  |  48 +++---
>   hw/vfio/pci.c                         | 206 +++++++++++++++-----------
>   hw/vfio/pci.h                         |   5 +-
>   hw/vfio/spapr.c                       |  16 +-
>   include/hw/vfio/vfio-container-base.h |  13 +-
>   include/hw/vfio/vfio-container.h      |   7 +-
>   15 files changed, 249 insertions(+), 204 deletions(-)
>