]> git.proxmox.com Git - mirror_qemu.git/blob - hw/qdev.h
qdev: kill off DeviceInfo
[mirror_qemu.git] / hw / qdev.h
1 #ifndef QDEV_H
2 #define QDEV_H
3
4 #include "hw.h"
5 #include "qemu-queue.h"
6 #include "qemu-char.h"
7 #include "qemu-option.h"
8 #include "qapi/qapi-visit-core.h"
9 #include "qemu/object.h"
10
11 typedef struct Property Property;
12
13 typedef struct PropertyInfo PropertyInfo;
14
15 typedef struct CompatProperty CompatProperty;
16
17 typedef struct BusState BusState;
18
19 typedef struct BusInfo BusInfo;
20
21 enum DevState {
22 DEV_STATE_CREATED = 1,
23 DEV_STATE_INITIALIZED,
24 };
25
26 enum {
27 DEV_NVECTORS_UNSPECIFIED = -1,
28 };
29
30 /**
31 * @DevicePropertyAccessor - called when trying to get/set a property
32 *
33 * @dev the device that owns the property
34 * @v the visitor that contains the property data
35 * @opaque the device property opaque
36 * @name the name of the property
37 * @errp a pointer to an Error that is filled if getting/setting fails.
38 */
39 typedef void (DevicePropertyAccessor)(DeviceState *dev,
40 Visitor *v,
41 void *opaque,
42 const char *name,
43 Error **errp);
44
45 /**
46 * @DevicePropertyRelease - called when a property is removed from a device
47 *
48 * @dev the device that owns the property
49 * @name the name of the property
50 * @opaque the opaque registered with the property
51 */
52 typedef void (DevicePropertyRelease)(DeviceState *dev,
53 const char *name,
54 void *opaque);
55
56 typedef struct DeviceProperty
57 {
58 gchar *name;
59 gchar *type;
60 DevicePropertyAccessor *get;
61 DevicePropertyAccessor *set;
62 DevicePropertyRelease *release;
63 void *opaque;
64
65 QTAILQ_ENTRY(DeviceProperty) node;
66 } DeviceProperty;
67
68 #define TYPE_DEVICE "device"
69 #define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)
70 #define DEVICE_CLASS(klass) OBJECT_CLASS_CHECK(DeviceClass, (klass), TYPE_DEVICE)
71 #define DEVICE_GET_CLASS(obj) OBJECT_GET_CLASS(DeviceClass, (obj), TYPE_DEVICE)
72
73 typedef int (*qdev_initfn)(DeviceState *dev);
74 typedef int (*qdev_event)(DeviceState *dev);
75 typedef void (*qdev_resetfn)(DeviceState *dev);
76
77 typedef struct DeviceClass {
78 ObjectClass parent_class;
79
80 const char *fw_name;
81 const char *alias;
82 const char *desc;
83 Property *props;
84 int no_user;
85
86 /* callbacks */
87 void (*reset)(DeviceState *dev);
88
89 /* device state */
90 const VMStateDescription *vmsd;
91
92 /* Private to qdev / bus. */
93 qdev_initfn init;
94 qdev_event unplug;
95 qdev_event exit;
96 BusInfo *bus_info;
97 } DeviceClass;
98
99 /* This structure should not be accessed directly. We declare it here
100 so that it can be embedded in individual device state structures. */
101 struct DeviceState {
102 Object parent_obj;
103
104 const char *id;
105 enum DevState state;
106 QemuOpts *opts;
107 int hotplugged;
108 BusState *parent_bus;
109 int num_gpio_out;
110 qemu_irq *gpio_out;
111 int num_gpio_in;
112 qemu_irq *gpio_in;
113 QLIST_HEAD(, BusState) child_bus;
114 int num_child_bus;
115 QTAILQ_ENTRY(DeviceState) sibling;
116 int instance_id_alias;
117 int alias_required_for_version;
118
119 /**
120 * This tracks the number of references between devices. See @qdev_ref for
121 * more information.
122 */
123 uint32_t ref;
124
125 QTAILQ_HEAD(, DeviceProperty) properties;
126
127 /* Do not, under any circumstance, use this parent link below anywhere
128 * outside of qdev.c. You have been warned. */
129 DeviceState *parent;
130 };
131
132 typedef void (*bus_dev_printfn)(Monitor *mon, DeviceState *dev, int indent);
133 typedef char *(*bus_get_dev_path)(DeviceState *dev);
134 /*
135 * This callback is used to create Open Firmware device path in accordance with
136 * OF spec http://forthworks.com/standards/of1275.pdf. Indicidual bus bindings
137 * can be found here http://playground.sun.com/1275/bindings/.
138 */
139 typedef char *(*bus_get_fw_dev_path)(DeviceState *dev);
140 typedef int (qbus_resetfn)(BusState *bus);
141
142 struct BusInfo {
143 const char *name;
144 size_t size;
145 bus_dev_printfn print_dev;
146 bus_get_dev_path get_dev_path;
147 bus_get_fw_dev_path get_fw_dev_path;
148 qbus_resetfn *reset;
149 Property *props;
150 };
151
152 struct BusState {
153 DeviceState *parent;
154 BusInfo *info;
155 const char *name;
156 int allow_hotplug;
157 int qdev_allocated;
158 QTAILQ_HEAD(ChildrenHead, DeviceState) children;
159 QLIST_ENTRY(BusState) sibling;
160 };
161
162 struct Property {
163 const char *name;
164 PropertyInfo *info;
165 int offset;
166 int bitnr;
167 void *defval;
168 };
169
170 enum PropertyType {
171 PROP_TYPE_UNSPEC = 0,
172 PROP_TYPE_UINT8,
173 PROP_TYPE_UINT16,
174 PROP_TYPE_UINT32,
175 PROP_TYPE_INT32,
176 PROP_TYPE_UINT64,
177 PROP_TYPE_TADDR,
178 PROP_TYPE_MACADDR,
179 PROP_TYPE_LOSTTICKPOLICY,
180 PROP_TYPE_DRIVE,
181 PROP_TYPE_CHR,
182 PROP_TYPE_STRING,
183 PROP_TYPE_NETDEV,
184 PROP_TYPE_VLAN,
185 PROP_TYPE_PTR,
186 PROP_TYPE_BIT,
187 };
188
189 struct PropertyInfo {
190 const char *name;
191 const char *legacy_name;
192 size_t size;
193 enum PropertyType type;
194 int64_t min;
195 int64_t max;
196 int (*parse)(DeviceState *dev, Property *prop, const char *str);
197 int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
198 void (*free)(DeviceState *dev, Property *prop);
199 DevicePropertyAccessor *get;
200 DevicePropertyAccessor *set;
201 };
202
203 typedef struct GlobalProperty {
204 const char *driver;
205 const char *property;
206 const char *value;
207 QTAILQ_ENTRY(GlobalProperty) next;
208 } GlobalProperty;
209
210 /*** Board API. This should go away once we have a machine config file. ***/
211
212 DeviceState *qdev_create(BusState *bus, const char *name);
213 DeviceState *qdev_try_create(BusState *bus, const char *name);
214 bool qdev_exists(const char *name);
215 int qdev_device_help(QemuOpts *opts);
216 DeviceState *qdev_device_add(QemuOpts *opts);
217 int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT;
218 void qdev_init_nofail(DeviceState *dev);
219 void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
220 int required_for_version);
221 int qdev_unplug(DeviceState *dev);
222 void qdev_free(DeviceState *dev);
223 int qdev_simple_unplug_cb(DeviceState *dev);
224 void qdev_machine_creation_done(void);
225 bool qdev_machine_modified(void);
226
227 qemu_irq qdev_get_gpio_in(DeviceState *dev, int n);
228 void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin);
229
230 BusState *qdev_get_child_bus(DeviceState *dev, const char *name);
231
232 /*** Device API. ***/
233
234 /* Register device properties. */
235 /* GPIO inputs also double as IRQ sinks. */
236 void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n);
237 void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
238
239 CharDriverState *qdev_init_chardev(DeviceState *dev);
240
241 BusState *qdev_get_parent_bus(DeviceState *dev);
242
243 /*** BUS API. ***/
244
245 DeviceState *qdev_find_recursive(BusState *bus, const char *id);
246
247 /* Returns 0 to walk children, > 0 to skip walk, < 0 to terminate walk. */
248 typedef int (qbus_walkerfn)(BusState *bus, void *opaque);
249 typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque);
250
251 void qbus_create_inplace(BusState *bus, BusInfo *info,
252 DeviceState *parent, const char *name);
253 BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name);
254 /* Returns > 0 if either devfn or busfn skip walk somewhere in cursion,
255 * < 0 if either devfn or busfn terminate walk somewhere in cursion,
256 * 0 otherwise. */
257 int qbus_walk_children(BusState *bus, qdev_walkerfn *devfn,
258 qbus_walkerfn *busfn, void *opaque);
259 int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn,
260 qbus_walkerfn *busfn, void *opaque);
261 void qdev_reset_all(DeviceState *dev);
262 void qbus_reset_all_fn(void *opaque);
263
264 void qbus_free(BusState *bus);
265
266 #define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev)
267
268 /* This should go away once we get rid of the NULL bus hack */
269 BusState *sysbus_get_default(void);
270
271 /*** monitor commands ***/
272
273 void do_info_qtree(Monitor *mon);
274 void do_info_qdm(Monitor *mon);
275 int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
276 int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
277
278 /*** qdev-properties.c ***/
279
280 extern PropertyInfo qdev_prop_bit;
281 extern PropertyInfo qdev_prop_uint8;
282 extern PropertyInfo qdev_prop_uint16;
283 extern PropertyInfo qdev_prop_uint32;
284 extern PropertyInfo qdev_prop_int32;
285 extern PropertyInfo qdev_prop_uint64;
286 extern PropertyInfo qdev_prop_hex8;
287 extern PropertyInfo qdev_prop_hex32;
288 extern PropertyInfo qdev_prop_hex64;
289 extern PropertyInfo qdev_prop_string;
290 extern PropertyInfo qdev_prop_chr;
291 extern PropertyInfo qdev_prop_ptr;
292 extern PropertyInfo qdev_prop_macaddr;
293 extern PropertyInfo qdev_prop_losttickpolicy;
294 extern PropertyInfo qdev_prop_drive;
295 extern PropertyInfo qdev_prop_netdev;
296 extern PropertyInfo qdev_prop_vlan;
297 extern PropertyInfo qdev_prop_pci_devfn;
298
299 #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
300 .name = (_name), \
301 .info = &(_prop), \
302 .offset = offsetof(_state, _field) \
303 + type_check(_type,typeof_field(_state, _field)), \
304 }
305 #define DEFINE_PROP_DEFAULT(_name, _state, _field, _defval, _prop, _type) { \
306 .name = (_name), \
307 .info = &(_prop), \
308 .offset = offsetof(_state, _field) \
309 + type_check(_type,typeof_field(_state, _field)), \
310 .defval = (_type[]) { _defval }, \
311 }
312 #define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \
313 .name = (_name), \
314 .info = &(qdev_prop_bit), \
315 .bitnr = (_bit), \
316 .offset = offsetof(_state, _field) \
317 + type_check(uint32_t,typeof_field(_state, _field)), \
318 .defval = (bool[]) { (_defval) }, \
319 }
320
321 #define DEFINE_PROP_UINT8(_n, _s, _f, _d) \
322 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
323 #define DEFINE_PROP_UINT16(_n, _s, _f, _d) \
324 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
325 #define DEFINE_PROP_UINT32(_n, _s, _f, _d) \
326 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
327 #define DEFINE_PROP_INT32(_n, _s, _f, _d) \
328 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t)
329 #define DEFINE_PROP_UINT64(_n, _s, _f, _d) \
330 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
331 #define DEFINE_PROP_HEX8(_n, _s, _f, _d) \
332 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex8, uint8_t)
333 #define DEFINE_PROP_HEX32(_n, _s, _f, _d) \
334 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex32, uint32_t)
335 #define DEFINE_PROP_HEX64(_n, _s, _f, _d) \
336 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex64, uint64_t)
337 #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \
338 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, uint32_t)
339
340 #define DEFINE_PROP_PTR(_n, _s, _f) \
341 DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
342 #define DEFINE_PROP_CHR(_n, _s, _f) \
343 DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
344 #define DEFINE_PROP_STRING(_n, _s, _f) \
345 DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*)
346 #define DEFINE_PROP_NETDEV(_n, _s, _f) \
347 DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState*)
348 #define DEFINE_PROP_VLAN(_n, _s, _f) \
349 DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, VLANState*)
350 #define DEFINE_PROP_DRIVE(_n, _s, _f) \
351 DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockDriverState *)
352 #define DEFINE_PROP_MACADDR(_n, _s, _f) \
353 DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr)
354 #define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \
355 DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_losttickpolicy, \
356 LostTickPolicy)
357
358 #define DEFINE_PROP_END_OF_LIST() \
359 {}
360
361 /* Set properties between creation and init. */
362 void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
363 int qdev_prop_exists(DeviceState *dev, const char *name);
364 int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);
365 void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type);
366 void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value);
367 void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value);
368 void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value);
369 void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value);
370 void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value);
371 void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
372 void qdev_prop_set_string(DeviceState *dev, const char *name, char *value);
373 void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
374 void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value);
375 void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value);
376 int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) QEMU_WARN_UNUSED_RESULT;
377 void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverState *value);
378 void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value);
379 void qdev_prop_set_losttickpolicy(DeviceState *dev, const char *name,
380 LostTickPolicy *value);
381 /* FIXME: Remove opaque pointer properties. */
382 void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
383 void qdev_prop_set_defaults(DeviceState *dev, Property *props);
384
385 void qdev_prop_register_global_list(GlobalProperty *props);
386 void qdev_prop_set_globals(DeviceState *dev);
387 void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
388 Property *prop, const char *value);
389
390 char *qdev_get_fw_dev_path(DeviceState *dev);
391
392 /* This is a nasty hack to allow passing a NULL bus to qdev_create. */
393 extern struct BusInfo system_bus_info;
394
395 /**
396 * @qdev_ref
397 *
398 * Increase the reference count of a device. A device cannot be freed as long
399 * as its reference count is greater than zero.
400 *
401 * @dev - the device
402 */
403 void qdev_ref(DeviceState *dev);
404
405 /**
406 * @qdef_unref
407 *
408 * Decrease the reference count of a device. A device cannot be freed as long
409 * as its reference count is greater than zero.
410 *
411 * @dev - the device
412 */
413 void qdev_unref(DeviceState *dev);
414
415 /**
416 * @qdev_property_add - add a new property to a device
417 *
418 * @dev - the device to add a property to
419 *
420 * @name - the name of the property. This can contain any character except for
421 * a forward slash. In general, you should use hyphens '-' instead of
422 * underscores '_' when naming properties.
423 *
424 * @type - the type name of the property. This namespace is pretty loosely
425 * defined. Sub namespaces are constructed by using a prefix and then
426 * to angle brackets. For instance, the type 'virtio-net-pci' in the
427 * 'link' namespace would be 'link<virtio-net-pci>'.
428 *
429 * @get - the getter to be called to read a property. If this is NULL, then
430 * the property cannot be read.
431 *
432 * @set - the setter to be called to write a property. If this is NULL,
433 * then the property cannot be written.
434 *
435 * @release - called when the property is removed from the device. This is
436 * meant to allow a property to free its opaque upon device
437 * destruction. This may be NULL.
438 *
439 * @opaque - an opaque pointer to pass to the callbacks for the property
440 *
441 * @errp - returns an error if this function fails
442 */
443 void qdev_property_add(DeviceState *dev, const char *name, const char *type,
444 DevicePropertyAccessor *get, DevicePropertyAccessor *set,
445 DevicePropertyRelease *release,
446 void *opaque, Error **errp);
447
448 /**
449 * @qdev_property_get - reads a property from a device
450 *
451 * @dev - the device
452 *
453 * @v - the visitor that will receive the property value. This should be an
454 * Output visitor and the data will be written with @name as the name.
455 *
456 * @name - the name of the property
457 *
458 * @errp - returns an error if this function fails
459 */
460 void qdev_property_get(DeviceState *dev, Visitor *v, const char *name,
461 Error **errp);
462
463 /**
464 * @qdev_property_set - writes a property to a device
465 *
466 * @dev - the device
467 *
468 * @v - the visitor that will be used to write the property value. This should
469 * be an Input visitor and the data will be first read with @name as the
470 * name and then written as the property value.
471 *
472 * @name - the name of the property
473 *
474 * @errp - returns an error if this function fails
475 */
476 void qdev_property_set(DeviceState *dev, Visitor *v, const char *name,
477 Error **errp);
478
479 /**
480 * @qdev_property_get_type - returns the type of a property
481 *
482 * @dev - the device
483 *
484 * @name - the name of the property
485 *
486 * @errp - returns an error if this function fails
487 *
488 * Returns:
489 * The type name of the property.
490 */
491 const char *qdev_property_get_type(DeviceState *dev, const char *name,
492 Error **errp);
493
494 /**
495 * @qdev_property_add_static - add a @Property to a device referencing a
496 * field in a struct.
497 */
498 void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp);
499
500 /**
501 * @qdev_get_root - returns the root device of the composition tree
502 *
503 * Returns:
504 * The root of the composition tree.
505 */
506 DeviceState *qdev_get_root(void);
507
508 /**
509 * @qdev_get_canonical_path - returns the canonical path for a device. This
510 * is the path within the composition tree starting from the root.
511 *
512 * Returns:
513 * The canonical path in the composition tree.
514 */
515 gchar *qdev_get_canonical_path(DeviceState *dev);
516
517 /**
518 * @qdev_resolve_path - resolves a path returning a device
519 *
520 * There are two types of supported paths--absolute paths and partial paths.
521 *
522 * Absolute paths are derived from the root device and can follow child<> or
523 * link<> properties. Since they can follow link<> properties, they can be
524 * arbitrarily long. Absolute paths look like absolute filenames and are
525 * prefixed with a leading slash.
526 *
527 * Partial paths look like relative filenames. They do not begin with a
528 * prefix. The matching rules for partial paths are subtle but designed to make
529 * specifying devices easy. At each level of the composition tree, the partial
530 * path is matched as an absolute path. The first match is not returned. At
531 * least two matches are searched for. A successful result is only returned if
532 * only one match is founded. If more than one match is found, a flag is
533 * return to indicate that the match was ambiguous.
534 *
535 * @path - the path to resolve
536 *
537 * @ambiguous - returns true if the path resolution failed because of an
538 * ambiguous match
539 *
540 * Returns:
541 * The matched device or NULL on path lookup failure.
542 */
543 DeviceState *qdev_resolve_path(const char *path, bool *ambiguous);
544
545 /**
546 * @qdev_property_add_child - Add a child property to a device
547 *
548 * Child properties form the composition tree. All devices need to be a child
549 * of another device. Devices can only be a child of one device.
550 *
551 * There is no way for a child to determine what its parent is. It is not
552 * a bidirectional relationship. This is by design.
553 *
554 * @dev - the device to add a property to
555 *
556 * @name - the name of the property
557 *
558 * @child - the child device
559 *
560 * @errp - if an error occurs, a pointer to an area to store the area
561 */
562 void qdev_property_add_child(DeviceState *dev, const char *name,
563 DeviceState *child, Error **errp);
564
565 /**
566 * @qdev_property_add_link - Add a link property to a device
567 *
568 * Links establish relationships between devices. Links are unidirectional
569 * although two links can be combined to form a bidirectional relationship
570 * between devices.
571 *
572 * Links form the graph in the device model.
573 *
574 * @dev - the device to add a property to
575 *
576 * @name - the name of the property
577 *
578 * @type - the qdev type of the link
579 *
580 * @child - a pointer to where the link device reference is stored
581 *
582 * @errp - if an error occurs, a pointer to an area to store the area
583 */
584 void qdev_property_add_link(DeviceState *dev, const char *name,
585 const char *type, DeviceState **child,
586 Error **errp);
587
588 /**
589 * @qdev_property_add_str
590 *
591 * Add a string property using getters/setters. This function will add a
592 * property of type 'string'.
593 *
594 * @dev - the device to add a property to
595 *
596 * @name - the name of the property
597 *
598 * @get - the getter or NULL if the property is write-only. This function must
599 * return a string to be freed by @g_free().
600 *
601 * @set - the setter or NULL if the property is read-only
602 *
603 * @errp - if an error occurs, a pointer to an area to store the error
604 */
605 void qdev_property_add_str(DeviceState *dev, const char *name,
606 char *(*get)(DeviceState *, Error **),
607 void (*set)(DeviceState *, const char *, Error **),
608 Error **errp);
609
610 /**
611 * @qdev_get_type
612 *
613 * Returns the string representation of the type of this object.
614 *
615 * @dev - the device
616 *
617 * @errp - if an error occurs, a pointer to an area to store the error
618 *
619 * Returns: a string representing the type. This must be freed by the caller
620 * with g_free().
621 */
622 char *qdev_get_type(DeviceState *dev, Error **errp);
623
624 /**
625 * @qdev_machine_init
626 *
627 * Initialize platform devices before machine init. This is a hack until full
628 * support for composition is added.
629 */
630 void qdev_machine_init(void);
631
632 /**
633 * @device_reset
634 *
635 * Reset a single device (by calling the reset method).
636 */
637 void device_reset(DeviceState *dev);
638
639 const VMStateDescription *qdev_get_vmsd(DeviceState *dev);
640
641 const char *qdev_fw_name(DeviceState *dev);
642
643 BusInfo *qdev_get_bus_info(DeviceState *dev);
644
645 Property *qdev_get_props(DeviceState *dev);
646
647 #endif