summaryrefslogtreecommitdiffstats
path: root/qom/object.c
Commit message (Collapse)AuthorAgeFilesLines
* qom: Demote already-has-a-parent to a regular errorPeter Crosthwaite2014-10-231-1/+5
| | | | | | | | | | | | Rather than an abort(). This allows callers to decide whether parenting an already-parented object is a fatal error condition. Useful for providing a default value for an object's parent in the case where you want to set one iff it doesn't already have one. Reviewed-by: Alexander Graf <agraf@suse.de> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qom: Allow clearing of a Link propertyPeter Crosthwaite2014-10-231-3/+7
| | | | | | | | | | | | By passing in "" to object_property_set_link. The lead user of this is the QDEV GPIO framework which will implement GPIO disconnects via an "unlink". GPIO disconnection is used by qtest's irq_intercept_out command. Reviewed-by: Alexander Graf <agraf@suse.de> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qom: Add description field in ObjectProperty structGonglei2014-10-151-0/+20
| | | | | | | | | | | | | The descriptions can serve as documentation in the code, and they can be used to provide better help. Copy property descriptions when copying alias properties. Cc: Markus Armbruster <armbru@redhat.com> Signed-off-by: Gonglei <arei.gonglei@huawei.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: Add error handler for object alias propertyGonglei2014-10-151-1/+8
| | | | | | | | | | | | | | | | object_property_add_alias() is called at some places at present. And its parameter errp may not NULL, such as object_property_add_alias(obj, "iothread", OBJECT(&dev->vdev),"iothread", &error_abort); This patch add error handler for security. Cc: Stefan Hajnoczi <stefanha@redhat.com> Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Markus Armbruster <armbru@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: Add error handler for object_property_print()Gonglei2014-10-151-2/+10
| | | | | | | | | | Avoid the caller of object_property_print() leaking string argument's memory, such as qdev_print_props() when encounter errors. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: Add automatic arrayification to object_property_add()Peter Crosthwaite2014-09-041-0/+21
| | | | | | | | | | | | | | | If "[*]" is given as the last part of a QOM property name, treat that as an array property. The added property is given the first available name, replacing the * with a decimal number counting from 0. First add with name "foo[*]" will be "foo[0]". Second "foo[1]" and so on. Callers may inspect the ObjectProperty * return value to see what number the added property was given. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: Make object_child_foreach() safe for objects removalAlexey Kardashevskiy2014-09-041-2/+2
| | | | | | | | | | | | Current object_child_foreach() uses QTAILQ_FOREACH() to walk through children and that makes children removal from the callback impossible. This makes object_child_foreach() use QTAILQ_FOREACH_SAFE(). Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Hu Tao <hutao@cn.fujitsu.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom/object.c, hmp.c: fix string_output_get_string() memory leakChen Fan2014-09-021-2/+10
| | | | | | | | | | string_output_get_string() uses g_string_free(str, false) to transfer the 'str' pointer to callers and never free it. Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Hu Tao <hutao@cn.fujitsu.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* qom: object: move unparenting to the child property's release callbackPaolo Bonzini2014-08-171-10/+4
| | | | | | | | | | | | This ensures that the unparent callback is called automatically when the parent object is finalized. Note that there's no need to keep a reference neither in object_unparent nor in object_finalize_child_property. The reference held by the child property itself will do. Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qom: object: delete properties before calling instance_finalizePaolo Bonzini2014-08-171-1/+1
| | | | | | | | This ensures that the children's unparent callback will still have a usable parent. Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qom: object: Ignore refs/unrefs of NULLPeter Crosthwaite2014-07-011-6/+8
| | | | | | | | | Just do nothing if passed NULL for a ref or unref. This avoids call sites that manage a combination of NULL or non-NULL pointers having to add iffery around every ref and unref. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qom: object: remove parent pointer when unparentingPeter Crosthwaite2014-07-011-0/+1
| | | | | | | | | Certain parts of the QOM framework test this pointer to determine if an object is parented. Nuke it when the object is unparented to allow for reuse of an object after unparenting. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qom: allow creating an alias of a child<> propertyPaolo Bonzini2014-07-011-1/+11
| | | | | | | | | | | | Child properties must be unique. Fix this problem by turning their aliases into links. The resolve function that forwards to the target property does not have any knowledge of the target property's type, so it works fine. Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qom: add a generic mechanism to resolve pathsPaolo Bonzini2014-07-011-29/+53
| | | | | | | | | | | | | It may be desirable to have custom link<> properties that do more than just store an object. Even the addition of a "check" function is not enough if setting the link has side effects or if a non-standard reference counting is preferrable. Avoid the assumption that the opaque field of a link<> is a LinkProperty struct, by adding a generic "resolve" callback to ObjectProperty. This fixes aliases of link properties. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qom: add object_property_add_alias()Stefan Hajnoczi2014-07-011-0/+51
| | | | | | | | | | | | | | | | | Sometimes an object needs to present a property which is actually on another object, or it needs to provide an alias name for an existing property. Examples: a.foo -> b.foo a.old_name -> a.new_name The new object_property_add_alias() API allows objects to alias a property on the same object or another object. The source and target names can be different. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
* qom: introduce object_property_get_enum and object_property_get_uint16ListHu Tao2014-06-191-0/+35
| | | | | | Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* qerror.h: Remove QERR defines that are only used onceCole Robinson2014-04-251-2/+3
| | | | | | | | | | Just hardcode them in the callers Cc: Luiz Capitulino <lcapitulino@redhat.com> Cc: Markus Armbruster <armbru@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* qom: Fix crash with qom-list and link propertiesCole Robinson2014-04-111-1/+2
| | | | | | | | | | | | | | | | Commit 9561fda8d90e176bef598ba87c42a1bd6ad03ef7 changed the type of 'opaque' for link properties, but missed updating this call site. Reproducer: ./x86_64-softmmu/qemu-system-x86_64 -qmp unix:./qmp.sock,server & ./scripts/qmp/qmp-shell ./qmp.sock (QEMU) qom-list path=//machine/i440fx/pci.0/child[2] Reported-by: Marcin Gibuła <m.gibula@beyond.pl> Signed-off-by: Cole Robinson <crobinso@redhat.com> Message-id: 2f8f007ce2152ac3b65f0811199662799c509225.1397155389.git.crobinso@redhat.com Acked-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* qom: Add check() argument to object_property_add_link()Stefan Hajnoczi2014-03-191-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | There are currently three types of object_property_add_link() callers: 1. The link property may be set at any time. 2. The link property of a DeviceState instance may only be set before realize. 3. The link property may never be set, it is read-only. Something similar can already be achieved with object_property_add_str()'s set() argument. Follow its example and add a check() argument to object_property_add_link(). Also provide default check() functions for case #1 and #2. Case #3 is covered by passing a NULL function pointer. 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: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> [AF: Tweaked documentation comment] Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: Make QOM link property unref optionalStefan Hajnoczi2014-03-191-3/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: Don't make link NULL on object_property_set_link() failureStefan Hajnoczi2014-03-191-14/+15
| | | | | | | | | | | The error behavior of object_property_set_link() is dangerous. It sets the link property object to NULL if an error occurs. A setter function should either succeed or fail, it shouldn't leave the value NULL on failure. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: Split object_property_set_link()Stefan Hajnoczi2014-03-191-20/+40
| | | | | | | | | The path resolution logic in object_property_set_link() should be a separate function. This makes the code easier to read and maintain. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into ↵Peter Maydell2014-03-131-22/+32
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | staging Block pull request # gpg: Signature made Thu 13 Mar 2014 13:50:49 GMT using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * remotes/stefanha/tags/block-pull-request: (24 commits) block/raw-win32: bdrv_parse_filename() for hdev block/raw-posix: Strip protocol prefix on creation block/raw-posix: bdrv_parse_filename() for cdrom block/raw-posix: bdrv_parse_filename() for floppy block/raw-posix: bdrv_parse_filename() for hdev qemu-io: Fix warnings from static code analysis block: Unlink temporary file qcow2: Don't write with BDRV_O_INCOMING qcow2: Keep option in qcow2_invalidate_cache() qmp: add query-iothreads command iothread: stash thread ID away dataplane: replace internal thread with IOThread iothread: add "iothread" qdev property type qdev: make get_pointer() handle temporary strings iothread: add I/O thread object aio: add aio_context_acquire() and aio_context_release() rfifolock: add recursive FIFO lock object: add object_get_canonical_path_component() block: Rewrite the snapshot authorization mechanism for block filters. iotests: Test corruption during COW request ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
| * object: add object_get_canonical_path_component()Stefan Hajnoczi2014-03-131-22/+32
| | | | | | | | | | | | | | | | | | 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>
* | qom: Avoid leaking str and bool properties on failureStefan Hajnoczi2014-03-121-2/+12
|/ | | | | | | | | | | | | | | When object_property_add_str() and object_property_add_bool() fail, they leak their internal StringProperty and BoolProperty structs. Remember to free the structs on error. Luckily this is a low-impact memory leak since most QOM properties are static qdev properties that will never take the error case. object_property_add() only fails if the property name is already in use. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Cc: qemu-stable@nongnu.org Signed-off-by: Andreas Färber <afaerber@suse.de>
* qapi: Add human mode to StringOutputVisitorPaolo Bonzini2014-02-141-2/+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>
* Merge remote branch 'luiz/queue/qmp' into qmpqEdgar E. Iglesias2014-01-141-3/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * luiz/queue/qmp: migration: qmp_migrate(): keep working after syntax error qerror: Remove assert_no_error() qemu-option: Remove qemu_opts_create_nofail target-i386: Remove assert_no_error usage hw: Remove assert_no_error usages qdev: Delete dead code error: Add error_abort monitor: add object-add (QMP) and object_add (HMP) command monitor: add object-del (QMP) and object_del (HMP) command qom: catch errors in object_property_add_child qom: fix leak for objects created with -object rng: initialize file descriptor to -1 qemu-monitor: HMP cpu-add wrapper vl: add missing transition debug->finish_migrate Message-Id: 1389045795-18706-1-git-send-email-lcapitulino@redhat.com Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
| * qom: catch errors in object_property_add_childPaolo Bonzini2014-01-061-3/+8
| | | | | | | | | | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Tested-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* | qom: Detect bad reentrance during object_class_foreach()Hervé Poussineau2013-12-241-0/+5
| | | | | | | | | | | | | | | | | | | | We should not modify the type hash table while it is being iterated on. Assert that it does not happen. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> 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-11/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-6/+7
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 memory leak in object_property_set_link()Vlad Yasevich2013-11-191-2/+3
| | | | | | | | | | | Save the result of the call to object_get_canonical_path() so we can free it. Cc: qemu-stable@nongnu.org Signed-off-by: Vlad Yasevich <vyasevic@redhat.com> Reviewed-by: Amos Kong <akong@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* qom: add pointer to int property helpersMichael S. Tsirkin2013-10-141-0/+60
| | | | | | | | | | | | 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: Assert instance size in object_initialize_with_type()Andreas Färber2013-08-301-3/+4
| | | | | | | | 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/+1
| | | | | | | 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: Introduce instance_post_init hookEduardo Habkost2013-08-161-0/+14
| | | | | | | | | | | 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: Fix class cast of NULL classesPeter Crosthwaite2013-07-101-3/+3
| | | | | | | | | | Its clear from the implementation that class casting is supposed to work with a NULL class argument. Guard all dereferences of the class argument against NULL accordingly. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Message-id: 94cd5ba46b74eea289a7e582635820c1c54e66fa.1371546907.git.peter.crosthwaite@xilinx.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qom: Use atomics for object refcountingJan Kiszka2013-07-041-3/+2
| | | | | | | | | | | Object reference counts will soon be changed outside the BQL. So we need to use atomics in object_ref/unref. Based on a patch by Liu Ping Fan. Signed-off-by: Liu Ping Fan <qemulist@gmail.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qom/object: Don't poll cast cache for NULL objectsPeter Crosthwaite2013-05-221-2/+2
| | | | | | | | | | | | | | | | | | object_dynamic_cast_assert used to be tolerant of NULL objects and not assert. It's clear from the implementation that this is the expected behavior. The preceding check of the cast cache dereferences obj however causing a segfault. Fix by conditionalizing the cast cache logic on obj being non-null. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Message-id: 8e2bef6a55753869c50bfa32226f7fcf0439ca62.1369183592.git.peter.crosthwaite@xilinx.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qom: aggressively optimize qom castingAnthony Liguori2013-05-131-2/+38
| | | | | | | | | | | | | | | | 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-4/+11
| | | | | | | | | | | 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: trace asserting castsPaolo Bonzini2013-05-131-1/+9
| | | | | | | | | This provides a way to detect the cast that leads to a (reproducible) crash even when QOM cast debugging is disabled. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1368188203-3407-6-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-6/+9
| | | | | | 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: add a fast path to object_class_dynamic_castPaolo Bonzini2013-05-131-0/+5
| | | | | | | | | | For leaf classes, in many cases the callbacks will simply downcast the object back to the original class. Add this fast path to object_class_dynamic_cast, object_dynamic_cast will inherit it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1368188203-3407-4-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qom: allow casting of a NULL classPaolo Bonzini2013-05-131-3/+9
| | | | | | | | This mimics what we do in object_dynamic_cast_assert. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1368188203-3407-3-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* QOM: Fail casts for unknown typesAlexander Graf2013-04-301-0/+5
| | | | | | | | | | | | | When we try to cast an object to an unknown type, fail the cast. Today we would simply run into an assert(). This fixes a bug on qemu-system-s390x for me that gets triggered by the audio code looking for PCI and ISA buses. Signed-off-by: Alexander Graf <agraf@suse.de> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1367326936-28539-1-git-send-email-agraf@suse.de Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qom: do not return root for empty pathPaolo Bonzini2013-04-291-10/+2
| | | | | | | | | An empty path will return the sole object of that type in the QOM tree. This is different from "/", which returns the root. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1366303444-24620-7-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qom: do nothing on unparent of object without parentPaolo Bonzini2013-04-161-0/+4
| | | | | | | | | Otherwise, device_unparent will fail to get a canonical path of the object. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1364910600-3418-1-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Merge remote-tracking branch 'mst/tags/for_anthony' into stagingAnthony Liguori2013-03-261-3/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | virtio,pci,qom Work by Alex to support VGA assignment, pci and virtio fixes by Stefan, Jason and myself, and a new qmp event for hotplug support by myself. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # gpg: Signature made Tue 26 Mar 2013 02:02:24 PM CDT using RSA key ID D28D5469 # gpg: Can't check signature: public key not found # By Alex Williamson (13) and others # Via Michael S. Tsirkin * mst/tags/for_anthony: (23 commits) pcie: Add endpoint capability initialization wrapper roms: switch oldnoconfig to olddefconfig pcie: Mangle types to match topology pci: Create and use API to determine root buses pci: Create pci_bus_is_express helper pci: Q35, Root Ports, and Switches create PCI Express buses pci: Allow PCI bus creation interfaces to specify the type of bus pci: Move PCI and PCIE type defines pci: Create and register a new PCI Express TypeInfo exec: assert that RAMBlock size is non-zero pci: refuse empty ROM files pci_bridge: Remove duplicate IRQ swizzle function pci_bridge: Use a default map_irq function pci: Fix INTx routing notifier recursion pci_bridge: drop formatting from source pci_bridge: factor out common code pci: Teach PCI Bridges about VGA routing pci: Add PCI VGA helpers virtio-pci: guest notifier mask without non-irqfd virtio-net: remove layout assumptions for mq ctrl ...
| * qom: call class destructor before unparentMichael S. Tsirkin2013-03-261-3/+3
| | | | | | | | | | | | | | | | It seems more logical to have destruction flow start with the subclass and move up to the base class. This ensures object has a valid canonical path when destructor is called. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
OpenPOWER on IntegriCloud