1. 06 3月, 2019 3 次提交
    • D
      qdev: Provide qdev_get_bus_hotplug_handler() · 14405c27
      David Hildenbrand 提交于
      Let's use a wrapper instead of looking it up manually. This function can
      than be reused when we explicitly want to have the bus hotplug handler
      (e.g. when the bus hotplug handler was overwritten by the machine
      hotplug handler).
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20190228122849.4296-4-david@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      14405c27
    • I
      qdev: Let machine hotplug handler to override bus hotplug handler · 17cc0128
      Igor Mammedov 提交于
      it will allow to return another hotplug handler than the default
      one for a specific bus based device type. Which is needed to handle
      non trivial plug/unplug sequences that need the access to resources
      configured outside of bus where device is attached.
      
      That will allow for returned hotplug handler to orchestrate wiring
      in arbitrary order, by chaining other hotplug handlers when
      it's needed.
      
      PS:
      It could be used for hybrid virtio-mem and virtio-pmem devices
      where it will return machine as hotplug handler which will do
      necessary wiring at machine level and then pass control down
      the chain to bus specific hotplug handler.
      
      Example of top level hotplug handler override and custom plug sequence:
      
        some_machine_get_hotplug_handler(machine){
            if (object_dynamic_cast(OBJECT(dev), TYPE_SOME_BUS_DEVICE)) {
                return HOTPLUG_HANDLER(machine);
            }
            return NULL;
        }
      
        some_machine_device_plug(hotplug_dev, dev) {
            if (object_dynamic_cast(OBJECT(dev), TYPE_SOME_BUS_DEVICE)) {
                /* do machine specific initialization */
                some_machine_init_special_device(dev)
      
                /* pass control to bus specific handler */
                hotplug_handler_plug(dev->parent_bus->hotplug_handler, dev)
            }
        }
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20190228122849.4296-3-david@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      17cc0128
    • T
      qdev/core: fix qbus_is_full() · 12b2e9f3
      Tony Krowiak 提交于
      The qbus_is_full(BusState *bus) function (qdev_monitor.c) compares the max_index
      value of the BusState structure with the max_dev value of the BusClass structure
      to determine whether the maximum number of children has been reached for the
      bus. The problem is, the max_index field of the BusState structure does not
      necessarily reflect the number of devices that have been plugged into
      the bus.
      
      Whenever a child device is plugged into the bus, the bus's max_index value is
      assigned to the child device and then incremented. If the child is subsequently
      unplugged, the value of the max_index does not change and no longer reflects the
      number of children.
      
      When the bus's max_index value reaches the maximum number of devices
      allowed for the bus (i.e., the max_dev field in the BusClass structure),
      attempts to plug another device will be rejected claiming that the bus is
      full -- even if the bus is actually empty.
      
      To resolve the problem, a new 'num_children' field is being added to the
      BusState structure to keep track of the number of children plugged into the
      bus. It will be incremented when a child is plugged, and decremented when a
      child is unplugged.
      Signed-off-by: NTony Krowiak <akrowiak@linux.ibm.com>
      Reviewed-by: Pierre Morel<pmorel@linux.ibm.com>
      Reviewed-by: NHalil Pasic <pasic@linux.ibm.com>
      Message-Id: <1545062250-7573-1-git-send-email-akrowiak@linux.ibm.com>
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      12b2e9f3
  2. 17 2月, 2019 1 次提交
  3. 18 1月, 2019 1 次提交
  4. 11 1月, 2019 1 次提交
  5. 07 1月, 2019 4 次提交
  6. 12 12月, 2018 1 次提交
  7. 25 9月, 2018 1 次提交
  8. 01 6月, 2018 1 次提交
  9. 02 3月, 2018 1 次提交
  10. 09 2月, 2018 1 次提交
  11. 05 2月, 2018 2 次提交
  12. 19 1月, 2018 1 次提交
    • T
      qdev: Check for the availability of a hotplug controller before adding a device · 03fcbd9d
      Thomas Huth 提交于
      The qdev_unplug() function contains a g_assert(hotplug_ctrl) statement,
      so QEMU crashes when the user tries to device_add + device_del a device
      that does not have a corresponding hotplug controller. This could be
      provoked for a couple of devices in the past (see commit 4c939506
      or 84ebd3e8 for example), and can currently for example also be
      triggered like this:
      
      $ s390x-softmmu/qemu-system-s390x -M none -nographic
      QEMU 2.10.50 monitor - type 'help' for more information
      (qemu) device_add qemu-s390x-cpu,id=x
      (qemu) device_del x
      **
      ERROR:qemu/qdev-monitor.c:872:qdev_unplug: assertion failed: (hotplug_ctrl)
      Aborted (core dumped)
      
      So devices clearly need a hotplug controller when they should be usable
      with device_add.
      The code in qdev_device_add() already checks whether the bus has a proper
      hotplug controller, but for devices that do not have a corresponding bus,
      there is no appropriate check available yet. In that case we should check
      whether the machine itself provides a suitable hotplug controller and
      refuse to plug the device if none is available.
      Reviewed-by: NIgor Mammedov <imammedo@redhat.com>
      Signed-off-by: NThomas Huth <thuth@redhat.com>
      Message-Id: <1509617407-21191-3-git-send-email-thuth@redhat.com>
      Reviewed-by: NCornelia Huck <cohuck@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      03fcbd9d
  13. 18 10月, 2017 1 次提交
    • M
      qdev: store DeviceState's canonical path to use when unparenting · 04162f8f
      Michael Roth 提交于
      device_unparent(dev, ...) is called when a device is unparented,
      either directly, or as a result of a parent device being
      finalized, and handles some final cleanup for the device. Part
      of this includes emiting a DEVICE_DELETED QMP event to notify
      management, which includes the device's path in the composition
      tree as provided by object_get_canonical_path().
      
      object_get_canonical_path() assumes the device is still connected
      to the machine/root container, and will assert otherwise, but
      in some situations this isn't the case:
      
      If the parent is finalized as a result of object_unparent(), it
      will still be attached to the composition tree at the time any
      children are unparented as a result of that same call to
      object_unparent(). However, in some cases, object_unparent()
      will complete without finalizing the parent device, due to
      lingering references that won't be released till some time later.
      One such example is if the parent has MemoryRegion children (which
      take a ref on their parent), who in turn have AddressSpace's (which
      take a ref on their regions), since those AddressSpaces get cleaned
      up asynchronously by the RCU thread.
      
      In this case qdev:device_unparent() may be called for a child Device
      that no longer has a path to the root/machine container, causing
      object_get_canonical_path() to assert.
      
      Fix this by storing the canonical path during realize() so the
      information will still be available for device_unparent() in such
      cases.
      
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Tested-by: NEric Auger <eric.auger@redhat.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Message-Id: <20171016222315.407-2-mdroth@linux.vnet.ibm.com>
      [Clear dev->canonical_path at the post_realize_fail label, which is
       cleaner.  Suggested by David Gibson. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      04162f8f
  14. 04 9月, 2017 1 次提交
  15. 17 7月, 2017 1 次提交
    • P
      qdev: support properties which don't set a default value · 5cc56cc6
      Peter Maydell 提交于
      In some situations it's useful to have a qdev property which doesn't
      automatically set its default value when qdev_property_add_static is
      called (for instance when the default value is not constant).
      
      Support this by adding a flag to the Property struct indicating
      whether to set the default value.  This replaces the existing test
      for whether the PropertyInfo set_default_value function pointer is
      NULL, and we set the .set_default field to true for all those cases
      of struct Property which use a PropertyInfo with a non-NULL
      set_default_value, so behaviour remains the same as before.
      
      This gives us the semantics of:
       * if .set_default is true, then .info->set_default_value must
         be not NULL, and .defval is used as the the default value of
         the property
       * otherwise, the property system does not set any default, and
         the field will retain whatever initial value it was given by
         the device's .instance_init method
      
      We define two new macros DEFINE_PROP_SIGNED_NODEFAULT and
      DEFINE_PROP_UNSIGNED_NODEFAULT, to cover the most plausible use cases
      of wanting to set an integer property with no default value.
      Suggested-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Message-id: 1499788408-10096-3-git-send-email-peter.maydell@linaro.org
      5cc56cc6
  16. 14 7月, 2017 3 次提交
  17. 20 6月, 2017 2 次提交
  18. 19 6月, 2017 1 次提交
  19. 17 5月, 2017 1 次提交
    • E
      qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable · e90f2a8c
      Eduardo Habkost 提交于
      cannot_instantiate_with_device_add_yet was introduced by commit
      efec3dd6 to replace no_user. It was
      supposed to be a temporary measure.
      
      When it was introduced, we had 54
      cannot_instantiate_with_device_add_yet=true lines in the code.
      Today (3 years later) this number has not shrunk: we now have
      57 cannot_instantiate_with_device_add_yet=true lines. I think it
      is safe to say it is not a temporary measure, and we won't see
      the flag go away soon.
      
      Instead of a long field name that misleads people to believe it
      is temporary, replace it a shorter and less misleading field:
      user_creatable.
      
      Except for code comments, changes were generated using the
      following Coccinelle patch:
      
        @@
        expression DC;
        @@
        (
        -DC->cannot_instantiate_with_device_add_yet = false;
        +DC->user_creatable = true;
        |
        -DC->cannot_instantiate_with_device_add_yet = true;
        +DC->user_creatable = false;
        )
      
        @@
        typedef ObjectClass;
        expression dc;
        identifier class, data;
        @@
         static void device_class_init(ObjectClass *class, void *data)
         {
         ...
         dc->hotpluggable = true;
        +dc->user_creatable = true;
         ...
         }
      
        @@
        @@
         struct DeviceClass {
         ...
        -bool cannot_instantiate_with_device_add_yet;
        +bool user_creatable;
         ...
        }
      
        @@
        expression DC;
        @@
        (
        -!DC->cannot_instantiate_with_device_add_yet
        +DC->user_creatable
        |
        -DC->cannot_instantiate_with_device_add_yet
        +!DC->user_creatable
        )
      
      Cc: Alistair Francis <alistair.francis@xilinx.com>
      Cc: Laszlo Ersek <lersek@redhat.com>
      Cc: Marcel Apfelbaum <marcel@redhat.com>
      Cc: Markus Armbruster <armbru@redhat.com>
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Thomas Huth <thuth@redhat.com>
      Acked-by: NAlistair Francis <alistair.francis@xilinx.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel@redhat.com>
      Acked-by: NMarcel Apfelbaum <marcel@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <20170503203604.31462-2-ehabkost@redhat.com>
      [ehabkost: kept "TODO remove once we're there" comment]
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      e90f2a8c
  20. 21 4月, 2017 3 次提交
  21. 28 1月, 2017 1 次提交
  22. 08 9月, 2016 1 次提交
  23. 27 7月, 2016 1 次提交
  24. 08 7月, 2016 1 次提交
  25. 17 6月, 2016 1 次提交
    • E
      qdev: Use GList for global properties · f9a8b553
      Eduardo Habkost 提交于
      If the same GlobalProperty struct is registered twice, the list
      entry gets corrupted, making tqe_next points to itself, and
      qdev_prop_set_globals() gets stuck in a loop. The bug can be
      easily reproduced by running:
      
        $ qemu-system-x86_64 -rtc-td-hack -rtc-td-hack
      
      Change global_props to use GList instead of queue.h, making the
      code simpler and able to deal with properties being registered
      twice.
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      f9a8b553
  26. 23 3月, 2016 1 次提交
  27. 23 2月, 2016 1 次提交
    • P
      include: Clean up includes · 90ce6e26
      Peter Maydell 提交于
      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.
      
      NB: If this commit breaks compilation for your out-of-tree
      patchseries or fork, then you need to make sure you add
      #include "qemu/osdep.h" to any new .c files that you have.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      90ce6e26
  28. 17 12月, 2015 1 次提交
    • E
      qobject: Rename qtype_code to QType · 1310a3d3
      Eric Blake 提交于
      The name QType matches our CODING_STYLE conventions for type names
      in CamelCase.  It also matches the fact that we are already naming
      all the enum members with a prefix of QTYPE, not QTYPE_CODE.  And
      doing the rename will also make it easier for the next patch to use
      QAPI for providing the enum, which also wants CamelCase type names.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Message-Id: <1449033659-25497-3-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      1310a3d3
  29. 19 11月, 2015 1 次提交