[PATCH v2 0/7] include/hw/pci include/hw/cxl: Clean up includes

Markus Armbruster posted 7 patches 1 year, 4 months ago
Failed in applying to current master (apply log)
hw/alpha/alpha_sys.h                |   1 -
hw/display/ati_int.h                |   2 +-
hw/display/qxl.h                    |   3 +-
hw/ide/ahci_internal.h              |   2 +-
hw/net/vmxnet3_defs.h               |   2 +-
hw/nvme/nvme.h                      |   2 +-
hw/rdma/rdma_utils.h                |   1 -
hw/rdma/vmw/pvrdma.h                |   2 +-
hw/scsi/mptsas.h                    |   2 +-
hw/usb/hcd-ehci.h                   |   3 +-
hw/usb/hcd-uhci.h                   |   2 +-
hw/usb/hcd-xhci-pci.h               |   1 +
hw/vfio/pci.h                       |   2 +-
hw/xen/xen_pt.h                     |   1 -
include/hw/acpi/piix4.h             |   2 +-
include/hw/arm/allwinner-a10.h      |   1 +
include/hw/cxl/cxl.h                |   5 +-
include/hw/cxl/cxl_cdat.h           |   1 +
include/hw/cxl/cxl_component.h      |   1 +
include/hw/cxl/cxl_device.h         |   2 +
include/hw/cxl/cxl_pci.h            |   3 -
include/hw/i386/ich9.h              |   4 -
include/hw/i386/x86-iommu.h         |   1 -
include/hw/ide/pci.h                |   2 +-
include/hw/isa/vt82c686.h           |   1 -
include/hw/misc/macio/macio.h       |   2 +-
include/hw/pci-host/designware.h    |   3 -
include/hw/pci-host/gpex.h          |   2 +-
include/hw/pci-host/i440fx.h        |   2 +-
include/hw/pci-host/ls7a.h          |   2 -
include/hw/pci-host/pnv_phb3.h      |   2 -
include/hw/pci-host/pnv_phb4.h      |   3 +-
include/hw/pci-host/q35.h           |   2 +-
include/hw/pci-host/sabre.h         |   2 +-
include/hw/pci-host/xilinx-pcie.h   |   1 -
include/hw/pci/msi.h                |   2 +-
include/hw/pci/pci.h                | 341 ---------------------------
include/hw/pci/pci_bridge.h         |   3 +-
include/hw/pci/pci_device.h         | 350 ++++++++++++++++++++++++++++
include/hw/pci/pcie.h               |   1 -
include/hw/pci/pcie_port.h          |   1 +
include/hw/pci/pcie_sriov.h         |   2 +
include/hw/pci/shpc.h               |   2 +-
include/hw/remote/iohub.h           |   2 +-
include/hw/remote/proxy.h           |   2 +-
include/hw/sd/sdhci.h               |   2 +-
include/hw/southbridge/piix.h       |   3 +-
include/hw/virtio/virtio-scsi.h     |   1 -
include/hw/xen/xen_common.h         |   2 +-
hw/acpi/erst.c                      |   2 +-
hw/alpha/pci.c                      |   1 +
hw/alpha/typhoon.c                  |   2 +-
hw/audio/ac97.c                     |   2 +-
hw/audio/es1370.c                   |   2 +-
hw/audio/via-ac97.c                 |   2 +-
hw/char/serial-pci-multi.c          |   2 +-
hw/char/serial-pci.c                |   2 +-
hw/core/qdev-properties-system.c    |   1 +
hw/display/bochs-display.c          |   2 +-
hw/display/cirrus_vga.c             |   2 +-
hw/display/sm501.c                  |   2 +-
hw/display/vga-pci.c                |   2 +-
hw/display/vmware_vga.c             |   2 +-
hw/i386/acpi-build.c                |   2 +-
hw/i386/xen/xen_pvdevice.c          |   2 +-
hw/ipack/tpci200.c                  |   2 +-
hw/ipmi/pci_ipmi_bt.c               |   2 +-
hw/ipmi/pci_ipmi_kcs.c              |   2 +-
hw/isa/i82378.c                     |   2 +-
hw/mips/gt64xxx_pci.c               |   2 +-
hw/misc/pci-testdev.c               |   2 +-
hw/misc/pvpanic-pci.c               |   2 +-
hw/net/can/can_kvaser_pci.c         |   2 +-
hw/net/can/can_mioe3680_pci.c       |   2 +-
hw/net/can/can_pcm3680_pci.c        |   2 +-
hw/net/can/ctucan_pci.c             |   2 +-
hw/net/e1000.c                      |   2 +-
hw/net/e1000x_common.c              |   2 +-
hw/net/eepro100.c                   |   2 +-
hw/net/ne2000-pci.c                 |   2 +-
hw/net/net_tx_pkt.c                 |   2 +-
hw/net/pcnet-pci.c                  |   2 +-
hw/net/rocker/rocker.c              |   2 +-
hw/net/rocker/rocker_desc.c         |   2 +-
hw/net/rtl8139.c                    |   2 +-
hw/net/sungem.c                     |   2 +-
hw/net/sunhme.c                     |   2 +-
hw/net/tulip.c                      |   2 +-
hw/net/virtio-net.c                 |   2 +-
hw/pci-bridge/i82801b11.c           |   2 +-
hw/pci-bridge/pci_expander_bridge.c |   1 -
hw/pci-host/bonito.c                |   2 +-
hw/pci-host/dino.c                  |   2 +-
hw/pci-host/grackle.c               |   2 +-
hw/pci-host/mv64361.c               |   2 +-
hw/pci-host/ppce500.c               |   2 +-
hw/pci-host/raven.c                 |   2 +-
hw/pci-host/sh_pci.c                |   2 +-
hw/pci-host/uninorth.c              |   2 +-
hw/pci-host/versatile.c             |   2 +-
hw/pci/pci-hmp-cmds.c               |   1 +
hw/pci/pcie_host.c                  |   2 +-
hw/pci/pcie_sriov.c                 |   2 +-
hw/pci/slotid_cap.c                 |   2 +-
hw/ppc/ppc440_pcix.c                |   2 +-
hw/ppc/ppc4xx_pci.c                 |   2 +-
hw/ppc/spapr_pci_vfio.c             |   1 +
hw/rdma/rdma_utils.c                |   1 +
hw/s390x/s390-pci-inst.c            |   1 +
hw/scsi/esp-pci.c                   |   2 +-
hw/scsi/lsi53c895a.c                |   2 +-
hw/scsi/virtio-scsi.c               |   1 +
hw/smbios/smbios.c                  |   1 +
hw/usb/hcd-ohci-pci.c               |   2 +-
hw/watchdog/wdt_i6300esb.c          |   2 +-
tests/qtest/fuzz/generic_fuzz.c     |   1 +
ui/util.c                           |   2 +-
117 files changed, 455 insertions(+), 455 deletions(-)
create mode 100644 include/hw/pci/pci_device.h
[PATCH v2 0/7] include/hw/pci include/hw/cxl: Clean up includes
Posted by Markus Armbruster 1 year, 4 months ago
Back in 2016, we discussed[1] rules for headers, and these were
generally liked:

1. Have a carefully curated header that's included everywhere first.  We
   got that already thanks to Peter: osdep.h.

2. Headers should normally include everything they need beyond osdep.h.
   If exceptions are needed for some reason, they must be documented in
   the header.  If all that's needed from a header is typedefs, put
   those into qemu/typedefs.h instead of including the header.

3. Cyclic inclusion is forbidden.

After this series, include/hw/pci and include/hw/cxl conform to these
rules.

It is based on

    [PATCH v2 0/3] block: Clean up includes
    [PATCH v3 0/5] coroutine: Clean up includes

v2:
* Rebased
* PATCH 1: Actually breaks an inclusion loop; commit message rephrased
  accordingly
* PATCH 2: New [Jonathan]
* PATCH 5: tests/qtest/fuzz/generic_fuzz.c fixed [Michael]
* PATCH 6: Inclusion of cxl_pci.h into cxl_cdat_h kept, commit message
  adjusted [Jonathan]

[1] Message-ID: <87h9g8j57d.fsf@blackfin.pond.sub.org>
    https://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg03345.html

Based-on: <20221221133551.3967339-1-armbru@redhat.com>

Markus Armbruster (7):
  include/hw/pci: Break inclusion loop pci_bridge.h and cxl.h
  include/hw/cxl: Move typedef PXBDev to cxl.h, and put it to use
  include/hw/cxl: Include hw/cxl/*.h where needed
  include/hw/pci: Clean up a few things checkpatch.pl would flag
  include/hw/pci: Split pci_device.h off pci.h
  include/hw/pci: Include hw/pci/pci.h where needed
  include/hw/cxl: Break inclusion loop cxl_pci.h and cxl_cdat_h

 hw/alpha/alpha_sys.h                |   1 -
 hw/display/ati_int.h                |   2 +-
 hw/display/qxl.h                    |   3 +-
 hw/ide/ahci_internal.h              |   2 +-
 hw/net/vmxnet3_defs.h               |   2 +-
 hw/nvme/nvme.h                      |   2 +-
 hw/rdma/rdma_utils.h                |   1 -
 hw/rdma/vmw/pvrdma.h                |   2 +-
 hw/scsi/mptsas.h                    |   2 +-
 hw/usb/hcd-ehci.h                   |   3 +-
 hw/usb/hcd-uhci.h                   |   2 +-
 hw/usb/hcd-xhci-pci.h               |   1 +
 hw/vfio/pci.h                       |   2 +-
 hw/xen/xen_pt.h                     |   1 -
 include/hw/acpi/piix4.h             |   2 +-
 include/hw/arm/allwinner-a10.h      |   1 +
 include/hw/cxl/cxl.h                |   5 +-
 include/hw/cxl/cxl_cdat.h           |   1 +
 include/hw/cxl/cxl_component.h      |   1 +
 include/hw/cxl/cxl_device.h         |   2 +
 include/hw/cxl/cxl_pci.h            |   3 -
 include/hw/i386/ich9.h              |   4 -
 include/hw/i386/x86-iommu.h         |   1 -
 include/hw/ide/pci.h                |   2 +-
 include/hw/isa/vt82c686.h           |   1 -
 include/hw/misc/macio/macio.h       |   2 +-
 include/hw/pci-host/designware.h    |   3 -
 include/hw/pci-host/gpex.h          |   2 +-
 include/hw/pci-host/i440fx.h        |   2 +-
 include/hw/pci-host/ls7a.h          |   2 -
 include/hw/pci-host/pnv_phb3.h      |   2 -
 include/hw/pci-host/pnv_phb4.h      |   3 +-
 include/hw/pci-host/q35.h           |   2 +-
 include/hw/pci-host/sabre.h         |   2 +-
 include/hw/pci-host/xilinx-pcie.h   |   1 -
 include/hw/pci/msi.h                |   2 +-
 include/hw/pci/pci.h                | 341 ---------------------------
 include/hw/pci/pci_bridge.h         |   3 +-
 include/hw/pci/pci_device.h         | 350 ++++++++++++++++++++++++++++
 include/hw/pci/pcie.h               |   1 -
 include/hw/pci/pcie_port.h          |   1 +
 include/hw/pci/pcie_sriov.h         |   2 +
 include/hw/pci/shpc.h               |   2 +-
 include/hw/remote/iohub.h           |   2 +-
 include/hw/remote/proxy.h           |   2 +-
 include/hw/sd/sdhci.h               |   2 +-
 include/hw/southbridge/piix.h       |   3 +-
 include/hw/virtio/virtio-scsi.h     |   1 -
 include/hw/xen/xen_common.h         |   2 +-
 hw/acpi/erst.c                      |   2 +-
 hw/alpha/pci.c                      |   1 +
 hw/alpha/typhoon.c                  |   2 +-
 hw/audio/ac97.c                     |   2 +-
 hw/audio/es1370.c                   |   2 +-
 hw/audio/via-ac97.c                 |   2 +-
 hw/char/serial-pci-multi.c          |   2 +-
 hw/char/serial-pci.c                |   2 +-
 hw/core/qdev-properties-system.c    |   1 +
 hw/display/bochs-display.c          |   2 +-
 hw/display/cirrus_vga.c             |   2 +-
 hw/display/sm501.c                  |   2 +-
 hw/display/vga-pci.c                |   2 +-
 hw/display/vmware_vga.c             |   2 +-
 hw/i386/acpi-build.c                |   2 +-
 hw/i386/xen/xen_pvdevice.c          |   2 +-
 hw/ipack/tpci200.c                  |   2 +-
 hw/ipmi/pci_ipmi_bt.c               |   2 +-
 hw/ipmi/pci_ipmi_kcs.c              |   2 +-
 hw/isa/i82378.c                     |   2 +-
 hw/mips/gt64xxx_pci.c               |   2 +-
 hw/misc/pci-testdev.c               |   2 +-
 hw/misc/pvpanic-pci.c               |   2 +-
 hw/net/can/can_kvaser_pci.c         |   2 +-
 hw/net/can/can_mioe3680_pci.c       |   2 +-
 hw/net/can/can_pcm3680_pci.c        |   2 +-
 hw/net/can/ctucan_pci.c             |   2 +-
 hw/net/e1000.c                      |   2 +-
 hw/net/e1000x_common.c              |   2 +-
 hw/net/eepro100.c                   |   2 +-
 hw/net/ne2000-pci.c                 |   2 +-
 hw/net/net_tx_pkt.c                 |   2 +-
 hw/net/pcnet-pci.c                  |   2 +-
 hw/net/rocker/rocker.c              |   2 +-
 hw/net/rocker/rocker_desc.c         |   2 +-
 hw/net/rtl8139.c                    |   2 +-
 hw/net/sungem.c                     |   2 +-
 hw/net/sunhme.c                     |   2 +-
 hw/net/tulip.c                      |   2 +-
 hw/net/virtio-net.c                 |   2 +-
 hw/pci-bridge/i82801b11.c           |   2 +-
 hw/pci-bridge/pci_expander_bridge.c |   1 -
 hw/pci-host/bonito.c                |   2 +-
 hw/pci-host/dino.c                  |   2 +-
 hw/pci-host/grackle.c               |   2 +-
 hw/pci-host/mv64361.c               |   2 +-
 hw/pci-host/ppce500.c               |   2 +-
 hw/pci-host/raven.c                 |   2 +-
 hw/pci-host/sh_pci.c                |   2 +-
 hw/pci-host/uninorth.c              |   2 +-
 hw/pci-host/versatile.c             |   2 +-
 hw/pci/pci-hmp-cmds.c               |   1 +
 hw/pci/pcie_host.c                  |   2 +-
 hw/pci/pcie_sriov.c                 |   2 +-
 hw/pci/slotid_cap.c                 |   2 +-
 hw/ppc/ppc440_pcix.c                |   2 +-
 hw/ppc/ppc4xx_pci.c                 |   2 +-
 hw/ppc/spapr_pci_vfio.c             |   1 +
 hw/rdma/rdma_utils.c                |   1 +
 hw/s390x/s390-pci-inst.c            |   1 +
 hw/scsi/esp-pci.c                   |   2 +-
 hw/scsi/lsi53c895a.c                |   2 +-
 hw/scsi/virtio-scsi.c               |   1 +
 hw/smbios/smbios.c                  |   1 +
 hw/usb/hcd-ohci-pci.c               |   2 +-
 hw/watchdog/wdt_i6300esb.c          |   2 +-
 tests/qtest/fuzz/generic_fuzz.c     |   1 +
 ui/util.c                           |   2 +-
 117 files changed, 455 insertions(+), 455 deletions(-)
 create mode 100644 include/hw/pci/pci_device.h

-- 
2.38.1
Re: [PATCH v2 0/7] include/hw/pci include/hw/cxl: Clean up includes
Posted by Bernhard Beschow 1 year, 4 months ago

Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <armbru@redhat.com>:
>Back in 2016, we discussed[1] rules for headers, and these were
>generally liked:
>
>1. Have a carefully curated header that's included everywhere first.  We
>   got that already thanks to Peter: osdep.h.
>
>2. Headers should normally include everything they need beyond osdep.h.
>   If exceptions are needed for some reason, they must be documented in
>   the header.  If all that's needed from a header is typedefs, put
>   those into qemu/typedefs.h instead of including the header.
>
>3. Cyclic inclusion is forbidden.

Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?

Best regards,
Bernhard

>After this series, include/hw/pci and include/hw/cxl conform to these
>rules.
>
>It is based on
>
>    [PATCH v2 0/3] block: Clean up includes
>    [PATCH v3 0/5] coroutine: Clean up includes
>
>v2:
>* Rebased
>* PATCH 1: Actually breaks an inclusion loop; commit message rephrased
>  accordingly
>* PATCH 2: New [Jonathan]
>* PATCH 5: tests/qtest/fuzz/generic_fuzz.c fixed [Michael]
>* PATCH 6: Inclusion of cxl_pci.h into cxl_cdat_h kept, commit message
>  adjusted [Jonathan]
>
>[1] Message-ID: <87h9g8j57d.fsf@blackfin.pond.sub.org>
>    https://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg03345.html
>
>Based-on: <20221221133551.3967339-1-armbru@redhat.com>
>
>Markus Armbruster (7):
>  include/hw/pci: Break inclusion loop pci_bridge.h and cxl.h
>  include/hw/cxl: Move typedef PXBDev to cxl.h, and put it to use
>  include/hw/cxl: Include hw/cxl/*.h where needed
>  include/hw/pci: Clean up a few things checkpatch.pl would flag
>  include/hw/pci: Split pci_device.h off pci.h
>  include/hw/pci: Include hw/pci/pci.h where needed
>  include/hw/cxl: Break inclusion loop cxl_pci.h and cxl_cdat_h
>
> hw/alpha/alpha_sys.h                |   1 -
> hw/display/ati_int.h                |   2 +-
> hw/display/qxl.h                    |   3 +-
> hw/ide/ahci_internal.h              |   2 +-
> hw/net/vmxnet3_defs.h               |   2 +-
> hw/nvme/nvme.h                      |   2 +-
> hw/rdma/rdma_utils.h                |   1 -
> hw/rdma/vmw/pvrdma.h                |   2 +-
> hw/scsi/mptsas.h                    |   2 +-
> hw/usb/hcd-ehci.h                   |   3 +-
> hw/usb/hcd-uhci.h                   |   2 +-
> hw/usb/hcd-xhci-pci.h               |   1 +
> hw/vfio/pci.h                       |   2 +-
> hw/xen/xen_pt.h                     |   1 -
> include/hw/acpi/piix4.h             |   2 +-
> include/hw/arm/allwinner-a10.h      |   1 +
> include/hw/cxl/cxl.h                |   5 +-
> include/hw/cxl/cxl_cdat.h           |   1 +
> include/hw/cxl/cxl_component.h      |   1 +
> include/hw/cxl/cxl_device.h         |   2 +
> include/hw/cxl/cxl_pci.h            |   3 -
> include/hw/i386/ich9.h              |   4 -
> include/hw/i386/x86-iommu.h         |   1 -
> include/hw/ide/pci.h                |   2 +-
> include/hw/isa/vt82c686.h           |   1 -
> include/hw/misc/macio/macio.h       |   2 +-
> include/hw/pci-host/designware.h    |   3 -
> include/hw/pci-host/gpex.h          |   2 +-
> include/hw/pci-host/i440fx.h        |   2 +-
> include/hw/pci-host/ls7a.h          |   2 -
> include/hw/pci-host/pnv_phb3.h      |   2 -
> include/hw/pci-host/pnv_phb4.h      |   3 +-
> include/hw/pci-host/q35.h           |   2 +-
> include/hw/pci-host/sabre.h         |   2 +-
> include/hw/pci-host/xilinx-pcie.h   |   1 -
> include/hw/pci/msi.h                |   2 +-
> include/hw/pci/pci.h                | 341 ---------------------------
> include/hw/pci/pci_bridge.h         |   3 +-
> include/hw/pci/pci_device.h         | 350 ++++++++++++++++++++++++++++
> include/hw/pci/pcie.h               |   1 -
> include/hw/pci/pcie_port.h          |   1 +
> include/hw/pci/pcie_sriov.h         |   2 +
> include/hw/pci/shpc.h               |   2 +-
> include/hw/remote/iohub.h           |   2 +-
> include/hw/remote/proxy.h           |   2 +-
> include/hw/sd/sdhci.h               |   2 +-
> include/hw/southbridge/piix.h       |   3 +-
> include/hw/virtio/virtio-scsi.h     |   1 -
> include/hw/xen/xen_common.h         |   2 +-
> hw/acpi/erst.c                      |   2 +-
> hw/alpha/pci.c                      |   1 +
> hw/alpha/typhoon.c                  |   2 +-
> hw/audio/ac97.c                     |   2 +-
> hw/audio/es1370.c                   |   2 +-
> hw/audio/via-ac97.c                 |   2 +-
> hw/char/serial-pci-multi.c          |   2 +-
> hw/char/serial-pci.c                |   2 +-
> hw/core/qdev-properties-system.c    |   1 +
> hw/display/bochs-display.c          |   2 +-
> hw/display/cirrus_vga.c             |   2 +-
> hw/display/sm501.c                  |   2 +-
> hw/display/vga-pci.c                |   2 +-
> hw/display/vmware_vga.c             |   2 +-
> hw/i386/acpi-build.c                |   2 +-
> hw/i386/xen/xen_pvdevice.c          |   2 +-
> hw/ipack/tpci200.c                  |   2 +-
> hw/ipmi/pci_ipmi_bt.c               |   2 +-
> hw/ipmi/pci_ipmi_kcs.c              |   2 +-
> hw/isa/i82378.c                     |   2 +-
> hw/mips/gt64xxx_pci.c               |   2 +-
> hw/misc/pci-testdev.c               |   2 +-
> hw/misc/pvpanic-pci.c               |   2 +-
> hw/net/can/can_kvaser_pci.c         |   2 +-
> hw/net/can/can_mioe3680_pci.c       |   2 +-
> hw/net/can/can_pcm3680_pci.c        |   2 +-
> hw/net/can/ctucan_pci.c             |   2 +-
> hw/net/e1000.c                      |   2 +-
> hw/net/e1000x_common.c              |   2 +-
> hw/net/eepro100.c                   |   2 +-
> hw/net/ne2000-pci.c                 |   2 +-
> hw/net/net_tx_pkt.c                 |   2 +-
> hw/net/pcnet-pci.c                  |   2 +-
> hw/net/rocker/rocker.c              |   2 +-
> hw/net/rocker/rocker_desc.c         |   2 +-
> hw/net/rtl8139.c                    |   2 +-
> hw/net/sungem.c                     |   2 +-
> hw/net/sunhme.c                     |   2 +-
> hw/net/tulip.c                      |   2 +-
> hw/net/virtio-net.c                 |   2 +-
> hw/pci-bridge/i82801b11.c           |   2 +-
> hw/pci-bridge/pci_expander_bridge.c |   1 -
> hw/pci-host/bonito.c                |   2 +-
> hw/pci-host/dino.c                  |   2 +-
> hw/pci-host/grackle.c               |   2 +-
> hw/pci-host/mv64361.c               |   2 +-
> hw/pci-host/ppce500.c               |   2 +-
> hw/pci-host/raven.c                 |   2 +-
> hw/pci-host/sh_pci.c                |   2 +-
> hw/pci-host/uninorth.c              |   2 +-
> hw/pci-host/versatile.c             |   2 +-
> hw/pci/pci-hmp-cmds.c               |   1 +
> hw/pci/pcie_host.c                  |   2 +-
> hw/pci/pcie_sriov.c                 |   2 +-
> hw/pci/slotid_cap.c                 |   2 +-
> hw/ppc/ppc440_pcix.c                |   2 +-
> hw/ppc/ppc4xx_pci.c                 |   2 +-
> hw/ppc/spapr_pci_vfio.c             |   1 +
> hw/rdma/rdma_utils.c                |   1 +
> hw/s390x/s390-pci-inst.c            |   1 +
> hw/scsi/esp-pci.c                   |   2 +-
> hw/scsi/lsi53c895a.c                |   2 +-
> hw/scsi/virtio-scsi.c               |   1 +
> hw/smbios/smbios.c                  |   1 +
> hw/usb/hcd-ohci-pci.c               |   2 +-
> hw/watchdog/wdt_i6300esb.c          |   2 +-
> tests/qtest/fuzz/generic_fuzz.c     |   1 +
> ui/util.c                           |   2 +-
> 117 files changed, 455 insertions(+), 455 deletions(-)
> create mode 100644 include/hw/pci/pci_device.h
>
Re: [PATCH v2 0/7] include/hw/pci include/hw/cxl: Clean up includes
Posted by Markus Armbruster 1 year, 4 months ago
Bernhard Beschow <shentey@gmail.com> writes:

> Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <armbru@redhat.com>:
>>Back in 2016, we discussed[1] rules for headers, and these were
>>generally liked:
>>
>>1. Have a carefully curated header that's included everywhere first.  We
>>   got that already thanks to Peter: osdep.h.
>>
>>2. Headers should normally include everything they need beyond osdep.h.
>>   If exceptions are needed for some reason, they must be documented in
>>   the header.  If all that's needed from a header is typedefs, put
>>   those into qemu/typedefs.h instead of including the header.
>>
>>3. Cyclic inclusion is forbidden.
>
> Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?

Makes sense.  I'll see what I can do.  Thanks!
Re: [PATCH v2 0/7] include/hw/pci include/hw/cxl: Clean up includes
Posted by Michael S. Tsirkin 1 year, 4 months ago
On Thu, Dec 22, 2022 at 11:48:25AM +0100, Markus Armbruster wrote:
> Bernhard Beschow <shentey@gmail.com> writes:
> 
> > Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <armbru@redhat.com>:
> >>Back in 2016, we discussed[1] rules for headers, and these were
> >>generally liked:
> >>
> >>1. Have a carefully curated header that's included everywhere first.  We
> >>   got that already thanks to Peter: osdep.h.
> >>
> >>2. Headers should normally include everything they need beyond osdep.h.
> >>   If exceptions are needed for some reason, they must be documented in
> >>   the header.  If all that's needed from a header is typedefs, put
> >>   those into qemu/typedefs.h instead of including the header.
> >>
> >>3. Cyclic inclusion is forbidden.
> >
> > Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?
> 
> Makes sense.  I'll see what I can do.  Thanks!

It would be even better if there was e.g. a make target
pulling in each header and making sure it's self consistent and
no circularity. We could run it e.g. in CI.

-- 
MST
Re: [PATCH v2 0/7] include/hw/pci include/hw/cxl: Clean up includes
Posted by Markus Armbruster 1 year, 4 months ago
"Michael S. Tsirkin" <mst@redhat.com> writes:

> On Thu, Dec 22, 2022 at 11:48:25AM +0100, Markus Armbruster wrote:
>> Bernhard Beschow <shentey@gmail.com> writes:
>> 
>> > Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <armbru@redhat.com>:
>> >>Back in 2016, we discussed[1] rules for headers, and these were
>> >>generally liked:
>> >>
>> >>1. Have a carefully curated header that's included everywhere first.  We
>> >>   got that already thanks to Peter: osdep.h.
>> >>
>> >>2. Headers should normally include everything they need beyond osdep.h.
>> >>   If exceptions are needed for some reason, they must be documented in
>> >>   the header.  If all that's needed from a header is typedefs, put
>> >>   those into qemu/typedefs.h instead of including the header.
>> >>
>> >>3. Cyclic inclusion is forbidden.
>> >
>> > Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?
>> 
>> Makes sense.  I'll see what I can do.  Thanks!
>
> It would be even better if there was e.g. a make target
> pulling in each header and making sure it's self consistent and
> no circularity. We could run it e.g. in CI.

Yes, that would be nice, but the problem I've been unable to crack is
deciding whether a header is supposed to compile target-independently or
not.  In my manual testing, I use trial and error: if it fails to
compile target-independently, compile for all targets.  This is s-l-o-w.

The other problem, of course, is coding it up in Meson.  I haven't even
tried.
Re: [PATCH v2 0/7] include/hw/pci include/hw/cxl: Clean up includes
Posted by Michael S. Tsirkin 1 year, 4 months ago
On Fri, Dec 23, 2022 at 06:27:07AM +0100, Markus Armbruster wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
> 
> > On Thu, Dec 22, 2022 at 11:48:25AM +0100, Markus Armbruster wrote:
> >> Bernhard Beschow <shentey@gmail.com> writes:
> >> 
> >> > Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <armbru@redhat.com>:
> >> >>Back in 2016, we discussed[1] rules for headers, and these were
> >> >>generally liked:
> >> >>
> >> >>1. Have a carefully curated header that's included everywhere first.  We
> >> >>   got that already thanks to Peter: osdep.h.
> >> >>
> >> >>2. Headers should normally include everything they need beyond osdep.h.
> >> >>   If exceptions are needed for some reason, they must be documented in
> >> >>   the header.  If all that's needed from a header is typedefs, put
> >> >>   those into qemu/typedefs.h instead of including the header.
> >> >>
> >> >>3. Cyclic inclusion is forbidden.
> >> >
> >> > Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?
> >> 
> >> Makes sense.  I'll see what I can do.  Thanks!
> >
> > It would be even better if there was e.g. a make target
> > pulling in each header and making sure it's self consistent and
> > no circularity. We could run it e.g. in CI.
> 
> Yes, that would be nice, but the problem I've been unable to crack is
> deciding whether a header is supposed to compile target-independently or
> not.  In my manual testing, I use trial and error: if it fails to
> compile target-independently, compile for all targets.  This is s-l-o-w.

Yes and it's annoying for developers too.
Do we want to come up with a scheme for target-dependent files?
Name them target-X or put in a target/ directory?
We could also write checkpatch rules to disallow
including target specific headers in target independent files then.

> The other problem, of course, is coding it up in Meson.  I haven't even
> tried.
Re: [PATCH v2 0/7] include/hw/pci include/hw/cxl: Clean up includes
Posted by Markus Armbruster 1 year, 2 months ago
"Michael S. Tsirkin" <mst@redhat.com> writes:

> On Fri, Dec 23, 2022 at 06:27:07AM +0100, Markus Armbruster wrote:
>> "Michael S. Tsirkin" <mst@redhat.com> writes:
>> 
>> > On Thu, Dec 22, 2022 at 11:48:25AM +0100, Markus Armbruster wrote:
>> >> Bernhard Beschow <shentey@gmail.com> writes:
>> >> 
>> >> > Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <armbru@redhat.com>:
>> >> >>Back in 2016, we discussed[1] rules for headers, and these were
>> >> >>generally liked:
>> >> >>
>> >> >>1. Have a carefully curated header that's included everywhere first.  We
>> >> >>   got that already thanks to Peter: osdep.h.
>> >> >>
>> >> >>2. Headers should normally include everything they need beyond osdep.h.
>> >> >>   If exceptions are needed for some reason, they must be documented in
>> >> >>   the header.  If all that's needed from a header is typedefs, put
>> >> >>   those into qemu/typedefs.h instead of including the header.
>> >> >>
>> >> >>3. Cyclic inclusion is forbidden.
>> >> >
>> >> > Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?
>> >> 
>> >> Makes sense.  I'll see what I can do.  Thanks!

Commit f07ceffdf50.

>> > It would be even better if there was e.g. a make target
>> > pulling in each header and making sure it's self consistent and
>> > no circularity. We could run it e.g. in CI.
>> 
>> Yes, that would be nice, but the problem I've been unable to crack is
>> deciding whether a header is supposed to compile target-independently or
>> not.  In my manual testing, I use trial and error: if it fails to
>> compile target-independently, compile for all targets.  This is s-l-o-w.

To spice things up, we also have headers that provide additional
contents in target-dependent context.  These need to be tested in both
contexts.

> Yes and it's annoying for developers too.
> Do we want to come up with a scheme for target-dependent files?
> Name them target-X or put in a target/ directory?

I'd be in favour.  Sadly, I'm not able to push such an effort myself.

> We could also write checkpatch rules to disallow
> including target specific headers in target independent files then.

Fortunately, that's pretty unlikely to compile :)

>> The other problem, of course, is coding it up in Meson.  I haven't even
>> tried.
Re: [PATCH v2 0/7] include/hw/pci include/hw/cxl: Clean up includes
Posted by Philippe Mathieu-Daudé 1 year, 2 months ago
On 15/2/23 14:28, Markus Armbruster wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
> 
>> On Fri, Dec 23, 2022 at 06:27:07AM +0100, Markus Armbruster wrote:
>>> "Michael S. Tsirkin" <mst@redhat.com> writes:
>>>
>>>> On Thu, Dec 22, 2022 at 11:48:25AM +0100, Markus Armbruster wrote:
>>>>> Bernhard Beschow <shentey@gmail.com> writes:
>>>>>
>>>>>> Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <armbru@redhat.com>:
>>>>>>> Back in 2016, we discussed[1] rules for headers, and these were
>>>>>>> generally liked:
>>>>>>>
>>>>>>> 1. Have a carefully curated header that's included everywhere first.  We
>>>>>>>    got that already thanks to Peter: osdep.h.
>>>>>>>
>>>>>>> 2. Headers should normally include everything they need beyond osdep.h.
>>>>>>>    If exceptions are needed for some reason, they must be documented in
>>>>>>>    the header.  If all that's needed from a header is typedefs, put
>>>>>>>    those into qemu/typedefs.h instead of including the header.
>>>>>>>
>>>>>>> 3. Cyclic inclusion is forbidden.
>>>>>>
>>>>>> Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?
>>>>>
>>>>> Makes sense.  I'll see what I can do.  Thanks!
> 
> Commit f07ceffdf50.
> 
>>>> It would be even better if there was e.g. a make target
>>>> pulling in each header and making sure it's self consistent and
>>>> no circularity. We could run it e.g. in CI.
>>>
>>> Yes, that would be nice, but the problem I've been unable to crack is
>>> deciding whether a header is supposed to compile target-independently or
>>> not.  In my manual testing, I use trial and error: if it fails to
>>> compile target-independently, compile for all targets.  This is s-l-o-w.
> 
> To spice things up, we also have headers that provide additional
> contents in target-dependent context.  These need to be tested in both
> contexts.

Do we need to figure a way to get rid of this problem
in order to build a single qemu-system binary?

>> Yes and it's annoying for developers too.
>> Do we want to come up with a scheme for target-dependent files?
>> Name them target-X or put in a target/ directory?
> 
> I'd be in favour.  Sadly, I'm not able to push such an effort myself.
> 
>> We could also write checkpatch rules to disallow
>> including target specific headers in target independent files then.
> 
> Fortunately, that's pretty unlikely to compile :)
> 
>>> The other problem, of course, is coding it up in Meson.  I haven't even
>>> tried.
Re: [PATCH v2 0/7] include/hw/pci include/hw/cxl: Clean up includes
Posted by Markus Armbruster 1 year, 2 months ago
Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> On 15/2/23 14:28, Markus Armbruster wrote:
>> "Michael S. Tsirkin" <mst@redhat.com> writes:
>> 
>>> On Fri, Dec 23, 2022 at 06:27:07AM +0100, Markus Armbruster wrote:
>>>> "Michael S. Tsirkin" <mst@redhat.com> writes:

[...]

>>>>> It would be even better if there was e.g. a make target
>>>>> pulling in each header and making sure it's self consistent and
>>>>> no circularity. We could run it e.g. in CI.
>>>>
>>>> Yes, that would be nice, but the problem I've been unable to crack is
>>>> deciding whether a header is supposed to compile target-independently or
>>>> not.  In my manual testing, I use trial and error: if it fails to
>>>> compile target-independently, compile for all targets.  This is s-l-o-w.
>>
>> To spice things up, we also have headers that provide additional
>> contents in target-dependent context.  These need to be tested in both
>> contexts.
>
> Do we need to figure a way to get rid of this problem
> in order to build a single qemu-system binary?

I don't know.
Re: [PATCH v2 0/7] include/hw/pci include/hw/cxl: Clean up includes
Posted by Bernhard Beschow 1 year, 4 months ago

Am 23. Dezember 2022 05:27:07 UTC schrieb Markus Armbruster <armbru@redhat.com>:
>"Michael S. Tsirkin" <mst@redhat.com> writes:
>
>> On Thu, Dec 22, 2022 at 11:48:25AM +0100, Markus Armbruster wrote:
>>> Bernhard Beschow <shentey@gmail.com> writes:
>>> 
>>> > Am 22. Dezember 2022 10:03:23 UTC schrieb Markus Armbruster <armbru@redhat.com>:
>>> >>Back in 2016, we discussed[1] rules for headers, and these were
>>> >>generally liked:
>>> >>
>>> >>1. Have a carefully curated header that's included everywhere first.  We
>>> >>   got that already thanks to Peter: osdep.h.
>>> >>
>>> >>2. Headers should normally include everything they need beyond osdep.h.
>>> >>   If exceptions are needed for some reason, they must be documented in
>>> >>   the header.  If all that's needed from a header is typedefs, put
>>> >>   those into qemu/typedefs.h instead of including the header.
>>> >>
>>> >>3. Cyclic inclusion is forbidden.
>>> >
>>> > Sounds like these -- useful and sane -- rules belong in QEMU's coding style. What about putting them there for easy reference?
>>> 
>>> Makes sense.  I'll see what I can do.  Thanks!
>>
>> It would be even better if there was e.g. a make target
>> pulling in each header and making sure it's self consistent and
>> no circularity. We could run it e.g. in CI.
>
>Yes, that would be nice, but the problem I've been unable to crack is
>deciding whether a header is supposed to compile target-independently or
>not.  In my manual testing, I use trial and error: if it fails to
>compile target-independently, compile for all targets.  This is s-l-o-w.
>
>The other problem, of course, is coding it up in Meson.  I haven't even
>tried.

There is https://include-what-you-use.org which is a Clang-based tool. Maybe that works?

Best regards,
Bernhard