1. 18 10月, 2017 2 次提交
    • 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
  2. 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
  3. 14 7月, 2017 1 次提交
  4. 19 6月, 2017 1 次提交
  5. 02 6月, 2017 1 次提交
  6. 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
  7. 21 4月, 2017 4 次提交
  8. 01 3月, 2017 1 次提交
  9. 28 2月, 2017 1 次提交
  10. 06 2月, 2017 2 次提交
  11. 15 11月, 2016 1 次提交
  12. 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
  13. 04 8月, 2016 1 次提交
  14. 27 7月, 2016 1 次提交
  15. 17 6月, 2016 1 次提交
  16. 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
  17. 07 6月, 2016 1 次提交
  18. 26 5月, 2016 1 次提交
  19. 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
  20. 29 1月, 2016 1 次提交
  21. 21 1月, 2016 1 次提交
  22. 19 1月, 2016 1 次提交
  23. 13 1月, 2016 1 次提交
    • M
      error: Use error_reportf_err() where it makes obvious sense · c29b77f9
      Markus Armbruster 提交于
      Done with this Coccinelle semantic patch
      
          @@
          expression FMT, E, S;
          expression list ARGS;
          @@
          -    error_report(FMT, ARGS, error_get_pretty(E));
          +    error_reportf_err(E, FMT/*@@@*/, ARGS);
          (
          -    error_free(E);
          |
      	 exit(S);
          |
      	 abort();
          )
      
      followed by a replace of '%s"/*@@@*/' by '"' and some line rewrapping,
      because I can't figure out how to make Coccinelle transform strings.
      
      We now use the error whole instead of just its message obtained with
      error_get_pretty().  This avoids suppressing its hint (see commit
      50b7b000), but I can't see how the errors touched in this commit could
      come with hints.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1450452927-8346-12-git-send-email-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      c29b77f9
  24. 11 1月, 2016 1 次提交
  25. 12 11月, 2015 1 次提交
  26. 19 9月, 2015 1 次提交
    • P
      qdev: Do not use slow [*] expansion for GPIO creation · 6c76b377
      Pavel Fedin 提交于
      Expansion of [*] suffix is very slow because index expansion is done using
      trial and error strategy, starting every time from zero and retrying with
      the next index until insertion succeeds. With large number of already added
      properties this process takes huge amount of time (O(n^2) complexity).
      
      Some architectures (like ARM) use very large amount of IRQ pins in interrupt
      controller models. This flaw makes machine startup extremely slow
      (~20 seconds for ARM64 with 32 CPUs). This patch decreases this time down to
      ~10 seconds.
      
      Also in qdev_init_gpio_out_named() memset() is now called only once for the
      whole array instead of per-cell cleaning
      Signed-off-by: NPavel Fedin <p.fedin@samsung.com>
      Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
      Signed-off-by: NAndreas Färber <afaerber@suse.de>
      6c76b377
  27. 11 9月, 2015 1 次提交
  28. 23 6月, 2015 2 次提交
  29. 20 6月, 2015 1 次提交
  30. 19 6月, 2015 1 次提交
  31. 28 4月, 2015 1 次提交
  32. 17 3月, 2015 1 次提交