2 * Dynamic device configuration and creation.
4 * Copyright (c) 2009 CodeSourcery
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 /* The theory here is that it should be possible to create a machine without
21 knowledge of specific devices. Historically board init routines have
22 passed a bunch of arguments to each device, requiring the board know
23 exactly which device it is dealing with. This file provides an abstract
24 API for device configuration and initialization. Devices will generally
25 inherit from a particular bus (e.g. PCI or I2C) rather than
28 #include "qemu/osdep.h"
29 #include "qapi/error.h"
30 #include "qapi/qapi-events-qdev.h"
31 #include "qapi/qmp/qdict.h"
32 #include "qapi/qmp/qerror.h"
33 #include "qapi/visitor.h"
34 #include "qemu/error-report.h"
35 #include "qemu/option.h"
37 #include "hw/qdev-properties.h"
38 #include "hw/boards.h"
39 #include "hw/sysbus.h"
40 #include "hw/qdev-clock.h"
41 #include "migration/vmstate.h"
44 static bool qdev_hot_added
= false;
45 bool qdev_hot_removed
= false;
47 const VMStateDescription
*qdev_get_vmsd(DeviceState
*dev
)
49 DeviceClass
*dc
= DEVICE_GET_CLASS(dev
);
53 static void bus_free_bus_child(BusChild
*kid
)
55 object_unref(OBJECT(kid
->child
));
59 static void bus_remove_child(BusState
*bus
, DeviceState
*child
)
63 QTAILQ_FOREACH(kid
, &bus
->children
, sibling
) {
64 if (kid
->child
== child
) {
67 snprintf(name
, sizeof(name
), "child[%d]", kid
->index
);
68 QTAILQ_REMOVE_RCU(&bus
->children
, kid
, sibling
);
72 /* This gives back ownership of kid->child back to us. */
73 object_property_del(OBJECT(bus
), name
);
75 /* free the bus kid, when it is safe to do so*/
76 call_rcu(kid
, bus_free_bus_child
, rcu
);
82 static void bus_add_child(BusState
*bus
, DeviceState
*child
)
85 BusChild
*kid
= g_malloc0(sizeof(*kid
));
88 kid
->index
= bus
->max_index
++;
90 object_ref(OBJECT(kid
->child
));
92 QTAILQ_INSERT_HEAD_RCU(&bus
->children
, kid
, sibling
);
94 /* This transfers ownership of kid->child to the property. */
95 snprintf(name
, sizeof(name
), "child[%d]", kid
->index
);
96 object_property_add_link(OBJECT(bus
), name
,
97 object_get_typename(OBJECT(child
)),
98 (Object
**)&kid
->child
,
99 NULL
, /* read-only property */
103 static bool bus_check_address(BusState
*bus
, DeviceState
*child
, Error
**errp
)
105 BusClass
*bc
= BUS_GET_CLASS(bus
);
106 return !bc
->check_address
|| bc
->check_address(bus
, child
, errp
);
109 bool qdev_set_parent_bus(DeviceState
*dev
, BusState
*bus
, Error
**errp
)
111 BusState
*old_parent_bus
= dev
->parent_bus
;
112 DeviceClass
*dc
= DEVICE_GET_CLASS(dev
);
114 assert(dc
->bus_type
&& object_dynamic_cast(OBJECT(bus
), dc
->bus_type
));
116 if (!bus_check_address(bus
, dev
, errp
)) {
120 if (old_parent_bus
) {
121 trace_qdev_update_parent_bus(dev
, object_get_typename(OBJECT(dev
)),
122 old_parent_bus
, object_get_typename(OBJECT(old_parent_bus
)),
123 OBJECT(bus
), object_get_typename(OBJECT(bus
)));
125 * Keep a reference to the device while it's not plugged into
126 * any bus, to avoid it potentially evaporating when it is
127 * dereffed in bus_remove_child().
128 * Also keep the ref of the parent bus until the end, so that
129 * we can safely call resettable_change_parent() below.
131 object_ref(OBJECT(dev
));
132 bus_remove_child(dev
->parent_bus
, dev
);
134 dev
->parent_bus
= bus
;
135 object_ref(OBJECT(bus
));
136 bus_add_child(bus
, dev
);
138 resettable_change_parent(OBJECT(dev
), OBJECT(bus
),
139 OBJECT(old_parent_bus
));
141 if (old_parent_bus
) {
142 object_unref(OBJECT(old_parent_bus
));
143 object_unref(OBJECT(dev
));
148 DeviceState
*qdev_new(const char *name
)
150 if (!object_class_by_name(name
)) {
151 module_load_qom_one(name
);
153 return DEVICE(object_new(name
));
156 DeviceState
*qdev_try_new(const char *name
)
158 if (!module_object_class_by_name(name
)) {
161 return DEVICE(object_new(name
));
164 static QTAILQ_HEAD(, DeviceListener
) device_listeners
165 = QTAILQ_HEAD_INITIALIZER(device_listeners
);
167 enum ListenerDirection
{ Forward
, Reverse
};
169 #define DEVICE_LISTENER_CALL(_callback, _direction, _args...) \
171 DeviceListener *_listener; \
173 switch (_direction) { \
175 QTAILQ_FOREACH(_listener, &device_listeners, link) { \
176 if (_listener->_callback) { \
177 _listener->_callback(_listener, ##_args); \
182 QTAILQ_FOREACH_REVERSE(_listener, &device_listeners, \
184 if (_listener->_callback) { \
185 _listener->_callback(_listener, ##_args); \
194 static int device_listener_add(DeviceState
*dev
, void *opaque
)
196 DEVICE_LISTENER_CALL(realize
, Forward
, dev
);
201 void device_listener_register(DeviceListener
*listener
)
203 QTAILQ_INSERT_TAIL(&device_listeners
, listener
, link
);
205 qbus_walk_children(sysbus_get_default(), NULL
, NULL
, device_listener_add
,
209 void device_listener_unregister(DeviceListener
*listener
)
211 QTAILQ_REMOVE(&device_listeners
, listener
, link
);
214 bool qdev_should_hide_device(const QDict
*opts
, bool from_json
, Error
**errp
)
217 DeviceListener
*listener
;
219 QTAILQ_FOREACH(listener
, &device_listeners
, link
) {
220 if (listener
->hide_device
) {
221 if (listener
->hide_device(listener
, opts
, from_json
, errp
)) {
232 void qdev_set_legacy_instance_id(DeviceState
*dev
, int alias_id
,
233 int required_for_version
)
235 assert(!dev
->realized
);
236 dev
->instance_id_alias
= alias_id
;
237 dev
->alias_required_for_version
= required_for_version
;
240 static int qdev_prereset(DeviceState
*dev
, void *opaque
)
242 trace_qdev_reset_tree(dev
, object_get_typename(OBJECT(dev
)));
246 static int qbus_prereset(BusState
*bus
, void *opaque
)
248 trace_qbus_reset_tree(bus
, object_get_typename(OBJECT(bus
)));
252 static int qdev_reset_one(DeviceState
*dev
, void *opaque
)
254 device_legacy_reset(dev
);
259 static int qbus_reset_one(BusState
*bus
, void *opaque
)
261 BusClass
*bc
= BUS_GET_CLASS(bus
);
262 trace_qbus_reset(bus
, object_get_typename(OBJECT(bus
)));
269 void qdev_reset_all(DeviceState
*dev
)
271 trace_qdev_reset_all(dev
, object_get_typename(OBJECT(dev
)));
272 qdev_walk_children(dev
, qdev_prereset
, qbus_prereset
,
273 qdev_reset_one
, qbus_reset_one
, NULL
);
276 void qdev_reset_all_fn(void *opaque
)
278 qdev_reset_all(DEVICE(opaque
));
281 void qbus_reset_all(BusState
*bus
)
283 trace_qbus_reset_all(bus
, object_get_typename(OBJECT(bus
)));
284 qbus_walk_children(bus
, qdev_prereset
, qbus_prereset
,
285 qdev_reset_one
, qbus_reset_one
, NULL
);
288 void qbus_reset_all_fn(void *opaque
)
290 BusState
*bus
= opaque
;
294 void device_cold_reset(DeviceState
*dev
)
296 resettable_reset(OBJECT(dev
), RESET_TYPE_COLD
);
299 bool device_is_in_reset(DeviceState
*dev
)
301 return resettable_is_in_reset(OBJECT(dev
));
304 static ResettableState
*device_get_reset_state(Object
*obj
)
306 DeviceState
*dev
= DEVICE(obj
);
310 static void device_reset_child_foreach(Object
*obj
, ResettableChildCallback cb
,
311 void *opaque
, ResetType type
)
313 DeviceState
*dev
= DEVICE(obj
);
316 QLIST_FOREACH(bus
, &dev
->child_bus
, sibling
) {
317 cb(OBJECT(bus
), opaque
, type
);
321 bool qdev_realize(DeviceState
*dev
, BusState
*bus
, Error
**errp
)
323 assert(!dev
->realized
&& !dev
->parent_bus
);
326 if (!qdev_set_parent_bus(dev
, bus
, errp
)) {
330 assert(!DEVICE_GET_CLASS(dev
)->bus_type
);
333 return object_property_set_bool(OBJECT(dev
), "realized", true, errp
);
336 bool qdev_realize_and_unref(DeviceState
*dev
, BusState
*bus
, Error
**errp
)
340 ret
= qdev_realize(dev
, bus
, errp
);
341 object_unref(OBJECT(dev
));
345 void qdev_unrealize(DeviceState
*dev
)
347 object_property_set_bool(OBJECT(dev
), "realized", false, &error_abort
);
350 static int qdev_assert_realized_properly_cb(Object
*obj
, void *opaque
)
352 DeviceState
*dev
= DEVICE(object_dynamic_cast(obj
, TYPE_DEVICE
));
356 dc
= DEVICE_GET_CLASS(dev
);
357 assert(dev
->realized
);
358 assert(dev
->parent_bus
|| !dc
->bus_type
);
363 void qdev_assert_realized_properly(void)
365 object_child_foreach_recursive(object_get_root(),
366 qdev_assert_realized_properly_cb
, NULL
);
369 bool qdev_machine_modified(void)
371 return qdev_hot_added
|| qdev_hot_removed
;
374 BusState
*qdev_get_parent_bus(DeviceState
*dev
)
376 return dev
->parent_bus
;
379 BusState
*qdev_get_child_bus(DeviceState
*dev
, const char *name
)
382 Object
*child
= object_resolve_path_component(OBJECT(dev
), name
);
384 bus
= (BusState
*)object_dynamic_cast(child
, TYPE_BUS
);
389 QLIST_FOREACH(bus
, &dev
->child_bus
, sibling
) {
390 if (strcmp(name
, bus
->name
) == 0) {
397 int qdev_walk_children(DeviceState
*dev
,
398 qdev_walkerfn
*pre_devfn
, qbus_walkerfn
*pre_busfn
,
399 qdev_walkerfn
*post_devfn
, qbus_walkerfn
*post_busfn
,
406 err
= pre_devfn(dev
, opaque
);
412 QLIST_FOREACH(bus
, &dev
->child_bus
, sibling
) {
413 err
= qbus_walk_children(bus
, pre_devfn
, pre_busfn
,
414 post_devfn
, post_busfn
, opaque
);
421 err
= post_devfn(dev
, opaque
);
430 DeviceState
*qdev_find_recursive(BusState
*bus
, const char *id
)
436 WITH_RCU_READ_LOCK_GUARD() {
437 QTAILQ_FOREACH_RCU(kid
, &bus
->children
, sibling
) {
438 DeviceState
*dev
= kid
->child
;
440 if (dev
->id
&& strcmp(dev
->id
, id
) == 0) {
444 QLIST_FOREACH(child
, &dev
->child_bus
, sibling
) {
445 ret
= qdev_find_recursive(child
, id
);
455 char *qdev_get_dev_path(DeviceState
*dev
)
459 if (!dev
|| !dev
->parent_bus
) {
463 bc
= BUS_GET_CLASS(dev
->parent_bus
);
464 if (bc
->get_dev_path
) {
465 return bc
->get_dev_path(dev
);
471 static bool device_get_realized(Object
*obj
, Error
**errp
)
473 DeviceState
*dev
= DEVICE(obj
);
474 return dev
->realized
;
477 static bool check_only_migratable(Object
*obj
, Error
**errp
)
479 DeviceClass
*dc
= DEVICE_GET_CLASS(obj
);
481 if (!vmstate_check_only_migratable(dc
->vmsd
)) {
482 error_setg(errp
, "Device %s is not migratable, but "
483 "--only-migratable was specified",
484 object_get_typename(obj
));
491 static void device_set_realized(Object
*obj
, bool value
, Error
**errp
)
493 DeviceState
*dev
= DEVICE(obj
);
494 DeviceClass
*dc
= DEVICE_GET_CLASS(dev
);
495 HotplugHandler
*hotplug_ctrl
;
498 Error
*local_err
= NULL
;
499 bool unattached_parent
= false;
500 static int unattached_count
;
502 if (dev
->hotplugged
&& !dc
->hotpluggable
) {
503 error_setg(errp
, QERR_DEVICE_NO_HOTPLUG
, object_get_typename(obj
));
507 if (value
&& !dev
->realized
) {
508 if (!check_only_migratable(obj
, errp
)) {
513 gchar
*name
= g_strdup_printf("device[%d]", unattached_count
++);
515 object_property_add_child(container_get(qdev_get_machine(),
518 unattached_parent
= true;
522 hotplug_ctrl
= qdev_get_hotplug_handler(dev
);
524 hotplug_handler_pre_plug(hotplug_ctrl
, dev
, &local_err
);
525 if (local_err
!= NULL
) {
531 dc
->realize(dev
, &local_err
);
532 if (local_err
!= NULL
) {
537 DEVICE_LISTENER_CALL(realize
, Forward
, dev
);
540 * always free/re-initialize here since the value cannot be cleaned up
541 * in device_unrealize due to its usage later on in the unplug path
543 g_free(dev
->canonical_path
);
544 dev
->canonical_path
= object_get_canonical_path(OBJECT(dev
));
545 QLIST_FOREACH(ncl
, &dev
->clocks
, node
) {
549 clock_setup_canonical_path(ncl
->clock
);
553 if (qdev_get_vmsd(dev
)) {
554 if (vmstate_register_with_alias_id(VMSTATE_IF(dev
),
555 VMSTATE_INSTANCE_ID_ANY
,
556 qdev_get_vmsd(dev
), dev
,
557 dev
->instance_id_alias
,
558 dev
->alias_required_for_version
,
560 goto post_realize_fail
;
565 * Clear the reset state, in case the object was previously unrealized
566 * with a dirty state.
568 resettable_state_clear(&dev
->reset
);
570 QLIST_FOREACH(bus
, &dev
->child_bus
, sibling
) {
571 if (!qbus_realize(bus
, errp
)) {
572 goto child_realize_fail
;
575 if (dev
->hotplugged
) {
577 * Reset the device, as well as its subtree which, at this point,
578 * should be realized too.
580 resettable_assert_reset(OBJECT(dev
), RESET_TYPE_COLD
);
581 resettable_change_parent(OBJECT(dev
), OBJECT(dev
->parent_bus
),
583 resettable_release_reset(OBJECT(dev
), RESET_TYPE_COLD
);
585 dev
->pending_deleted_event
= false;
588 hotplug_handler_plug(hotplug_ctrl
, dev
, &local_err
);
589 if (local_err
!= NULL
) {
590 goto child_realize_fail
;
594 qatomic_store_release(&dev
->realized
, value
);
596 } else if (!value
&& dev
->realized
) {
599 * Change the value so that any concurrent users are aware
600 * that the device is going to be unrealized
602 * TODO: change .realized property to enum that states
603 * each phase of the device realization/unrealization
606 qatomic_set(&dev
->realized
, value
);
608 * Ensure that concurrent users see this update prior to
609 * any other changes done by unrealize.
613 QLIST_FOREACH(bus
, &dev
->child_bus
, sibling
) {
616 if (qdev_get_vmsd(dev
)) {
617 vmstate_unregister(VMSTATE_IF(dev
), qdev_get_vmsd(dev
), dev
);
622 dev
->pending_deleted_event
= true;
623 DEVICE_LISTENER_CALL(unrealize
, Reverse
, dev
);
626 assert(local_err
== NULL
);
630 QLIST_FOREACH(bus
, &dev
->child_bus
, sibling
) {
634 if (qdev_get_vmsd(dev
)) {
635 vmstate_unregister(VMSTATE_IF(dev
), qdev_get_vmsd(dev
), dev
);
639 g_free(dev
->canonical_path
);
640 dev
->canonical_path
= NULL
;
646 error_propagate(errp
, local_err
);
647 if (unattached_parent
) {
649 * Beware, this doesn't just revert
650 * object_property_add_child(), it also runs bus_remove()!
652 object_unparent(OBJECT(dev
));
657 static bool device_get_hotpluggable(Object
*obj
, Error
**errp
)
659 DeviceClass
*dc
= DEVICE_GET_CLASS(obj
);
660 DeviceState
*dev
= DEVICE(obj
);
662 return dc
->hotpluggable
&& (dev
->parent_bus
== NULL
||
663 qbus_is_hotpluggable(dev
->parent_bus
));
666 static bool device_get_hotplugged(Object
*obj
, Error
**errp
)
668 DeviceState
*dev
= DEVICE(obj
);
670 return dev
->hotplugged
;
673 static void device_initfn(Object
*obj
)
675 DeviceState
*dev
= DEVICE(obj
);
677 if (phase_check(PHASE_MACHINE_READY
)) {
679 qdev_hot_added
= true;
682 dev
->instance_id_alias
= -1;
683 dev
->realized
= false;
684 dev
->allow_unplug_during_migration
= false;
686 QLIST_INIT(&dev
->gpios
);
687 QLIST_INIT(&dev
->clocks
);
690 static void device_post_init(Object
*obj
)
693 * Note: ordered so that the user's global properties take
696 object_apply_compat_props(obj
);
697 qdev_prop_set_globals(DEVICE(obj
));
700 /* Unlink device from bus and free the structure. */
701 static void device_finalize(Object
*obj
)
703 NamedGPIOList
*ngl
, *next
;
705 DeviceState
*dev
= DEVICE(obj
);
707 QLIST_FOREACH_SAFE(ngl
, &dev
->gpios
, node
, next
) {
708 QLIST_REMOVE(ngl
, node
);
709 qemu_free_irqs(ngl
->in
, ngl
->num_in
);
712 /* ngl->out irqs are owned by the other end and should not be freed
717 qdev_finalize_clocklist(dev
);
719 /* Only send event if the device had been completely realized */
720 if (dev
->pending_deleted_event
) {
721 g_assert(dev
->canonical_path
);
723 qapi_event_send_device_deleted(!!dev
->id
, dev
->id
, dev
->canonical_path
);
724 g_free(dev
->canonical_path
);
725 dev
->canonical_path
= NULL
;
728 qobject_unref(dev
->opts
);
732 static void device_class_base_init(ObjectClass
*class, void *data
)
734 DeviceClass
*klass
= DEVICE_CLASS(class);
736 /* We explicitly look up properties in the superclasses,
737 * so do not propagate them to the subclasses.
739 klass
->props_
= NULL
;
742 static void device_unparent(Object
*obj
)
744 DeviceState
*dev
= DEVICE(obj
);
750 while (dev
->num_child_bus
) {
751 bus
= QLIST_FIRST(&dev
->child_bus
);
752 object_unparent(OBJECT(bus
));
754 if (dev
->parent_bus
) {
755 bus_remove_child(dev
->parent_bus
, dev
);
756 object_unref(OBJECT(dev
->parent_bus
));
757 dev
->parent_bus
= NULL
;
762 device_vmstate_if_get_id(VMStateIf
*obj
)
764 DeviceState
*dev
= DEVICE(obj
);
766 return qdev_get_dev_path(dev
);
770 * device_phases_reset:
771 * Transition reset method for devices to allow moving
772 * smoothly from legacy reset method to multi-phases
774 static void device_phases_reset(DeviceState
*dev
)
776 ResettableClass
*rc
= RESETTABLE_GET_CLASS(dev
);
778 if (rc
->phases
.enter
) {
779 rc
->phases
.enter(OBJECT(dev
), RESET_TYPE_COLD
);
781 if (rc
->phases
.hold
) {
782 rc
->phases
.hold(OBJECT(dev
));
784 if (rc
->phases
.exit
) {
785 rc
->phases
.exit(OBJECT(dev
));
789 static void device_transitional_reset(Object
*obj
)
791 DeviceClass
*dc
= DEVICE_GET_CLASS(obj
);
794 * This will call either @device_phases_reset (for multi-phases transitioned
795 * devices) or a device's specific method for not-yet transitioned devices.
796 * In both case, it does not reset children.
799 dc
->reset(DEVICE(obj
));
804 * device_get_transitional_reset:
805 * check if the device's class is ready for multi-phase
807 static ResettableTrFunction
device_get_transitional_reset(Object
*obj
)
809 DeviceClass
*dc
= DEVICE_GET_CLASS(obj
);
810 if (dc
->reset
!= device_phases_reset
) {
812 * dc->reset has been overridden by a subclass,
813 * the device is not ready for multi phase yet.
815 return device_transitional_reset
;
820 static void device_class_init(ObjectClass
*class, void *data
)
822 DeviceClass
*dc
= DEVICE_CLASS(class);
823 VMStateIfClass
*vc
= VMSTATE_IF_CLASS(class);
824 ResettableClass
*rc
= RESETTABLE_CLASS(class);
826 class->unparent
= device_unparent
;
828 /* by default all devices were considered as hotpluggable,
829 * so with intent to check it in generic qdev_unplug() /
830 * device_set_realized() functions make every device
831 * hotpluggable. Devices that shouldn't be hotpluggable,
832 * should override it in their class_init()
834 dc
->hotpluggable
= true;
835 dc
->user_creatable
= true;
836 vc
->get_id
= device_vmstate_if_get_id
;
837 rc
->get_state
= device_get_reset_state
;
838 rc
->child_foreach
= device_reset_child_foreach
;
841 * @device_phases_reset is put as the default reset method below, allowing
842 * to do the multi-phase transition from base classes to leaf classes. It
843 * allows a legacy-reset Device class to extend a multi-phases-reset
844 * Device class for the following reason:
845 * + If a base class B has been moved to multi-phase, then it does not
846 * override this default reset method and may have defined phase methods.
847 * + A child class C (extending class B) which uses
848 * device_class_set_parent_reset() (or similar means) to override the
849 * reset method will still work as expected. @device_phases_reset function
850 * will be registered as the parent reset method and effectively call
851 * parent reset phases.
853 dc
->reset
= device_phases_reset
;
854 rc
->get_transitional_function
= device_get_transitional_reset
;
856 object_class_property_add_bool(class, "realized",
857 device_get_realized
, device_set_realized
);
858 object_class_property_add_bool(class, "hotpluggable",
859 device_get_hotpluggable
, NULL
);
860 object_class_property_add_bool(class, "hotplugged",
861 device_get_hotplugged
, NULL
);
862 object_class_property_add_link(class, "parent_bus", TYPE_BUS
,
863 offsetof(DeviceState
, parent_bus
), NULL
, 0);
866 void device_class_set_parent_reset(DeviceClass
*dc
,
867 DeviceReset dev_reset
,
868 DeviceReset
*parent_reset
)
870 *parent_reset
= dc
->reset
;
871 dc
->reset
= dev_reset
;
874 void device_class_set_parent_realize(DeviceClass
*dc
,
875 DeviceRealize dev_realize
,
876 DeviceRealize
*parent_realize
)
878 *parent_realize
= dc
->realize
;
879 dc
->realize
= dev_realize
;
882 void device_class_set_parent_unrealize(DeviceClass
*dc
,
883 DeviceUnrealize dev_unrealize
,
884 DeviceUnrealize
*parent_unrealize
)
886 *parent_unrealize
= dc
->unrealize
;
887 dc
->unrealize
= dev_unrealize
;
890 void device_legacy_reset(DeviceState
*dev
)
892 DeviceClass
*klass
= DEVICE_GET_CLASS(dev
);
894 trace_qdev_reset(dev
, object_get_typename(OBJECT(dev
)));
900 Object
*qdev_get_machine(void)
905 dev
= container_get(object_get_root(), "/machine");
911 static MachineInitPhase machine_phase
;
913 bool phase_check(MachineInitPhase phase
)
915 return machine_phase
>= phase
;
918 void phase_advance(MachineInitPhase phase
)
920 assert(machine_phase
== phase
- 1);
921 machine_phase
= phase
;
924 static const TypeInfo device_type_info
= {
926 .parent
= TYPE_OBJECT
,
927 .instance_size
= sizeof(DeviceState
),
928 .instance_init
= device_initfn
,
929 .instance_post_init
= device_post_init
,
930 .instance_finalize
= device_finalize
,
931 .class_base_init
= device_class_base_init
,
932 .class_init
= device_class_init
,
934 .class_size
= sizeof(DeviceClass
),
935 .interfaces
= (InterfaceInfo
[]) {
937 { TYPE_RESETTABLE_INTERFACE
},
942 static void qdev_register_types(void)
944 type_register_static(&device_type_info
);
947 type_init(qdev_register_types
)