blob: 97a9665424dbd42d7dba9924dfc5e6fdce3d9571 [file] [log] [blame]
Paul Brookaae94602009-05-14 22:35:06 +01001/*
2 * Dynamic device configuration and creation.
3 *
4 * Copyright (c) 2009 CodeSourcery
5 *
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 of the License, or (at your option) any later version.
10 *
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.
15 *
16 * You should have received a copy of the GNU Lesser General Public
Blue Swirl8167ee82009-07-16 20:47:01 +000017 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
Paul Brookaae94602009-05-14 22:35:06 +010018 */
19
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
26 this API directly. */
27
Paul Brook9d07d752009-05-14 22:35:07 +010028#include "net.h"
Paul Brookaae94602009-05-14 22:35:06 +010029#include "qdev.h"
30#include "sysemu.h"
Gerd Hoffmanncae49562009-06-05 15:53:17 +010031#include "monitor.h"
Paul Brookaae94602009-05-14 22:35:06 +010032
Paul Brook02e2da42009-05-23 00:05:19 +010033/* This is a nasty hack to allow passing a NULL bus to qdev_create. */
Blue Swirlb9aaf7f2009-06-09 18:38:51 +000034static BusState *main_system_bus;
Paul Brook4d6ae672009-05-14 22:35:06 +010035
Gerd Hoffmann042f84d2009-06-30 14:12:09 +020036static DeviceInfo *device_info_list;
Paul Brookaae94602009-05-14 22:35:06 +010037
Gerd Hoffmann8ffb1bc2009-07-15 13:59:25 +020038static BusState *qbus_find_recursive(BusState *bus, const char *name,
39 const BusInfo *info);
40static BusState *qbus_find(const char *path);
41
Paul Brookaae94602009-05-14 22:35:06 +010042/* Register a new device type. */
Gerd Hoffmann074f2ff2009-06-10 09:41:42 +020043void qdev_register(DeviceInfo *info)
Paul Brookaae94602009-05-14 22:35:06 +010044{
Gerd Hoffmann074f2ff2009-06-10 09:41:42 +020045 assert(info->size >= sizeof(DeviceState));
Gerd Hoffmann042f84d2009-06-30 14:12:09 +020046 assert(!info->next);
Paul Brookaae94602009-05-14 22:35:06 +010047
Gerd Hoffmann042f84d2009-06-30 14:12:09 +020048 info->next = device_info_list;
49 device_info_list = info;
Paul Brookaae94602009-05-14 22:35:06 +010050}
51
Gerd Hoffmann81ebb982009-07-15 13:43:32 +020052static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name)
53{
54 DeviceInfo *info;
55
Gerd Hoffmann3320e562009-07-15 13:43:33 +020056 /* first check device names */
Gerd Hoffmann81ebb982009-07-15 13:43:32 +020057 for (info = device_info_list; info != NULL; info = info->next) {
58 if (bus_info && info->bus_info != bus_info)
59 continue;
60 if (strcmp(info->name, name) != 0)
61 continue;
62 return info;
63 }
Gerd Hoffmann3320e562009-07-15 13:43:33 +020064
65 /* failing that check the aliases */
66 for (info = device_info_list; info != NULL; info = info->next) {
67 if (bus_info && info->bus_info != bus_info)
68 continue;
69 if (!info->alias)
70 continue;
71 if (strcmp(info->alias, name) != 0)
72 continue;
73 return info;
74 }
Gerd Hoffmann81ebb982009-07-15 13:43:32 +020075 return NULL;
76}
77
Paul Brookaae94602009-05-14 22:35:06 +010078/* Create a new device. This only initializes the device state structure
79 and allows properties to be set. qdev_init should be called to
80 initialize the actual device emulation. */
Paul Brook02e2da42009-05-23 00:05:19 +010081DeviceState *qdev_create(BusState *bus, const char *name)
Paul Brookaae94602009-05-14 22:35:06 +010082{
Gerd Hoffmann042f84d2009-06-30 14:12:09 +020083 DeviceInfo *info;
Paul Brookaae94602009-05-14 22:35:06 +010084 DeviceState *dev;
85
Gerd Hoffmann10c4c982009-06-30 14:12:08 +020086 if (!bus) {
87 if (!main_system_bus) {
88 main_system_bus = qbus_create(&system_bus_info, NULL, "main-system-bus");
Paul Brookaae94602009-05-14 22:35:06 +010089 }
Gerd Hoffmann10c4c982009-06-30 14:12:08 +020090 bus = main_system_bus;
91 }
92
Gerd Hoffmann81ebb982009-07-15 13:43:32 +020093 info = qdev_find_info(bus->info, name);
Gerd Hoffmann042f84d2009-06-30 14:12:09 +020094 if (!info) {
Gerd Hoffmann10c4c982009-06-30 14:12:08 +020095 hw_error("Unknown device '%s' for bus '%s'\n", name, bus->info->name);
Paul Brookaae94602009-05-14 22:35:06 +010096 }
97
Gerd Hoffmann042f84d2009-06-30 14:12:09 +020098 dev = qemu_mallocz(info->size);
99 dev->info = info;
Paul Brook02e2da42009-05-23 00:05:19 +0100100 dev->parent_bus = bus;
Gerd Hoffmannee6847d2009-07-15 13:43:31 +0200101 qdev_prop_set_defaults(dev, dev->info->props);
102 qdev_prop_set_defaults(dev, dev->parent_bus->info->props);
Gerd Hoffmannb6b61142009-07-15 13:48:21 +0200103 qdev_prop_set_compat(dev);
Paul Brook02e2da42009-05-23 00:05:19 +0100104 LIST_INSERT_HEAD(&bus->children, dev, sibling);
Paul Brookaae94602009-05-14 22:35:06 +0100105 return dev;
106}
107
Gerd Hoffmann8ffb1bc2009-07-15 13:59:25 +0200108DeviceState *qdev_device_add(const char *cmdline)
109{
110 DeviceInfo *info;
111 DeviceState *qdev;
112 BusState *bus;
113 char driver[32], path[128] = "";
114 char tag[32], value[256];
115 const char *params = NULL;
116 int n = 0;
117
118 if (1 != sscanf(cmdline, "%32[^,],%n", driver, &n)) {
119 fprintf(stderr, "device parse error: \"%s\"\n", cmdline);
120 return NULL;
121 }
122 if (strcmp(driver, "?") == 0) {
123 for (info = device_info_list; info != NULL; info = info->next) {
124 fprintf(stderr, "name \"%s\", bus %s\n", info->name, info->bus_info->name);
125 }
126 return NULL;
127 }
128 if (n) {
129 params = cmdline + n;
130 get_param_value(path, sizeof(path), "bus", params);
131 }
132 info = qdev_find_info(NULL, driver);
133 if (!info) {
134 fprintf(stderr, "Device \"%s\" not found. Try -device '?' for a list.\n",
135 driver);
136 return NULL;
137 }
138 if (info->no_user) {
139 fprintf(stderr, "device \"%s\" can't be added via command line\n",
140 info->name);
141 return NULL;
142 }
143
144 if (strlen(path)) {
145 bus = qbus_find(path);
146 if (!bus)
147 return NULL;
148 qdev = qdev_create(bus, driver);
149 } else {
150 bus = qbus_find_recursive(main_system_bus, NULL, info->bus_info);
151 if (!bus)
152 return NULL;
153 qdev = qdev_create(bus, driver);
154 }
155
156 if (params) {
157 while (params[0]) {
158 if (2 != sscanf(params, "%31[^=]=%255[^,]%n", tag, value, &n)) {
159 fprintf(stderr, "parse error at \"%s\"\n", params);
160 break;
161 }
162 params += n;
163 if (params[0] == ',')
164 params++;
165 if (strcmp(tag, "bus") == 0)
166 continue;
167 if (strcmp(tag, "id") == 0) {
168 qdev->id = qemu_strdup(value);
169 continue;
170 }
171 if (-1 == qdev_prop_parse(qdev, tag, value)) {
172 fprintf(stderr, "can't set property \"%s\" to \"%s\" for \"%s\"\n",
173 tag, value, driver);
174 }
175 }
176 }
177
178 qdev_init(qdev);
179 return qdev;
180}
181
Paul Brookaae94602009-05-14 22:35:06 +0100182/* Initialize a device. Device properties should be set before calling
183 this function. IRQs and MMIO regions should be connected/mapped after
184 calling this function. */
185void qdev_init(DeviceState *dev)
186{
Gerd Hoffmann042f84d2009-06-30 14:12:09 +0200187 dev->info->init(dev, dev->info);
Paul Brook02e2da42009-05-23 00:05:19 +0100188}
189
190/* Unlink device from bus and free the structure. */
191void qdev_free(DeviceState *dev)
192{
193 LIST_REMOVE(dev, sibling);
Gerd Hoffmannccb63de2009-07-15 13:43:34 +0200194 qemu_free(dev->id);
195 qemu_free(dev);
Paul Brookaae94602009-05-14 22:35:06 +0100196}
197
Paul Brookaae94602009-05-14 22:35:06 +0100198/* Get a character (serial) device interface. */
199CharDriverState *qdev_init_chardev(DeviceState *dev)
200{
201 static int next_serial;
202 static int next_virtconsole;
203 /* FIXME: This is a nasty hack that needs to go away. */
Gerd Hoffmann042f84d2009-06-30 14:12:09 +0200204 if (strncmp(dev->info->name, "virtio", 6) == 0) {
Paul Brookaae94602009-05-14 22:35:06 +0100205 return virtcon_hds[next_virtconsole++];
206 } else {
207 return serial_hds[next_serial++];
208 }
209}
210
Paul Brook02e2da42009-05-23 00:05:19 +0100211BusState *qdev_get_parent_bus(DeviceState *dev)
Paul Brookaae94602009-05-14 22:35:06 +0100212{
Paul Brook02e2da42009-05-23 00:05:19 +0100213 return dev->parent_bus;
Paul Brookaae94602009-05-14 22:35:06 +0100214}
215
Paul Brookaae94602009-05-14 22:35:06 +0100216void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n)
217{
218 assert(dev->num_gpio_in == 0);
219 dev->num_gpio_in = n;
220 dev->gpio_in = qemu_allocate_irqs(handler, dev, n);
221}
222
223void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n)
224{
225 assert(dev->num_gpio_out == 0);
226 dev->num_gpio_out = n;
227 dev->gpio_out = pins;
228}
229
230qemu_irq qdev_get_gpio_in(DeviceState *dev, int n)
231{
232 assert(n >= 0 && n < dev->num_gpio_in);
233 return dev->gpio_in[n];
234}
235
236void qdev_connect_gpio_out(DeviceState * dev, int n, qemu_irq pin)
237{
238 assert(n >= 0 && n < dev->num_gpio_out);
239 dev->gpio_out[n] = pin;
240}
241
Paul Brook9d07d752009-05-14 22:35:07 +0100242VLANClientState *qdev_get_vlan_client(DeviceState *dev,
Mark McLoughlincda90462009-05-18 13:13:16 +0100243 NetCanReceive *can_receive,
244 NetReceive *receive,
245 NetReceiveIOV *receive_iov,
Paul Brook9d07d752009-05-14 22:35:07 +0100246 NetCleanup *cleanup,
247 void *opaque)
248{
249 NICInfo *nd = dev->nd;
250 assert(nd);
Mark McLoughlinae50b272009-07-01 16:46:38 +0100251 nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, can_receive,
252 receive, receive_iov, cleanup, opaque);
253 return nd->vc;
Paul Brook9d07d752009-05-14 22:35:07 +0100254}
255
256
257void qdev_get_macaddr(DeviceState *dev, uint8_t *macaddr)
258{
259 memcpy(macaddr, dev->nd->macaddr, 6);
260}
261
Paul Brookaae94602009-05-14 22:35:06 +0100262static int next_block_unit[IF_COUNT];
263
264/* Get a block device. This should only be used for single-drive devices
265 (e.g. SD/Floppy/MTD). Multi-disk devices (scsi/ide) should use the
266 appropriate bus. */
267BlockDriverState *qdev_init_bdrv(DeviceState *dev, BlockInterfaceType type)
268{
269 int unit = next_block_unit[type]++;
270 int index;
271
272 index = drive_get_index(type, 0, unit);
273 if (index == -1) {
274 return NULL;
275 }
276 return drives_table[index].bdrv;
277}
Paul Brook4d6ae672009-05-14 22:35:06 +0100278
Paul Brook02e2da42009-05-23 00:05:19 +0100279BusState *qdev_get_child_bus(DeviceState *dev, const char *name)
Paul Brook4d6ae672009-05-14 22:35:06 +0100280{
Paul Brook02e2da42009-05-23 00:05:19 +0100281 BusState *bus;
Paul Brook4d6ae672009-05-14 22:35:06 +0100282
Paul Brook02e2da42009-05-23 00:05:19 +0100283 LIST_FOREACH(bus, &dev->child_bus, sibling) {
Paul Brook4d6ae672009-05-14 22:35:06 +0100284 if (strcmp(name, bus->name) == 0) {
Paul Brook02e2da42009-05-23 00:05:19 +0100285 return bus;
Paul Brook4d6ae672009-05-14 22:35:06 +0100286 }
287 }
288 return NULL;
289}
290
Paul Brook6f68ecb2009-05-14 22:35:07 +0100291static int next_scsi_bus;
292
293/* Create a scsi bus, and attach devices to it. */
294/* TODO: Actually create a scsi bus for hotplug to use. */
295void scsi_bus_new(DeviceState *host, SCSIAttachFn attach)
296{
297 int bus = next_scsi_bus++;
298 int unit;
299 int index;
300
301 for (unit = 0; unit < MAX_SCSI_DEVS; unit++) {
302 index = drive_get_index(IF_SCSI, bus, unit);
303 if (index == -1) {
304 continue;
305 }
306 attach(host, drives_table[index].bdrv, unit);
307 }
308}
Paul Brook02e2da42009-05-23 00:05:19 +0100309
Gerd Hoffmann8ffb1bc2009-07-15 13:59:25 +0200310static BusState *qbus_find_recursive(BusState *bus, const char *name,
311 const BusInfo *info)
312{
313 DeviceState *dev;
314 BusState *child, *ret;
315 int match = 1;
316
317 if (name && (strcmp(bus->name, name) != 0)) {
318 match = 0;
319 }
320 if (info && (bus->info != info)) {
321 match = 0;
322 }
323 if (match) {
324 return bus;
325 }
326
327 LIST_FOREACH(dev, &bus->children, sibling) {
328 LIST_FOREACH(child, &dev->child_bus, sibling) {
329 ret = qbus_find_recursive(child, name, info);
330 if (ret) {
331 return ret;
332 }
333 }
334 }
335 return NULL;
336}
337
338static void qbus_list_bus(DeviceState *dev, char *dest, int len)
339{
340 BusState *child;
341 const char *sep = " ";
342 int pos = 0;
343
344 pos += snprintf(dest+pos, len-pos,"child busses at \"%s\":",
345 dev->id ? dev->id : dev->info->name);
346 LIST_FOREACH(child, &dev->child_bus, sibling) {
347 pos += snprintf(dest+pos, len-pos, "%s\"%s\"", sep, child->name);
348 sep = ", ";
349 }
350}
351
352static void qbus_list_dev(BusState *bus, char *dest, int len)
353{
354 DeviceState *dev;
355 const char *sep = " ";
356 int pos = 0;
357
358 pos += snprintf(dest+pos, len-pos, "devices at \"%s\":",
359 bus->name);
360 LIST_FOREACH(dev, &bus->children, sibling) {
361 pos += snprintf(dest+pos, len-pos, "%s\"%s\"",
362 sep, dev->info->name);
363 if (dev->id)
364 pos += snprintf(dest+pos, len-pos, "/\"%s\"", dev->id);
365 sep = ", ";
366 }
367}
368
369static BusState *qbus_find_bus(DeviceState *dev, char *elem)
370{
371 BusState *child;
372
373 LIST_FOREACH(child, &dev->child_bus, sibling) {
374 if (strcmp(child->name, elem) == 0) {
375 return child;
376 }
377 }
378 return NULL;
379}
380
381static DeviceState *qbus_find_dev(BusState *bus, char *elem)
382{
383 DeviceState *dev;
384
385 /*
386 * try to match in order:
387 * (1) instance id, if present
388 * (2) driver name
389 * (3) driver alias, if present
390 */
391 LIST_FOREACH(dev, &bus->children, sibling) {
392 if (dev->id && strcmp(dev->id, elem) == 0) {
393 return dev;
394 }
395 }
396 LIST_FOREACH(dev, &bus->children, sibling) {
397 if (strcmp(dev->info->name, elem) == 0) {
398 return dev;
399 }
400 }
401 LIST_FOREACH(dev, &bus->children, sibling) {
402 if (dev->info->alias && strcmp(dev->info->alias, elem) == 0) {
403 return dev;
404 }
405 }
406 return NULL;
407}
408
409static BusState *qbus_find(const char *path)
410{
411 DeviceState *dev;
412 BusState *bus;
413 char elem[128], msg[256];
414 int pos, len;
415
416 /* find start element */
417 if (path[0] == '/') {
418 bus = main_system_bus;
419 pos = 0;
420 } else {
421 if (sscanf(path, "%127[^/]%n", elem, &len) != 1) {
422 fprintf(stderr, "path parse error (\"%s\")\n", path);
423 return NULL;
424 }
425 bus = qbus_find_recursive(main_system_bus, elem, NULL);
426 if (!bus) {
427 fprintf(stderr, "bus \"%s\" not found\n", elem);
428 return NULL;
429 }
430 pos = len;
431 }
432
433 for (;;) {
434 if (path[pos] == '\0') {
435 /* we are done */
436 return bus;
437 }
438
439 /* find device */
440 if (sscanf(path+pos, "/%127[^/]%n", elem, &len) != 1) {
441 fprintf(stderr, "path parse error (\"%s\" pos %d)\n", path, pos);
442 return NULL;
443 }
444 pos += len;
445 dev = qbus_find_dev(bus, elem);
446 if (!dev) {
447 qbus_list_dev(bus, msg, sizeof(msg));
448 fprintf(stderr, "device \"%s\" not found\n%s\n", elem, msg);
449 return NULL;
450 }
451 if (path[pos] == '\0') {
452 /* last specified element is a device. If it has exactly
453 * one child bus accept it nevertheless */
454 switch (dev->num_child_bus) {
455 case 0:
456 fprintf(stderr, "device has no child bus (%s)\n", path);
457 return NULL;
458 case 1:
459 return LIST_FIRST(&dev->child_bus);
460 default:
461 qbus_list_bus(dev, msg, sizeof(msg));
462 fprintf(stderr, "device has multiple child busses (%s)\n%s\n",
463 path, msg);
464 return NULL;
465 }
466 }
467
468 /* find bus */
469 if (sscanf(path+pos, "/%127[^/]%n", elem, &len) != 1) {
470 fprintf(stderr, "path parse error (\"%s\" pos %d)\n", path, pos);
471 return NULL;
472 }
473 pos += len;
474 bus = qbus_find_bus(dev, elem);
475 if (!bus) {
476 qbus_list_bus(dev, msg, sizeof(msg));
477 fprintf(stderr, "child bus \"%s\" not found\n%s\n", elem, msg);
478 return NULL;
479 }
480 }
481}
482
Gerd Hoffmann10c4c982009-06-30 14:12:08 +0200483BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name)
Paul Brook02e2da42009-05-23 00:05:19 +0100484{
485 BusState *bus;
Gerd Hoffmannd271de92009-07-15 13:59:24 +0200486 char *buf;
487 int i,len;
Paul Brook02e2da42009-05-23 00:05:19 +0100488
Gerd Hoffmann10c4c982009-06-30 14:12:08 +0200489 bus = qemu_mallocz(info->size);
490 bus->info = info;
Paul Brook02e2da42009-05-23 00:05:19 +0100491 bus->parent = parent;
Gerd Hoffmannd271de92009-07-15 13:59:24 +0200492
493 if (name) {
494 /* use supplied name */
495 bus->name = qemu_strdup(name);
496 } else if (parent && parent->id) {
497 /* parent device has id -> use it for bus name */
498 len = strlen(parent->id) + 16;
499 buf = qemu_malloc(len);
500 snprintf(buf, len, "%s.%d", parent->id, parent->num_child_bus);
501 bus->name = buf;
502 } else {
503 /* no id -> use lowercase bus type for bus name */
504 len = strlen(info->name) + 16;
505 buf = qemu_malloc(len);
506 len = snprintf(buf, len, "%s.%d", info->name,
507 parent ? parent->num_child_bus : 0);
508 for (i = 0; i < len; i++)
509 buf[i] = tolower(buf[i]);
510 bus->name = buf;
511 }
512
Paul Brook02e2da42009-05-23 00:05:19 +0100513 LIST_INIT(&bus->children);
514 if (parent) {
515 LIST_INSERT_HEAD(&parent->child_bus, bus, sibling);
Gerd Hoffmannd271de92009-07-15 13:59:24 +0200516 parent->num_child_bus++;
Paul Brook02e2da42009-05-23 00:05:19 +0100517 }
518 return bus;
519}
Gerd Hoffmanncae49562009-06-05 15:53:17 +0100520
Gerd Hoffmanncae49562009-06-05 15:53:17 +0100521#define qdev_printf(fmt, ...) monitor_printf(mon, "%*s" fmt, indent, "", ## __VA_ARGS__)
522static void qbus_print(Monitor *mon, BusState *bus, int indent);
523
Gerd Hoffmannee6847d2009-07-15 13:43:31 +0200524static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,
525 const char *prefix, int indent)
526{
527 char buf[64];
528
529 if (!props)
530 return;
531 while (props->name) {
532 if (props->info->print) {
533 props->info->print(dev, props, buf, sizeof(buf));
534 qdev_printf("%s-prop: %s = %s\n", prefix, props->name, buf);
535 }
536 props++;
537 }
538}
539
Gerd Hoffmanncae49562009-06-05 15:53:17 +0100540static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
541{
Gerd Hoffmanncae49562009-06-05 15:53:17 +0100542 BusState *child;
Gerd Hoffmannccb63de2009-07-15 13:43:34 +0200543 qdev_printf("dev: %s, id \"%s\"\n", dev->info->name,
544 dev->id ? dev->id : "");
Gerd Hoffmanncae49562009-06-05 15:53:17 +0100545 indent += 2;
546 if (dev->num_gpio_in) {
547 qdev_printf("gpio-in %d\n", dev->num_gpio_in);
548 }
549 if (dev->num_gpio_out) {
550 qdev_printf("gpio-out %d\n", dev->num_gpio_out);
551 }
Gerd Hoffmannee6847d2009-07-15 13:43:31 +0200552 qdev_print_props(mon, dev, dev->info->props, "dev", indent);
553 qdev_print_props(mon, dev, dev->parent_bus->info->props, "bus", indent);
Gerd Hoffmann10c4c982009-06-30 14:12:08 +0200554 if (dev->parent_bus->info->print_dev)
555 dev->parent_bus->info->print_dev(mon, dev, indent);
Gerd Hoffmanncae49562009-06-05 15:53:17 +0100556 LIST_FOREACH(child, &dev->child_bus, sibling) {
557 qbus_print(mon, child, indent);
558 }
559}
560
561static void qbus_print(Monitor *mon, BusState *bus, int indent)
562{
563 struct DeviceState *dev;
564
565 qdev_printf("bus: %s\n", bus->name);
566 indent += 2;
Gerd Hoffmann10c4c982009-06-30 14:12:08 +0200567 qdev_printf("type %s\n", bus->info->name);
Gerd Hoffmanncae49562009-06-05 15:53:17 +0100568 LIST_FOREACH(dev, &bus->children, sibling) {
569 qdev_print(mon, dev, indent);
570 }
571}
572#undef qdev_printf
573
574void do_info_qtree(Monitor *mon)
575{
576 if (main_system_bus)
577 qbus_print(mon, main_system_bus, 0);
578}