1. 16 7月, 2018 1 次提交
  2. 12 6月, 2018 1 次提交
    • M
      object: fix OBJ_PROP_LINK_UNREF_ON_RELEASE ambivalence · 265b578c
      Marc-André Lureau 提交于
      A link property can be set during creation, with
      object_property_add_link() and later with object_property_set_link().
      
      add_link() doesn't add a reference to the target object, while
      set_link() does.
      
      Furthemore, OBJ_PROP_LINK_UNREF_ON_RELEASE flags, set during add_link,
      says whether a reference must be released when the property is destroyed.
      This can lead to leaks if the property was later set_link(), as the
      added reference is never released.
      
      Instead, rename OBJ_PROP_LINK_UNREF_ON_RELEASE to OBJ_PROP_LINK_STRONG
      and use that has an indication on how the link handle reference
      management in set_link().
      Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-id: 20180531195119.22021-3-marcandre.lureau@redhat.com
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      265b578c
  3. 01 6月, 2018 1 次提交
  4. 03 3月, 2018 1 次提交
    • M
      qapi: Empty out qapi-schema.json · 112ed241
      Markus Armbruster 提交于
      The previous commit improved compile time by including less of the
      generated QAPI headers.  This is impossible for stuff defined directly
      in qapi-schema.json, because that ends up in headers that that pull in
      everything.
      
      Move everything but include directives from qapi-schema.json to new
      sub-module qapi/misc.json, then include just the "misc" shard where
      possible.
      
      It's possible everywhere, except:
      
      * monitor.c needs qmp-command.h to get qmp_init_marshal()
      
      * monitor.c, ui/vnc.c and the generated qapi-event-FOO.c need
        qapi-event.h to get enum QAPIEvent
      
      Perhaps we'll get rid of those some other day.
      
      Adding a type to qapi/migration.json now recompiles some 120 instead
      of 2300 out of 5100 objects.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20180211093607.27351-25-armbru@redhat.com>
      [eblake: rebase to master]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      112ed241
  5. 02 3月, 2018 1 次提交
  6. 09 2月, 2018 3 次提交
  7. 05 2月, 2018 1 次提交
  8. 23 1月, 2018 1 次提交
  9. 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
  10. 18 10月, 2017 3 次提交
    • M
      qdev: defer DEVICE_DEL event until instance_finalize() · f7b879e0
      Michael Roth 提交于
      DEVICE_DEL is currently emitted when a Device is unparented, as
      opposed to when it is finalized. The main design motivation for this
      seems to be that after unparent()/unrealize(), the Device is no
      longer visible to the guest, and thus the operation is complete
      from the perspective of management.
      
      However, there are cases where remaining host-side cleanup is also
      pertinent to management. The is generally handled by treating these
      resources as aspects of the "backend", which can be managed via
      separate interfaces/events, such as blockdev_add/del, netdev_add/del,
      object_add/del, etc, but some devices do not have this level of
      compartmentalization, namely vfio-pci, and possibly to lend themselves
      well to it.
      
      In the case of vfio-pci, the "backend" cleanup happens as part of
      the finalization of the vfio-pci device itself, in particular the
      cleanup of the VFIO group FD. Failing to wait for this cleanup can
      result in tools like libvirt attempting to rebind the device to
      the host while it's still being used by VFIO, which can result in
      host crashes or other misbehavior depending on the host driver.
      
      Deferring DEVICE_DEL still affords us the ability to manage backends
      explicitly, while also addressing cases like vfio-pci's, so we
      implement that approach here.
      
      An alternative proposal involving having VFIO emit a separate event
      to denote completion of host-side cleanup was discussed, but the
      prevailing opinion seems to be that it is not worth the added
      complexity, and leaves the issue open for other Device implementations
      to solve in the future.
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Tested-by: NEric Auger <eric.auger@redhat.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Message-Id: <20171016222315.407-4-mdroth@linux.vnet.ibm.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f7b879e0
    • M
      Revert "qdev: Free QemuOpts when the QOM path goes away" · 2fc06c4a
      Michael Roth 提交于
      This reverts commit abed886e.
      
      This patch originally addressed an issue where a DEVICE_DELETED
      event could be emitted (in device_unparent()) before a Device's
      QemuOpts were cleaned up (in device_finalize()), leading to a
      "duplicate ID" error if management attempted to immediately add
      a device with the same ID in response to the DEVICE_DELETED event.
      
      An alternative will be implemented in a subsequent patch where we
      defer the DEVICE_DELETED event until device_finalize(), which would
      also prevent the race, so we revert the original fix in preparation.
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Tested-by: NEric Auger <eric.auger@redhat.com>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Message-Id: <20171016222315.407-3-mdroth@linux.vnet.ibm.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      2fc06c4a
    • 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
  11. 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
  12. 14 7月, 2017 1 次提交
  13. 19 6月, 2017 1 次提交
  14. 02 6月, 2017 1 次提交
  15. 17 5月, 2017 2 次提交
    • 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
    • J
      migration: Move check_migratable() into qdev.c · 1bfe5f05
      Juan Quintela 提交于
      The function is only used once, and nothing else in migration knows
      about objects.  Create the function vmstate_device_is_migratable() in
      savem.c that really do the bit that is related with migration.
      Signed-off-by: NJuan Quintela <quintela@redhat.com>
      Reviewed-by: NPeter Xu <peterx@redhat.com>
      1bfe5f05
  16. 21 4月, 2017 4 次提交
  17. 01 3月, 2017 1 次提交
  18. 28 2月, 2017 1 次提交
  19. 06 2月, 2017 2 次提交
  20. 15 11月, 2016 1 次提交
  21. 02 11月, 2016 1 次提交
    • X
      nvdimm acpi: introduce fit buffer · 75b0713e
      Xiao Guangrong 提交于
      The buffer is used to save the FIT info for all the presented nvdimm
      devices which is updated after the nvdimm device is plugged or
      unplugged. In the later patch, it will be used to construct NVDIMM
      ACPI _FIT method which reflects the presented nvdimm devices after
      nvdimm hotplug
      
      As FIT buffer can not completely mapped into guest address space,
      OSPM will exit to QEMU multiple times, however, there is the race
      condition - FIT may be changed during these multiple exits, so that
      some rules are introduced:
      1) the user should hold the @lock to access the buffer and
      2) mark @dirty whenever the buffer is updated.
      
      @dirty is cleared for the first time OSPM gets fit buffer, if
      dirty is detected in the later access, OSPM will restart the
      access
      
      As fit should be updated after nvdimm device is successfully realized
      so that a new hotplug callback, post_hotplug, is introduced
      Signed-off-by: NXiao Guangrong <guangrong.xiao@linux.intel.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      75b0713e
  22. 04 8月, 2016 1 次提交
  23. 27 7月, 2016 1 次提交
  24. 17 6月, 2016 1 次提交
  25. 14 6月, 2016 1 次提交
    • P
      qdev_try_create(): Assert that devices we put onto the system bus are SysBusDevices · 7474f1be
      Peter Maydell 提交于
      If qdev_try_create() is passed NULL for the bus, it will automatically
      put the newly created device onto the default system bus. However
      if the device is not actually a SysBusDevice then this will result
      in later crashes (for instance when running the monitor "info qtree"
      command) because code reasonably assumes that all devices on the system
      bus are system bus devices.
      
      Generally the mistake is that the calling code should create the
      object with object_new(TYPE_FOO) rather than qdev_create(NULL, TYPE_FOO);
      see commit 6749695e for an example of fixing this bug.
      
      Assert in qdev_try_create() if the device isn't suitable to put on
      the system bus, so that this mistake results in failure earlier
      and more reliably.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      7474f1be
  26. 07 6月, 2016 1 次提交
  27. 26 5月, 2016 1 次提交
  28. 09 2月, 2016 2 次提交
    • E
      qom: Swap 'name' next to visitor in ObjectPropertyAccessor · d7bce999
      Eric Blake 提交于
      Similar to the previous patch, it's nice to have all functions
      in the tree that involve a visitor and a name for conversion to
      or from QAPI to consistently stick the 'name' parameter next
      to the Visitor parameter.
      
      Done by manually changing include/qom/object.h and qom/object.c,
      then running this Coccinelle script and touching up the fallout
      (Coccinelle insisted on adding some trailing whitespace).
      
          @ rule1 @
          identifier fn;
          typedef Object, Visitor, Error;
          identifier obj, v, opaque, name, errp;
          @@
           void fn
          - (Object *obj, Visitor *v, void *opaque, const char *name,
          + (Object *obj, Visitor *v, const char *name, void *opaque,
             Error **errp) { ... }
      
          @@
          identifier rule1.fn;
          expression obj, v, opaque, name, errp;
          @@
           fn(obj, v,
          -   opaque, name,
          +   name, opaque,
              errp)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1454075341-13658-20-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      d7bce999
    • E
      qapi: Swap visit_* arguments for consistent 'name' placement · 51e72bc1
      Eric Blake 提交于
      JSON uses "name":value, but many of our visitor interfaces were
      called with visit_type_FOO(v, &value, name, errp).  This can be
      a bit confusing to have to mentally swap the parameter order to
      match JSON order.  It's particularly bad for visit_start_struct(),
      where the 'name' parameter is smack in the middle of the
      otherwise-related group of 'obj, kind, size' parameters! It's
      time to do a global swap of the parameter ordering, so that the
      'name' parameter is always immediately after the Visitor argument.
      
      Additional reason in favor of the swap: the existing include/qjson.h
      prefers listing 'name' first in json_prop_*(), and I have plans to
      unify that file with the qapi visitors; listing 'name' first in
      qapi will minimize churn to the (admittedly few) qjson.h clients.
      
      Later patches will then fix docs, object.h, visitor-impl.h, and
      those clients to match.
      
      Done by first patching scripts/qapi*.py by hand to make generated
      files do what I want, then by running the following Coccinelle
      script to affect the rest of the code base:
       $ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
      I then had to apply some touchups (Coccinelle insisted on TAB
      indentation in visitor.h, and botched the signature of
      visit_type_enum() by rewriting 'const char *const strings[]' to
      the syntactically invalid 'const char*const[] strings').  The
      movement of parameters is sufficient to provoke compiler errors
      if any callers were missed.
      
          // Part 1: Swap declaration order
          @@
          type TV, TErr, TObj, T1, T2;
          identifier OBJ, ARG1, ARG2;
          @@
           void visit_start_struct
          -(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
           { ... }
      
          @@
          type bool, TV, T1;
          identifier ARG1;
          @@
           bool visit_optional
          -(TV v, T1 ARG1, const char *name)
          +(TV v, const char *name, T1 ARG1)
           { ... }
      
          @@
          type TV, TErr, TObj, T1;
          identifier OBJ, ARG1;
          @@
           void visit_get_next_type
          -(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
           { ... }
      
          @@
          type TV, TErr, TObj, T1, T2;
          identifier OBJ, ARG1, ARG2;
          @@
           void visit_type_enum
          -(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
           { ... }
      
          @@
          type TV, TErr, TObj;
          identifier OBJ;
          identifier VISIT_TYPE =~ "^visit_type_";
          @@
           void VISIT_TYPE
          -(TV v, TObj OBJ, const char *name, TErr errp)
          +(TV v, const char *name, TObj OBJ, TErr errp)
           { ... }
      
          // Part 2: swap caller order
          @@
          expression V, NAME, OBJ, ARG1, ARG2, ERR;
          identifier VISIT_TYPE =~ "^visit_type_";
          @@
          (
          -visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
          +visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
          |
          -visit_optional(V, ARG1, NAME)
          +visit_optional(V, NAME, ARG1)
          |
          -visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
          +visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
          |
          -visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
          +visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
          |
          -VISIT_TYPE(V, OBJ, NAME, ERR)
          +VISIT_TYPE(V, NAME, OBJ, ERR)
          )
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      51e72bc1
  29. 29 1月, 2016 1 次提交
  30. 21 1月, 2016 1 次提交