qapi: Add human mode to StringOutputVisitor
This will be used by "info qtree". For numbers it prints both thedecimal and hex values. For sizes it rounds to the nearest powerof 2^10. For strings, it puts quotes around the string and separatesNULL and empty string....
add optional 2nd stage initialization to -object/object-add commands
Introduces USER_CREATABLE interface that must be implemented byobjects which are designed to created with -object CLI option orobject-add QMP command.
Interface provides an ability to do an optional second stage...
Merge remote branch 'luiz/queue/qmp' into qmpq
qom: catch errors in object_property_add_child
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()
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>...
qom: Split out object and class caches
The object-cast and class-cast caches cannot be shared because classcaching is conditional on the target type not being an interface andobject caching is unconditional. Leads to a bug when a class castto an interface follows an object cast to the same interface type:...
qom: Do not register interface "types" in the type table and fix names
There should be no need to look up nor enumerate the interface "types",whose "classes" are really just vtables. Just create the types andadd them to the interface list of the parent type....
qdev: Replace no_user by cannot_instantiate_with_device_add_yet
In an ideal world, machines can be built by wiring devices togetherwith configuration, not code. Unfortunately, that's not the world welive in right now. We still have quite a few devices that need to be...
cpu: Document why cannot_instantiate_with_device_add_yet
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Andreas Färber <afaerber@suse.de>
qom: Fix memory leak in object_property_set_link()
Save the result of the call to object_get_canonical_path()so we can free it.
Cc: qemu-stable@nongnu.orgSigned-off-by: Vlad Yasevich <vyasevic@redhat.com>Reviewed-by: Amos Kong <akong@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>...
Merge remote-tracking branch 'mst/tags/for_anthony' into staging
pci, pc, acpi fixes, enhancements
This includes some pretty big changes:- pci master abort support by Marcel- pci IRQ API rework by Marcel- acpi generation support by myself
Everything has gone through several revisions, latest versions have been on...
qom: add pointer to int property helpers
Make it easy to add read-only helpers for simpleinteger properties in memory.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>Tested-by: Gerd Hoffmann <kraxel@redhat.com>...
cpu: Move cpu state syncs up into cpu_dump_state()
The x86 and ppc targets call cpu_synchronize_state() from their*_cpu_dump_state() callbacks to ensure that up to date state is dumpedwhen KVM is enabled (for example when a KVM internal error occurs)....
Merge remote-tracking branch 'afaerber/tags/qom-cpu-for-anthony' into staging
QOM CPUState refactorings / X86CPU
cpu: Replace qemu_for_each_cpu()
It was introduced to loop over CPUs from target-independent code, butsince commit 182735efaf956ccab50b6d74a4fed163e0f35660 target-independentCPUState is used.
A loop can be considered more efficient than function calls in a loop,...
qom: Pass available size to object_initialize()
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: Assert instance size in object_initialize_with_type()
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>
gdbstub: Fix gdb_register_coprocessor() register counting
Commit a0e372f0c49ac01faeaeb73a6e8f50e8ac615f34 reorganized the registercounting for GDB. While it seems correct not to let the total number ofregisters skyrocket in an SMP scenario through a static variable, the...
qom: Introduce instance_post_init hook
This will allow classes to specify a function to be called after allinstance_init functions were called.
This will be used by DeviceState to call qdev_prop_set_globals() at theright moment.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>...
cpu: Partially revert "cpu: Change qemu_init_vcpu() argument to CPUState"
Commit c643bed99 moved qemu_init_vcpu() calls to common CPUState code.This causes x86 cpu-add to fail with "KVM: setting VAPIC address failed".
The reason for the failure is that CPUClass::kvm_fd is not yet...
cpu: Introduce CPUClass::gdb_{read,write}_register()
Completes migration of target-specific code to new target-*/gdbstub.c.
Acked-by: Michael Walle <michael@walle.cc> (for lm32)Acked-by: Max Filippov <jcmvbkbc@gmail.com> (for xtensa)Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Introduce CPUState::gdb_num_regs and CPUClass::gdb_num_core_regs
CPUState::gdb_num_regs replaces num_g_regs.CPUClass::gdb_num_core_regs replaces NUM_CORE_REGS.
Allows building gdb_register_coprocessor() for xtensa, too.
As a side effect this should fix coprocessor register numbering for SMP....
QOM CPUState refactorings
qom: Fix class cast of NULL classes
Its clear from the implementation that class casting is supposed to workwith a NULL class argument. Guard all dereferences of the class argumentagainst NULL accordingly.
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>...
cpu: Move reset logging to CPUState
x86 was using additional CPU_DUMP_* flags, so make that configurable inCPUClass::reset_dump_flags.
This adds reset logging for alpha, unicore32 and xtensa.
Acked-by: Michael Walle <michael@walle.cc> (for lm32)Reviewed-by: Richard Henderson <rth@twiddle.net>...
qom: Use atomics for object refcounting
Object reference counts will soon be changed outside the BQL. So we needto 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>...
cpu: Change qemu_init_vcpu() argument to CPUState
This allows to move the call into CPUState's realizefn.Therefore move the stub into libqemustub.a.
Reviewed-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Change cpu_exit() argument to CPUState
It no longer depends on CPUArchState, so move it to qom/cpu.c.
Prepares for changing GDBState::c_cpu to CPUState.
Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Turn cpu_dump_{state,statistics}() into CPUState hooks
Make cpustats monitor command available unconditionally.
Prepares for changing kvm_handle_internal_error() and kvm_cpu_exec()arguments to CPUState.
cpu: Change default for CPUClass::get_paging_enabled()
qemu_get_guest_memory_mapping() uses cpu_paging_enabled() to determinewhether to use cpu_get_memory_mapping() to return mappings or whether tofall back to a simple identity map.
Since by default CPUClass::get_memory_mapping() is not implemented,...
cpu: Turn cpu_get_memory_mapping() into a CPUState hook
Change error reporting from return value to Error argument.
Reviewed-by: Jens Freimann <jfrei@linux.vnet.ibm.com>Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>[AF: Fixed cpu_get_memory_mapping() documentation]...
cpu: Turn cpu_paging_enabled() into a CPUState hook
Relocate assignment of x86 get_arch_id to have all hooks in one place.
Reviewed-by: Jens Freimann <jfrei@linux.vnet.ibm.com>Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Andreas Färber <afaerber@suse.de>
qom/object: Don't poll cast cache for NULL objects
object_dynamic_cast_assert used to be tolerant of NULL objects and notassert. It's clear from the implementation that this is the expectedbehavior.
The preceding check of the cast cache dereferences obj however causing...
qom: aggressively optimize qom casting
This patch adds a small typename cache to ObjectClass. This allowscaching positive casts within each ObjectClass. Benchmarking aPPC workload provided by Aurelien, this patch eliminates everysingle g_hash_table_lookup() happening during the benchmark (which...
qom: allow casting of a NULL class
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.comSigned-off-by: Anthony Liguori <aliguori@us.ibm.com>
qom: add a fast path to object_class_dynamic_cast
For leaf classes, in many cases the callbacks will simply downcastthe object back to the original class. Add this fast path toobject_class_dynamic_cast, object_dynamic_cast will inherit it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
qom: pass file/line/function to asserting casts
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Message-id: 1368188203-3407-5-git-send-email-pbonzini@redhat.comSigned-off-by: Anthony Liguori <aliguori@us.ibm.com>
qom: trace asserting casts
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...
qom: allow turning cast debugging off
Cast debugging can have a substantial cost (20% or more). Instead of addingspecial-cased "fast casts" in the hot paths, we can just disable it inreleases. The tracing facilities we just added make it easier to analyze...
cpu: Move cpu_write_elfXX_note() functions to CPUState
Convert cpu_write_elfXX_note() functions to CPUClass methods and passCPUState as argument. Update target-i386 accordingly.
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>[AF: Retain stubs as CPUClass' default method implementation; style changes]...
cpu: Introduce get_arch_id() method and override it for X86CPU
get_arch_id() adds possibility for generic code to get a guest-visibleCPU ID without accessing CPUArchState.If derived classes don't override it, it will return cpu_index.
Override it on target-i386 in X86CPU to return the APIC ID....
cpu: Add helper cpu_exists(), to check if CPU with specified id exists
Signed-off-by: Igor Mammedov <imammedo@redhat.com>Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Call cpu_synchronize_post_init() from DeviceClass::realize()
If hotplugged, synchronize CPU state to KVM.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Resume CPU from DeviceClass::realize() if hot-plugged
cpu: Introduce CPU hot-plug notifier
Hot-add CPU event will be distributed to acpi_piix4 and rtc_cmos.
QOM: Fail casts for unknown types
When we try to cast an object to an unknown type, fail the cast. Todaywe would simply run into an assert().
This fixes a bug on qemu-system-s390x for me that gets triggered by theaudio code looking for PCI and ISA buses....
qom: do not return root for empty path
An empty path will return the sole object of that type in theQOM 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...
qom: do nothing on unparent of object without parent
Otherwise, device_unparent will fail to get a canonical path ofthe object.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Message-id: 1364910600-3418-1-git-send-email-pbonzini@redhat.comSigned-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio,pci,qom
Work by Alex to support VGA assignment,pci and virtio fixes by Stefan, Jason and myself, and anew qmp event for hotplug support by myself.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>...
qom: call class destructor before unparent
It seems more logical to have destruction flow start with the subclassand move up to the base class. This ensures object has a validcanonical path when destructor is called.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
qom: Detect attempts to add a property that already exists
Detect attempts to add a property to an object if one ofthat name already exists, and report them as errors.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>...
cpu: Move halted and interrupt_request fields to CPUState
Both fields are used in VMState, thus need to be moved together.Explicitly zero them on reset since they were located beforebreakpoints.
Pass PowerPCCPU to kvmppc_handle_halt().
exec: Pass CPUState to cpu_reset_interrupt()
Move it to qom/cpu.c to avoid build failures depending on include orderof cpu-qom.h and exec/cpu-all.h.
Change opaques of various ..._irq_handler() functions to theappropriate CPU type to facilitate using cpu_reset_interrupt()....
qom/object.c: Reset interface list on inheritance
The QOM framework will attempt the recreate a classes interface list fromscratch for each class. This means that a child class should zero out thelist of interfaces when cloned from the parent class.
Currently the list is memcpy()d from the parent to the child. As the interface...
qom/object.c: Allow itf cast with num_itfs = 0
num_interfaces only tells you how many interfaces the concrete child class has(as defined in the TypeInfo). This means if you have a child class which definesno interfaces of its own, but its parent has interfaces you cannot cast to those...
cpu: Move exit_request field to CPUState
Since it was located before breakpoints field, it needs to be reset.
cpu: Move current_tb field to CPUState
Explictly NULL it on CPU reset since it was located before breakpoints.
Change vapic_report_tpr_access() argument to CPUState. This alsoresolves the use of void* for cpu.h independence.Change vAPIC patch_instruction() argument to X86CPU....
cpu: Prepare QOM realizefn
Overwrite the default implementation with a no-op, no longerattempting to call DeviceClass::init.
qom: remove object_delete
This is now unused. Document the initial reference count of an objectand when it will be freed/finalized.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qom: preserve object while unparenting it
Avoid that the object disappears after it's deleted from the QOMcomposition tree, in case that was the only reference to it.
Acked-by: Andreas Färber <afaerber@suse.de>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
qom: Introduce object_class_is_abstract()
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>
cpu: Add model resolution support to CPUClass
Introduce CPUClass::class_by_name and add a default implementation.Hook up the alpha and ppc implementations.
Introduce a wrapper function cpu_class_by_name().
build: remove universal-obj-y
All of universal-obj-y, user-obj-y (right now unused) and common-obj-y canbe unified into common-obj-y if we take care of defining CONFIG_SOFTMMUand CONFIG_USER_ONLY in the toplevel makefile. This is similar to howwe define symbols for hardware components....
qom: Make object_resolve_path_component() path argument const
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>...
build: consolidate multiple variables into universal-obj-y
The directory descent mechanism, and a less-flat tree both helpedin making some *-obj-y definitions very short. Many of theseoften end up in universal-obj-y, and used to be separate onlybecause of libuser (which is now part of history...)....
Make all static TypeInfos const
Since 39bffca2030950ef6efe57c2fac8327a45ae1015 (qdev: register alltypes natively through QEMU Object Model), TypeInfo as used inthe common, non-iterative pattern is no longer amended with informationand should therefore be const....
cpu: Change parent type to Device
This finally makes the CPU class a subclass of the Device class,allowing us to start using DeviceState properties on CPU subclasses.
It has no_user=1, as creating CPUs using -device doesn't work yet.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>...
misc: move include files to include/qemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qom: move include files to include/qom/
qapi: move include files to include/qobject/
qapi: remove qapi/qapi-types-core.h
The file is only including error.h and qerror.h. Prefer explicitinclusion of whatever files are needed.Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qom: make object_finalize static
It is not used anymore, and there is no need to make it public.
qom: fix refcount of non-heap-allocated objects
The reference count for embedded objects is always one too low, becauseobject_initialize_with_type returns with zero references to the object.This causes premature finalization of the object (or an assertion failure)...
qdev: move bus removal to object_unparent
Add an ObjectClass method that is done at object_unparent time. Itshould remove any backlinks to the object in the composition tree,so that object_delete will be able to drop the last reference andfree the object....
qom: make object_delete usable for statically-allocated objects
Store in the object the freeing function that will be used at deletiontime. This makes it possible to use object_delete on statically-allocated(embedded) objects. Dually, it makes it possible to use object_unparent...
qom: dynamic_cast of NULL is always NULL
Trying to cast a NULL value will cause a crash. ReturningNULL is also sensible, and it is also what the type-unsafeDO_UPCAST macro does.
Reported-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
object: add object_property_add_bool (v2)
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>---v1 -> v2 - Fix whitespace (Andreas Faerber)
qom: object_delete should unparent the object first
object_deinit is only called when the reference count goes to zero,and yet tries to do an object_unparent. Now, object_unparenteither does nothing or it will decrease the reference count.Because we know the reference count is zero, the object_unparent...
qom: Reimplement Interfaces
The current implementation of Interfaces is poorly designed. Each interfacethat an object implements ends up being an object that's tracked by theimplementing object. There's all sorts of gymnastics to deal with castingbetween these objects....
qbus: Make child devices links
Make qbus children show up as link<> properties. There is no stableaddressing for qbus children so we use an unstable naming convention.
This is okay in QOM though because the composition name is expected tobe what's stable....
qdev: Remove qdev_prop_exists()
Can be replaced everywhere with object_property_find().
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Andreas Färber <afaerber@suse.de>
qom: Push error reporting to object_property_find()
Avoids duplicated error_set().
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>[AF: Also drop error_set() in object_property_del().]Signed-off-by: Andreas Färber <afaerber@suse.de>
qom: Add class_base_init
The class_base_init TypeInfo callback was present in one of the earlyQOM versions but removed (on my request...) before committing. Wewill need it soon, add it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>...
qom: Make Object a type
Right now the base Object class has a special NULL type. Change this sothat we will be able to add class_init and class_base_init callbacks.To do this, remove some special casing of ObjectClass that is not reallynecessary.
qom: Assert that public types have a non-NULL parent field
This protects against unwanted effects of changing TYPE_OBJECT fromNULL to a string.
Suggested-by: Andreas Färber <afaerber@suse.de>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Andreas Färber <afaerber@suse.de>
qdev: Push "type" property up to Object
Now that Object is a type, add an instance_init function and pushthe "type" property from qdev to there.
qom: Add object_class_get_parent()
This simple bit of functionality was missing and we'll need it soon,so add it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>[AF: Document possible NULL return value]...
qom: Introduce object_property_is_{child,link}()
Avoids hardcoding partial string comparisons.
Signed-off-by: Alexander Barabash <alexander_barabash@mentor.com>Signed-off-by: Andreas Färber <afaerber@suse.de>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
qom: Add object_child_foreach()
A utility function that will be used to implement hierarchical realization.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>[AF: Drop unrelated whitespace change, add Returns: in documentation]...
build: adapt qom/Makefile and move it to Makefile.objs
qom/ already used a separate makefile. Convert it to use relativepaths, and make it declare both common-obj-y and user-obj-y. Thisway, the upper makefiles do not need to know that some QOM filesare compiled twice....
qdev: Use object_property_print() in info qtree
Otherwise, non-string properties without a legacy counterpart are missed.Also fix error propagation in object_property_print() itself.
qom: Fix memory leak in function container_get
Valgrind reported this memory leak which occured very often.
Test scenario:
qemu-system-i386 (no arguments), only BIOS started, terminate withmonitor command (quit).
Signed-off-by: Stefan Weil <sw@weilnetz.de>...
qom: Refine container_get() to allow using a custom root
Specify the root to search from as argument. This avoids hardcoding"/machine" in some places and makes it more flexible.
Signed-off-by: Andreas Färber <afaerber@suse.de>Cc: Paolo Bonzini <pbonzini@redhat.com>...
qom: add container_get
This is QOM "mkdir -p". It is useful when referring tocontainer objects such as "/machine".
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qom: Introduce CPU class
Reintroduce CPUState as QOM object: It's abstract and derived directlyfrom TYPE_OBJECT for compatibility with the user emulators.The identifier CPUState avoids conflicts between CPU and the struct.
Introduce $(qom-twice-y) to build it separately for system and for user...
qom/object.c: rename type_class_init() to type_initialize()
Function name type_class_init() gave us a wrong impression of separationof type's "class" and "object" entities initialization. Name type_initialize()is more appropriate for type_class_init() function (considering what operations...
qom: Introduce object_class_get_list()
This function allows to obtain a singly-linked list of classes, whichcan be sorted by the caller.
Signed-off-by: Andreas Färber <afaerber@suse.de>Cc: Anthony Liguori <anthony@codemonkey.ws>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qom: if @instance_size==0, assign size of object to parent object size
QOM documentation states that for objects of type with @instance_size == 0 sizewill be assigned to match parent object's size. But currently this feauture isnot implemented and qemu asserts during creation of object with zero instance_size....
qom: fix device hot-unplug
Property removal modifies the list, so it is not safe to continueiteration. We know anyway that each object can have only oneparent (see object_property_add_child), so exit after findingthe requested object.
Reported-by: Michael S. Tsirkin <mst@redhat.com>...
qom: In function object_set_link_property(), first call object_ref(), then object_unref().
In the old implementation, if the new value of the property linksto the same object, as the old value, that object is first unref-ed,and then ref-ed. This leads to unintended deinitialization of that object....