1. 20 3月, 2014 1 次提交
    • S
      qom: Make QOM link property unref optional · 9561fda8
      Stefan Hajnoczi 提交于
      Some object_property_add_link() callers expect property deletion to
      unref the link property object.  Other callers expect to manage the
      refcount themselves.  The former are currently broken and therefore leak
      the link property object.
      
      This patch adds a flags argument to object_property_add_link() so the
      caller can specify which refcount behavior they require.  The new
      OBJ_PROP_LINK_UNREF_ON_RELEASE flag causes the link pointer to be
      unreferenced when the property is deleted.
      
      This fixes refcount leaks in qdev.c, xilinx_axidma.c, xilinx_axienet.c,
      s390-virtio-bus.c, virtio-pci.c, virtio-rng.c, and ui/console.c.
      
      Rationale for refcount behavior:
      
       * hw/core/qdev.c
         - bus children are explicitly unreferenced, don't interfere
         - parent_bus is essentially a read-only property that doesn't hold a
           refcount, don't unref
         - hotplug_handler is leaked, do unref
      
       * hw/dma/xilinx_axidma.c
         - rx stream "dma" links are set using set_link, therefore they
           need unref
         - tx streams are set using set_link, therefore they need unref
      
       * hw/net/xilinx_axienet.c
         - same reasoning as hw/dma/xilinx_axidma.c
      
       * hw/pcmcia/pxa2xx.c
         - pxa2xx bypasses set_link and therefore does not use refcounts
      
       * hw/s390x/s390-virtio-bus.c
       * hw/virtio/virtio-pci.c
       * hw/virtio/virtio-rng.c
       * ui/console.c
         - set_link is used and there is no explicit unref, do unref
      
      Cc: Peter Crosthwaite <peter.crosthwaite@petalogix.com>
      Cc: Alexander Graf <agraf@suse.de>
      Cc: Anthony Liguori <aliguori@amazon.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NAndreas Färber <afaerber@suse.de>
      9561fda8
  2. 13 3月, 2014 1 次提交
  3. 15 2月, 2014 1 次提交
  4. 25 12月, 2013 2 次提交
    • P
      qom: Do not register interface "types" in the type table and fix names · b061dc41
      Paolo Bonzini 提交于
      There should be no need to look up nor enumerate the interface "types",
      whose "classes" are really just vtables.  Just create the types and
      add them to the interface list of the parent type.
      
      Interfaces not registering their type anymore means that accessing
      superclass::interface by type name will fail when initializing
      subclass::interface.  Thus, we need to pre-initialize the subclass's
      parent_type field before calling type_initialize.  Apart from this, the
      interface "types" should never be used and thus it is harmless to leave
      them out of the hashtable.
      
      Further, the interface types had a bug with interfaces that are
      inherited from a superclass:  The implementation type name was wrong
      (for example it was subclass::superclass::interface rather than
      just subclass::interface).  This patch fixes this as well.
      Reported-by: NIgor Mammedov <imammedo@redhat.com>
      Tested-by: NIgor Mammedov <imammedo@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NAndreas Färber <afaerber@suse.de>
      b061dc41
    • P
      qom: Split out object and class caches · 0ab4c94c
      Peter Crosthwaite 提交于
      The object-cast and class-cast caches cannot be shared because class
      caching is conditional on the target type not being an interface and
      object caching is unconditional. Leads to a bug when a class cast
      to an interface follows an object cast to the same interface type:
      
      FooObject = FOO(obj);
      FooClass = FOO_GET_CLASS(obj);
      
      Where TYPE_FOO is an interface. The first (object) cast will be
      successful and cache the casting result (i.e. TYPE_FOO will be cached).
      The second (class) cast will then check the shared cast cache
      and register a hit. The issue is, when a class cast hits in the cache
      it just returns a pointer cast of the input class (i.e. the concrete
      class).
      
      When casting to an interface, the cast itself must return the
      interface class, not the concrete class. The implementation of class
      cast caching already ensures that the returned cast result is only
      a pointer cast before caching. The object cast logic however does
      not have this check.
      
      Resolve by just splitting the object and class caches.
      
      Cc: qemu-stable@nongnu.org
      Signed-off-by: NPeter Crosthwaite <peter.crosthwaite@xilinx.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Tested-by: NNathan Rossi <nathan.rossi@xilinx.com>
      Reviewed-by: NEdgar E. Iglesias <edgar.iglesias@gmail.com>
      Signed-off-by: NAndreas Färber <afaerber@suse.de>
      0ab4c94c
  5. 06 11月, 2013 1 次提交
  6. 14 10月, 2013 3 次提交
  7. 31 8月, 2013 4 次提交
  8. 17 8月, 2013 1 次提交
  9. 14 5月, 2013 1 次提交
    • A
      qom: aggressively optimize qom casting · 03587328
      Anthony Liguori 提交于
      This patch adds a small typename cache to ObjectClass.  This allows
      caching positive casts within each ObjectClass.  Benchmarking a
      PPC workload provided by Aurelien, this patch eliminates every
      single g_hash_table_lookup() happening during the benchmark (which
      was about 2 million per-second).
      
      With this patch applied, I get exactly the same performance (within
      the margin of error) as with --disable-qom-cast-debug.
      
      N.B. it's safe to cache typenames only from the _assert() macros
      because they are always called with string literals.
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      03587328
  10. 13 5月, 2013 3 次提交
  11. 22 3月, 2013 1 次提交
  12. 02 2月, 2013 2 次提交
  13. 28 1月, 2013 1 次提交
  14. 17 1月, 2013 1 次提交
  15. 15 1月, 2013 1 次提交
  16. 11 1月, 2013 1 次提交
    • A
      Make all static TypeInfos const · 8c43a6f0
      Andreas Färber 提交于
      Since 39bffca2 (qdev: register all
      types natively through QEMU Object Model), TypeInfo as used in
      the common, non-iterative pattern is no longer amended with information
      and should therefore be const.
      
      Fix the documented QOM examples:
      
       sed -i 's/static TypeInfo/static const TypeInfo/g' include/qom/object.h
      
      Since frequently the wrong examples are being copied by contributors of
      new devices, fix all types in the tree:
      
       sed -i 's/^static TypeInfo/static const TypeInfo/g' */*.c
       sed -i 's/^static TypeInfo/static const TypeInfo/g' */*/*.c
      
      This also avoids to piggy-back these changes onto real functional
      changes or other refactorings.
      Signed-off-by: NAndreas Färber <afaerber@suse.de>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      8c43a6f0
  17. 19 12月, 2012 2 次提交
  18. 27 11月, 2012 3 次提交
  19. 16 11月, 2012 1 次提交
  20. 13 8月, 2012 1 次提交
    • A
      qom: Reimplement Interfaces · 33e95c63
      Anthony Liguori 提交于
      The current implementation of Interfaces is poorly designed.  Each interface
      that an object implements ends up being an object that's tracked by the
      implementing object.  There's all sorts of gymnastics to deal with casting
      between these objects.
      
      But an interface shouldn't be associated with an Object.  Interfaces are global
      to a class.  This patch moves all Interface knowledge to ObjectClass eliminating
      the relationship between Object and Interfaces.
      
      Interfaces are now abstract (as they should be) but this is okay.  Interfaces
      essentially act as additional parents for the classes and are treated as such.
      
      With this new implementation, we should fully support derived interfaces
      including reimplementing an inherited interface.
      
      PC: Rebased against qom-next merge Jun-2012.
      
      PC: Removed replication of cast logic for interfaces, i.e. there is only
      one cast function - object_dynamic_cast() (and object_dynamic_cast_assert())
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      Signed-off-by: NPeter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
      Acked-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NEdgar E. Iglesias <edgar.iglesias@gmail.com>
      33e95c63
  21. 18 6月, 2012 7 次提交
  22. 12 5月, 2012 1 次提交