Skip to content
Snippets Groups Projects
  1. Jun 20, 2023
  2. Jan 08, 2023
    • Markus Armbruster's avatar
      include/hw/pci: Split pci_device.h off pci.h · edf5ca5d
      Markus Armbruster authored
      
      PCIDeviceClass and PCIDevice are defined in pci.h.  Many users of the
      header don't actually need them.  Similar structs live in their own
      headers: PCIBusClass and PCIBus in pci_bus.h, PCIBridge in
      pci_bridge.h, PCIHostBridgeClass and PCIHostState in pci_host.h,
      PCIExpressHost in pcie_host.h, and PCIERootPortClass, PCIEPort, and
      PCIESlot in pcie_port.h.
      
      Move PCIDeviceClass and PCIDeviceClass to new pci_device.h, along with
      the code that needs them.  Adjust include directives.
      
      This also enables the next commit.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20221222100330.380143-6-armbru@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      edf5ca5d
  3. Sep 30, 2021
  4. Sep 18, 2020
  5. Sep 09, 2020
  6. Aug 21, 2020
  7. May 15, 2020
    • Markus Armbruster's avatar
      qdev: Unrealize must not fail · b69c3c21
      Markus Armbruster authored
      
      Devices may have component devices and buses.
      
      Device realization may fail.  Realization is recursive: a device's
      realize() method realizes its components, and device_set_realized()
      realizes its buses (which should in turn realize the devices on that
      bus, except bus_set_realized() doesn't implement that, yet).
      
      When realization of a component or bus fails, we need to roll back:
      unrealize everything we realized so far.  If any of these unrealizes
      failed, the device would be left in an inconsistent state.  Must not
      happen.
      
      device_set_realized() lets it happen: it ignores errors in the roll
      back code starting at label child_realize_fail.
      
      Since realization is recursive, unrealization must be recursive, too.
      But how could a partly failed unrealize be rolled back?  We'd have to
      re-realize, which can fail.  This design is fundamentally broken.
      
      device_set_realized() does not roll back at all.  Instead, it keeps
      unrealizing, ignoring further errors.
      
      It can screw up even for a device with no buses: if the lone
      dc->unrealize() fails, it still unregisters vmstate, and calls
      listeners' unrealize() callback.
      
      bus_set_realized() does not roll back either.  Instead, it stops
      unrealizing.
      
      Fortunately, no unrealize method can fail, as we'll see below.
      
      To fix the design error, drop parameter @errp from all the unrealize
      methods.
      
      Any unrealize method that uses @errp now needs an update.  This leads
      us to unrealize() methods that can fail.  Merely passing it to another
      unrealize method cannot cause failure, though.  Here are the ones that
      do other things with @errp:
      
      * virtio_serial_device_unrealize()
      
        Fails when qbus_set_hotplug_handler() fails, but still does all the
        other work.  On failure, the device would stay realized with its
        resources completely gone.  Oops.  Can't happen, because
        qbus_set_hotplug_handler() can't actually fail here.  Pass
        &error_abort to qbus_set_hotplug_handler() instead.
      
      * hw/ppc/spapr_drc.c's unrealize()
      
        Fails when object_property_del() fails, but all the other work is
        already done.  On failure, the device would stay realized with its
        vmstate registration gone.  Oops.  Can't happen, because
        object_property_del() can't actually fail here.  Pass &error_abort
        to object_property_del() instead.
      
      * spapr_phb_unrealize()
      
        Fails and bails out when remove_drcs() fails, but other work is
        already done.  On failure, the device would stay realized with some
        of its resources gone.  Oops.  remove_drcs() fails only when
        chassis_from_bus()'s object_property_get_uint() fails, and it can't
        here.  Pass &error_abort to remove_drcs() instead.
      
      Therefore, no unrealize method can fail before this patch.
      
      device_set_realized()'s recursive unrealization via bus uses
      object_property_set_bool().  Can't drop @errp there, so pass
      &error_abort.
      
      We similarly unrealize with object_property_set_bool() elsewhere,
      always ignoring errors.  Pass &error_abort instead.
      
      Several unrealize methods no longer handle errors from other unrealize
      methods: virtio_9p_device_unrealize(),
      virtio_input_device_unrealize(), scsi_qdev_unrealize(), ...
      Much of the deleted error handling looks wrong anyway.
      
      One unrealize methods no longer ignore such errors:
      usb_ehci_pci_exit().
      
      Several realize methods no longer ignore errors when rolling back:
      v9fs_device_realize_common(), pci_qdev_unrealize(),
      spapr_phb_realize(), usb_qdev_realize(), vfio_ccw_realize(),
      virtio_device_realize().
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20200505152926.18877-17-armbru@redhat.com>
      b69c3c21
  8. Jan 24, 2020
  9. Aug 16, 2019
    • Markus Armbruster's avatar
      Include hw/qdev-properties.h less · a27bd6c7
      Markus Armbruster authored
      
      In my "build everything" tree, changing hw/qdev-properties.h triggers
      a recompile of some 2700 out of 6600 objects (not counting tests and
      objects that don't depend on qemu/osdep.h).
      
      Many places including hw/qdev-properties.h (directly or via hw/qdev.h)
      actually need only hw/qdev-core.h.  Include hw/qdev-core.h there
      instead.
      
      hw/qdev.h is actually pointless: all it does is include hw/qdev-core.h
      and hw/qdev-properties.h, which in turn includes hw/qdev-core.h.
      Replace the remaining uses of hw/qdev.h by hw/qdev-properties.h.
      
      While there, delete a few superfluous inclusions of hw/qdev-core.h.
      
      Touching hw/qdev-properties.h now recompiles some 1200 objects.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: "Daniel P. Berrangé" <berrange@redhat.com>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <20190812052359.30071-22-armbru@redhat.com>
      a27bd6c7
    • Markus Armbruster's avatar
      Include migration/vmstate.h less · d6454270
      Markus Armbruster authored
      
      In my "build everything" tree, changing migration/vmstate.h triggers a
      recompile of some 2700 out of 6600 objects (not counting tests and
      objects that don't depend on qemu/osdep.h).
      
      hw/hw.h supposedly includes it for convenience.  Several other headers
      include it just to get VMStateDescription.  The previous commit made
      that unnecessary.
      
      Include migration/vmstate.h only where it's still needed.  Touching it
      now recompiles only some 1600 objects.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Message-Id: <20190812052359.30071-16-armbru@redhat.com>
      Tested-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      d6454270
    • Markus Armbruster's avatar
      Include hw/irq.h a lot less · 64552b6b
      Markus Armbruster authored
      
      In my "build everything" tree, changing hw/irq.h triggers a recompile
      of some 5400 out of 6600 objects (not counting tests and objects that
      don't depend on qemu/osdep.h).
      
      hw/hw.h supposedly includes it for convenience.  Several other headers
      include it just to get qemu_irq and.or qemu_irq_handler.
      
      Move the qemu_irq and qemu_irq_handler typedefs from hw/irq.h to
      qemu/typedefs.h, and then include hw/irq.h only where it's still
      needed.  Touching it now recompiles only some 500 objects.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Tested-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-Id: <20190812052359.30071-13-armbru@redhat.com>
      64552b6b
  10. Jun 12, 2019
  11. Mar 07, 2019
    • Paolo Bonzini's avatar
      build: convert pci.mak to Kconfig · 7c28b925
      Paolo Bonzini authored
      
      Instead of including the same list of devices for each target,
      set CONFIG_PCI to true, and make the devices default to present
      whenever PCI is available.  However, s390x does not want all the
      PCI devices, so there is a separate symbol to enable them.
      
      Done mostly with the following script:
      
        while read i; do
           i=${i%=y}; i=${i#CONFIG_}
           sed -i -e'/^config '$i'$/!b' -en \
                  -e'a\' -e'    default y if PCI_DEVICES\' -e'    depends on PCI' \
                `grep -lw $i hw/*/Kconfig`
        done < default-configs/pci.mak
      
      followed by replacing a few "depends on" clauses with "select"
      whenever the symbol is not really related to PCI.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarYang Zhong <yang.zhong@intel.com>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
      Message-Id: <20190123065618.3520-31-yang.zhong@intel.com>
      Acked-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      7c28b925
    • Paolo Bonzini's avatar
      kconfig: introduce kconfig files · 82f51817
      Paolo Bonzini authored
      
      The Kconfig files were generated mostly with this script:
      
        for i in `grep -ho CONFIG_[A-Z0-9_]* default-configs/* | sort -u`; do
          set fnord `git grep -lw $i -- 'hw/*/Makefile.objs' `
          shift
          if test $# = 1; then
            cat >> $(dirname $1)/Kconfig << EOF
      config ${i#CONFIG_}
          bool
      
      EOF
            git add $(dirname $1)/Kconfig
          else
            echo $i $*
          fi
        done
        sed -i '$d' hw/*/Kconfig
        for i in hw/*; do
          if test -d $i && ! test -f $i/Kconfig; then
            touch $i/Kconfig
            git add $i/Kconfig
          fi
        done
      
      Whenever a symbol is referenced from multiple subdirectories, the
      script prints the list of directories that reference the symbol.
      These symbols have to be added manually to the Kconfig files.
      
      Kconfig.host and hw/Kconfig were created manually.
      
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarYang Zhong <yang.zhong@intel.com>
      Message-Id: <20190123065618.3520-27-yang.zhong@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      82f51817
  12. Jul 02, 2018
  13. Oct 15, 2017
  14. May 18, 2016
  15. Mar 22, 2016
    • Markus Armbruster's avatar
      include/qemu/osdep.h: Don't include qapi/error.h · da34e65c
      Markus Armbruster authored
      
      Commit 57cb38b3 included qapi/error.h into qemu/osdep.h to get the
      Error typedef.  Since then, we've moved to include qemu/osdep.h
      everywhere.  Its file comment explains: "To avoid getting into
      possible circular include dependencies, this file should not include
      any other QEMU headers, with the exceptions of config-host.h,
      compiler.h, os-posix.h and os-win32.h, all of which are doing a
      similar job to this file and are under similar constraints."
      qapi/error.h doesn't do a similar job, and it doesn't adhere to
      similar constraints: it includes qapi-types.h.  That's in excess of
      100KiB of crap most .c files don't actually need.
      
      Add the typedef to qemu/typedefs.h, and include that instead of
      qapi/error.h.  Include qapi/error.h in .c files that need it and don't
      get it now.  Include qapi-types.h in qom/object.h for uint16List.
      
      Update scripts/clean-includes accordingly.  Update it further to match
      reality: replace config.h by config-target.h, add sysemu/os-posix.h,
      sysemu/os-win32.h.  Update the list of includes in the qemu/osdep.h
      comment quoted above similarly.
      
      This reduces the number of objects depending on qapi/error.h from "all
      of them" to less than a third.  Unfortunately, the number depending on
      qapi-types.h shrinks only a little.  More work is needed for that one.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      [Fix compilation without the spice devel packages. - Paolo]
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      da34e65c
  16. Jan 29, 2016
    • Peter Maydell's avatar
      hw: Clean up includes · 0430891c
      Peter Maydell authored
      
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1453832250-766-38-git-send-email-peter.maydell@linaro.org
      0430891c
  17. Feb 26, 2015
  18. Aug 18, 2014
  19. Jul 01, 2014
  20. May 14, 2014
  21. Feb 14, 2014
Loading