summaryrefslogtreecommitdiffstats
path: root/include/qom/object.h
Commit message (Collapse)AuthorAgeFilesLines
* object: add object_get_canonical_path_component()Stefan Hajnoczi2014-03-131-0/+8
| | | | | | | | | It is often useful to find an object's child property name. Also use this new function to simplify the implementation of object_get_canonical_path(). Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* qapi: Add human mode to StringOutputVisitorPaolo Bonzini2014-02-141-1/+2
| | | | | | | | | | | | This will be used by "info qtree". For numbers it prints both the decimal and hex values. For sizes it rounds to the nearest power of 2^10. For strings, it puts quotes around the string and separates NULL and empty string. Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: Do not register interface "types" in the type table and fix namesPaolo Bonzini2013-12-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | 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: Igor Mammedov <imammedo@redhat.com> Tested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: Split out object and class cachesPeter Crosthwaite2013-12-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Tested-by: Nathan Rossi <nathan.rossi@xilinx.com> Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: Fix pointer to int property helpers' documentationMichael S. Tsirkin2013-11-051-21/+52
| | | | | | Relocate to alongside the other object_property_add_* helpers while at it. Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: add pointer to int property helpersMichael S. Tsirkin2013-10-141-0/+21
| | | | | | | | | | | | Make it easy to add read-only helpers for simple integer properties in memory. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Tested-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Tested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* qom: cleanup struct Error referencesMichael S. Tsirkin2013-10-141-25/+25
| | | | | | | | | | | | now that a typedef for struct Error is available, use it in qom/object.h to match coding style rules. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Tested-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Tested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* cleanup object.h: include error.h directlyIgor Mammedov2013-10-141-1/+1
| | | | | | | | qapi/error.h is simple enough to be included in qom/object.h direcly and prepares qom/object.h to use Error typedef. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* qom: Assert instance size in object_initialize_with_type()Andreas Färber2013-08-301-1/+2
| | | | | | | | This catches objects initializing beyond allocated memory, e.g., when subtypes get extended with instance state of their own. Suggested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: Pass available size to object_initialize()Andreas Färber2013-08-301-1/+2
| | | | | | | To be passed on to object_initialize_with_type(). Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> (virtio-ccw) Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: Fix object_initialize_with_type() argument name in documentationAndreas Färber2013-08-301-1/+1
| | | | | | | @obj -> @data. Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* object: Fix typo in qom/object.hPeter Chubb2013-08-301-1/+1
| | | | | | | | There's been a cut-and-paste error, it looks like, in the documentation in qom/object.h. Signed-off-by: Peter Chubb <peter.chubb@nicta.com.au> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: Introduce instance_post_init hookEduardo Habkost2013-08-161-0/+3
| | | | | | | | | | | This will allow classes to specify a function to be called after all instance_init functions were called. This will be used by DeviceState to call qdev_prop_set_globals() at the right moment. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: aggressively optimize qom castingAnthony Liguori2013-05-131-0/+4
| | | | | | | | | | | | | | | | 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: Anthony Liguori <aliguori@us.ibm.com>
* qom: allow turning cast debugging offPaolo Bonzini2013-05-131-5/+6
| | | | | | | | | | | Cast debugging can have a substantial cost (20% or more). Instead of adding special-cased "fast casts" in the hot paths, we can just disable it in releases. The tracing facilities we just added make it easier to analyze those problems that cast debugging would reveal. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1368188203-3407-7-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qom: pass file/line/function to asserting castsPaolo Bonzini2013-05-131-5/+11
| | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1368188203-3407-5-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qom: improve documentation of cast functionsPaolo Bonzini2013-05-131-2/+21
| | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1368188203-3407-2-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix typos and misspellingsPeter Maydell2013-03-221-1/+1
| | | | | | | | | Fix various typos and misspellings. The bulk of these were found with codespell. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* qom: remove object_deletePaolo Bonzini2013-02-011-17/+10
| | | | | | | | This is now unused. Document the initial reference count of an object and when it will be freed/finalized. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qom: document reference counting of link propertiesPaolo Bonzini2013-02-011-0/+5
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qom: Introduce object_class_is_abstract()Andreas Färber2013-01-271-0/+8
| | | | | | | | This lets a caller check if an ObjectClass as returned by, e.g., object_class_by_name() is instantiatable. Signed-off-by: Andreas Färber <afaerber@suse.de> Cc: Anthony Liguori <anthony@codemonkey.ws>
* qom: Extend documentation on QOM method conceptsAndreas Färber2013-01-171-3/+101
| | | | | | | | | | Add a documentation section "Methods" and discuss among others how to handle overriding virtual methods. Clarify DeviceClass::realize documentation and refer to the above. Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qom: Make object_resolve_path_component() path argument constAndreas Färber2013-01-151-1/+1
| | | | | | | | | | | A usage with a hardcoded partial path such as object_resolve_path_component(obj, "foo") is totally valid but currently leads to a compilation error. Fix this. Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* Make all static TypeInfos constAndreas Färber2013-01-101-3/+3
| | | | | | | | | | | | | | | | | | | | | | | Since 39bffca2030950ef6efe57c2fac8327a45ae1015 (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: Andreas Färber <afaerber@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* misc: move include files to include/qemu/Paolo Bonzini2012-12-191-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qom: move include files to include/qom/Paolo Bonzini2012-12-191-0/+1003
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
OpenPOWER on IntegriCloud