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 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 #include "qemu/osdep.h"
21 #include "hw/sysbus.h"
22 #include "monitor/hmp.h"
23 #include "monitor/monitor.h"
24 #include "monitor/qdev.h"
25 #include "sysemu/arch_init.h"
26 #include "qapi/error.h"
27 #include "qapi/qapi-commands-qdev.h"
28 #include "qapi/qmp/qdict.h"
29 #include "qapi/qmp/qerror.h"
30 #include "qemu/config-file.h"
31 #include "qemu/error-report.h"
32 #include "qemu/help_option.h"
33 #include "qemu/option.h"
34 #include "qemu/qemu-print.h"
35 #include "qemu/option_int.h"
36 #include "sysemu/block-backend.h"
37 #include "sysemu/sysemu.h"
38 #include "migration/misc.h"
39 #include "migration/migration.h"
40 #include "qemu/cutils.h"
44 * Aliases were a bad idea from the start. Let's keep them
45 * from spreading further.
47 typedef struct QDevAlias
54 /* Please keep this table sorted by typename. */
55 static const QDevAlias qdev_alias_table[] = {
56 { "AC97", "ac97" }, /* -soundhw name */
57 { "e1000", "e1000-82540em" },
58 { "ES1370", "es1370" }, /* -soundhw name */
59 { "ich9-ahci", "ahci" },
60 { "lsi53c895a", "lsi" },
61 { "virtio-9p-ccw", "virtio-9p", QEMU_ARCH_S390X },
62 { "virtio-9p-pci", "virtio-9p", QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
63 { "virtio-balloon-ccw", "virtio-balloon", QEMU_ARCH_S390X },
64 { "virtio-balloon-pci", "virtio-balloon",
65 QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
66 { "virtio-blk-ccw", "virtio-blk", QEMU_ARCH_S390X },
67 { "virtio-blk-pci", "virtio-blk", QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
68 { "virtio-gpu-ccw", "virtio-gpu", QEMU_ARCH_S390X },
69 { "virtio-gpu-pci", "virtio-gpu", QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
70 { "virtio-input-host-ccw", "virtio-input-host", QEMU_ARCH_S390X },
71 { "virtio-input-host-pci", "virtio-input-host",
72 QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
73 { "virtio-iommu-pci", "virtio-iommu", QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
74 { "virtio-keyboard-ccw", "virtio-keyboard", QEMU_ARCH_S390X },
75 { "virtio-keyboard-pci", "virtio-keyboard",
76 QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
77 { "virtio-mouse-ccw", "virtio-mouse", QEMU_ARCH_S390X },
78 { "virtio-mouse-pci", "virtio-mouse", QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
79 { "virtio-net-ccw", "virtio-net", QEMU_ARCH_S390X },
80 { "virtio-net-pci", "virtio-net", QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
81 { "virtio-rng-ccw", "virtio-rng", QEMU_ARCH_S390X },
82 { "virtio-rng-pci", "virtio-rng", QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
83 { "virtio-scsi-ccw", "virtio-scsi", QEMU_ARCH_S390X },
84 { "virtio-scsi-pci", "virtio-scsi", QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
85 { "virtio-serial-ccw", "virtio-serial", QEMU_ARCH_S390X },
86 { "virtio-serial-pci", "virtio-serial", QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
87 { "virtio-tablet-ccw", "virtio-tablet", QEMU_ARCH_S390X },
88 { "virtio-tablet-pci", "virtio-tablet", QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
92 static const char *qdev_class_get_alias(DeviceClass *dc)
94 const char *typename = object_class_get_name(OBJECT_CLASS(dc));
97 for (i = 0; qdev_alias_table[i].typename; i++) {
98 if (qdev_alias_table[i].arch_mask &&
99 !(qdev_alias_table[i].arch_mask & arch_type)) {
103 if (strcmp(qdev_alias_table[i].typename, typename) == 0) {
104 return qdev_alias_table[i].alias;
111 static bool qdev_class_has_alias(DeviceClass *dc)
113 return (qdev_class_get_alias(dc) != NULL);
116 static void qdev_print_devinfo(DeviceClass *dc)
118 qemu_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc)));
120 qemu_printf(", bus %s", dc->bus_type);
122 if (qdev_class_has_alias(dc)) {
123 qemu_printf(", alias \"%s\"", qdev_class_get_alias(dc));
126 qemu_printf(", desc \"%s\"", dc->desc);
128 if (!dc->user_creatable) {
129 qemu_printf(", no-user");
134 static void qdev_print_devinfos(bool show_no_user)
136 static const char *cat_name[DEVICE_CATEGORY_MAX + 1] = {
137 [DEVICE_CATEGORY_BRIDGE] = "Controller/Bridge/Hub",
138 [DEVICE_CATEGORY_USB] = "USB",
139 [DEVICE_CATEGORY_STORAGE] = "Storage",
140 [DEVICE_CATEGORY_NETWORK] = "Network",
141 [DEVICE_CATEGORY_INPUT] = "Input",
142 [DEVICE_CATEGORY_DISPLAY] = "Display",
143 [DEVICE_CATEGORY_SOUND] = "Sound",
144 [DEVICE_CATEGORY_MISC] = "Misc",
145 [DEVICE_CATEGORY_CPU] = "CPU",
146 [DEVICE_CATEGORY_MAX] = "Uncategorized",
152 module_load_qom_all();
153 list = object_class_get_list_sorted(TYPE_DEVICE, false);
155 for (i = 0; i <= DEVICE_CATEGORY_MAX; i++) {
157 for (elt = list; elt; elt = elt->next) {
158 DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,
160 if ((i < DEVICE_CATEGORY_MAX
161 ? !test_bit(i, dc->categories)
162 : !bitmap_empty(dc->categories, DEVICE_CATEGORY_MAX))
164 && !dc->user_creatable)) {
168 qemu_printf("%s%s devices:\n", i ? "\n" : "", cat_name[i]);
171 qdev_print_devinfo(dc);
178 static int set_property(void *opaque, const char *name, const char *value,
181 Object *obj = opaque;
183 if (strcmp(name, "driver") == 0)
185 if (strcmp(name, "bus") == 0)
188 if (!object_property_parse(obj, name, value, errp)) {
194 static const char *find_typename_by_alias(const char *alias)
198 for (i = 0; qdev_alias_table[i].alias; i++) {
199 if (qdev_alias_table[i].arch_mask &&
200 !(qdev_alias_table[i].arch_mask & arch_type)) {
204 if (strcmp(qdev_alias_table[i].alias, alias) == 0) {
205 return qdev_alias_table[i].typename;
212 static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)
216 const char *original_name = *driver;
218 oc = module_object_class_by_name(*driver);
220 const char *typename = find_typename_by_alias(*driver);
224 oc = module_object_class_by_name(*driver);
228 if (!object_class_dynamic_cast(oc, TYPE_DEVICE)) {
229 if (*driver != original_name) {
230 error_setg(errp, "'%s' (alias '%s') is not a valid device model"
231 " name", original_name, *driver);
233 error_setg(errp, "'%s' is not a valid device model name", *driver);
238 if (object_class_is_abstract(oc)) {
239 error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
240 "non-abstract device type");
244 dc = DEVICE_CLASS(oc);
245 if (!dc->user_creatable ||
246 (qdev_hotplug && !dc->hotpluggable)) {
247 error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
248 "pluggable device type");
256 int qdev_device_help(QemuOpts *opts)
258 Error *local_err = NULL;
260 ObjectPropertyInfoList *prop_list;
261 ObjectPropertyInfoList *prop;
265 driver = qemu_opt_get(opts, "driver");
266 if (driver && is_help_option(driver)) {
267 qdev_print_devinfos(false);
271 if (!driver || !qemu_opt_has_help_opt(opts)) {
275 if (!object_class_by_name(driver)) {
276 const char *typename = find_typename_by_alias(driver);
283 prop_list = qmp_device_list_properties(driver, &local_err);
289 qemu_printf("%s options:\n", driver);
291 qemu_printf("There are no options for %s.\n", driver);
293 array = g_ptr_array_new();
294 for (prop = prop_list; prop; prop = prop->next) {
295 g_ptr_array_add(array,
296 object_property_help(prop->value->name,
298 prop->value->default_value,
299 prop->value->description));
301 g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0);
302 for (i = 0; i < array->len; i++) {
303 printf("%s\n", (char *)array->pdata[i]);
305 g_ptr_array_set_free_func(array, g_free);
306 g_ptr_array_free(array, true);
307 qapi_free_ObjectPropertyInfoList(prop_list);
311 error_report_err(local_err);
315 static Object *qdev_get_peripheral(void)
320 dev = container_get(qdev_get_machine(), "/peripheral");
326 static Object *qdev_get_peripheral_anon(void)
331 dev = container_get(qdev_get_machine(), "/peripheral-anon");
337 static void qbus_error_append_bus_list_hint(DeviceState *dev,
341 const char *sep = " ";
343 error_append_hint(errp, "child buses at \"%s\":",
344 dev->id ? dev->id : object_get_typename(OBJECT(dev)));
345 QLIST_FOREACH(child, &dev->child_bus, sibling) {
346 error_append_hint(errp, "%s\"%s\"", sep, child->name);
349 error_append_hint(errp, "\n");
352 static void qbus_error_append_dev_list_hint(BusState *bus,
356 const char *sep = " ";
358 error_append_hint(errp, "devices at \"%s\":", bus->name);
359 QTAILQ_FOREACH(kid, &bus->children, sibling) {
360 DeviceState *dev = kid->child;
361 error_append_hint(errp, "%s\"%s\"", sep,
362 object_get_typename(OBJECT(dev)));
364 error_append_hint(errp, "/\"%s\"", dev->id);
368 error_append_hint(errp, "\n");
371 static BusState *qbus_find_bus(DeviceState *dev, char *elem)
375 QLIST_FOREACH(child, &dev->child_bus, sibling) {
376 if (strcmp(child->name, elem) == 0) {
383 static DeviceState *qbus_find_dev(BusState *bus, char *elem)
388 * try to match in order:
389 * (1) instance id, if present
391 * (3) driver alias, if present
393 QTAILQ_FOREACH(kid, &bus->children, sibling) {
394 DeviceState *dev = kid->child;
395 if (dev->id && strcmp(dev->id, elem) == 0) {
399 QTAILQ_FOREACH(kid, &bus->children, sibling) {
400 DeviceState *dev = kid->child;
401 if (strcmp(object_get_typename(OBJECT(dev)), elem) == 0) {
405 QTAILQ_FOREACH(kid, &bus->children, sibling) {
406 DeviceState *dev = kid->child;
407 DeviceClass *dc = DEVICE_GET_CLASS(dev);
409 if (qdev_class_has_alias(dc) &&
410 strcmp(qdev_class_get_alias(dc), elem) == 0) {
417 static inline bool qbus_is_full(BusState *bus)
419 BusClass *bus_class = BUS_GET_CLASS(bus);
420 return bus_class->max_dev && bus->num_children >= bus_class->max_dev;
424 * Search the tree rooted at @bus for a bus.
425 * If @name, search for a bus with that name. Note that bus names
426 * need not be unique. Yes, that's screwed up.
427 * Else search for a bus that is a subtype of @bus_typename.
428 * If more than one exists, prefer one that can take another device.
429 * Return the bus if found, else %NULL.
431 static BusState *qbus_find_recursive(BusState *bus, const char *name,
432 const char *bus_typename)
435 BusState *pick, *child, *ret;
438 assert(name || bus_typename);
440 match = !strcmp(bus->name, name);
442 match = !!object_dynamic_cast(OBJECT(bus), bus_typename);
445 if (match && !qbus_is_full(bus)) {
446 return bus; /* root matches and isn't full */
449 pick = match ? bus : NULL;
451 QTAILQ_FOREACH(kid, &bus->children, sibling) {
452 DeviceState *dev = kid->child;
453 QLIST_FOREACH(child, &dev->child_bus, sibling) {
454 ret = qbus_find_recursive(child, name, bus_typename);
455 if (ret && !qbus_is_full(ret)) {
456 return ret; /* a descendant matches and isn't full */
464 /* root or a descendant matches, but is full */
468 static BusState *qbus_find(const char *path, Error **errp)
475 /* find start element */
476 if (path[0] == '/') {
477 bus = sysbus_get_default();
480 if (sscanf(path, "%127[^/]%n", elem, &len) != 1) {
484 bus = qbus_find_recursive(sysbus_get_default(), elem, NULL);
486 error_setg(errp, "Bus '%s' not found", elem);
493 assert(path[pos] == '/' || !path[pos]);
494 while (path[pos] == '/') {
497 if (path[pos] == '\0') {
502 if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) {
503 g_assert_not_reached();
507 dev = qbus_find_dev(bus, elem);
509 error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
510 "Device '%s' not found", elem);
511 qbus_error_append_dev_list_hint(bus, errp);
515 assert(path[pos] == '/' || !path[pos]);
516 while (path[pos] == '/') {
519 if (path[pos] == '\0') {
520 /* last specified element is a device. If it has exactly
521 * one child bus accept it nevertheless */
522 if (dev->num_child_bus == 1) {
523 bus = QLIST_FIRST(&dev->child_bus);
526 if (dev->num_child_bus) {
527 error_setg(errp, "Device '%s' has multiple child buses",
529 qbus_error_append_bus_list_hint(dev, errp);
531 error_setg(errp, "Device '%s' has no child bus", elem);
537 if (sscanf(path+pos, "%127[^/]%n", elem, &len) != 1) {
538 g_assert_not_reached();
542 bus = qbus_find_bus(dev, elem);
544 error_setg(errp, "Bus '%s' not found", elem);
545 qbus_error_append_bus_list_hint(dev, errp);
550 if (qbus_is_full(bus)) {
551 error_setg(errp, "Bus '%s' is full", path);
557 void qdev_set_id(DeviceState *dev, const char *id)
564 object_property_add_child(qdev_get_peripheral(), dev->id,
567 static int anon_count;
568 gchar *name = g_strdup_printf("device[%d]", anon_count++);
569 object_property_add_child(qdev_get_peripheral_anon(), name,
575 static int is_failover_device(void *opaque, const char *name, const char *value,
578 if (strcmp(name, "failover_pair_id") == 0) {
579 QemuOpts *opts = (QemuOpts *)opaque;
581 if (qdev_should_hide_device(opts)) {
589 static bool should_hide_device(QemuOpts *opts)
591 if (qemu_opt_foreach(opts, is_failover_device, opts, NULL) == 0) {
597 DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
600 const char *driver, *path;
601 DeviceState *dev = NULL;
602 BusState *bus = NULL;
605 driver = qemu_opt_get(opts, "driver");
607 error_setg(errp, QERR_MISSING_PARAMETER, "driver");
612 dc = qdev_get_device_class(&driver, errp);
618 path = qemu_opt_get(opts, "bus");
620 bus = qbus_find(path, errp);
624 if (!object_dynamic_cast(OBJECT(bus), dc->bus_type)) {
625 error_setg(errp, "Device '%s' can't go on %s bus",
626 driver, object_get_typename(OBJECT(bus)));
629 } else if (dc->bus_type != NULL) {
630 bus = qbus_find_recursive(sysbus_get_default(), NULL, dc->bus_type);
631 if (!bus || qbus_is_full(bus)) {
632 error_setg(errp, "No '%s' bus found for device '%s'",
633 dc->bus_type, driver);
637 hide = should_hide_device(opts);
639 if ((hide || qdev_hotplug) && bus && !qbus_is_hotpluggable(bus)) {
640 error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
648 if (!migration_is_idle()) {
649 error_setg(errp, "device_add not allowed while migrating");
654 dev = qdev_new(driver);
656 /* Check whether the hotplug is allowed by the machine */
657 if (qdev_hotplug && !qdev_hotplug_allowed(dev, errp)) {
661 if (!bus && qdev_hotplug && !qdev_get_machine_hotplug_handler(dev)) {
662 /* No bus, no machine hotplug handler --> device is not hotpluggable */
663 error_setg(errp, "Device '%s' can not be hotplugged on this machine",
668 qdev_set_id(dev, qemu_opts_id(opts));
671 if (qemu_opt_foreach(opts, set_property, dev, errp)) {
676 if (!qdev_realize(DEVICE(dev), bus, errp)) {
684 object_unparent(OBJECT(dev));
685 object_unref(OBJECT(dev));
691 #define qdev_printf(fmt, ...) monitor_printf(mon, "%*s" fmt, indent, "", ## __VA_ARGS__)
692 static void qbus_print(Monitor *mon, BusState *bus, int indent);
694 static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props,
699 for (; props->name; props++) {
701 char *legacy_name = g_strdup_printf("legacy-%s", props->name);
703 if (object_property_get_type(OBJECT(dev), legacy_name, NULL)) {
704 value = object_property_get_str(OBJECT(dev), legacy_name, NULL);
706 value = object_property_print(OBJECT(dev), props->name, true,
714 qdev_printf("%s = %s\n", props->name,
715 *value ? value : "<null>");
720 static void bus_print_dev(BusState *bus, Monitor *mon, DeviceState *dev, int indent)
722 BusClass *bc = BUS_GET_CLASS(bus);
725 bc->print_dev(mon, dev, indent);
729 static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
736 qdev_printf("dev: %s, id \"%s\"\n", object_get_typename(OBJECT(dev)),
737 dev->id ? dev->id : "");
739 QLIST_FOREACH(ngl, &dev->gpios, node) {
741 qdev_printf("gpio-in \"%s\" %d\n", ngl->name ? ngl->name : "",
745 qdev_printf("gpio-out \"%s\" %d\n", ngl->name ? ngl->name : "",
749 QLIST_FOREACH(ncl, &dev->clocks, node) {
750 qdev_printf("clock-%s%s \"%s\" freq_hz=%e\n",
751 ncl->output ? "out" : "in",
752 ncl->alias ? " (alias)" : "",
754 CLOCK_PERIOD_TO_HZ(1.0 * clock_get(ncl->clock)));
756 class = object_get_class(OBJECT(dev));
758 qdev_print_props(mon, dev, DEVICE_CLASS(class)->props_, indent);
759 class = object_class_get_parent(class);
760 } while (class != object_class_by_name(TYPE_DEVICE));
761 bus_print_dev(dev->parent_bus, mon, dev, indent);
762 QLIST_FOREACH(child, &dev->child_bus, sibling) {
763 qbus_print(mon, child, indent);
767 static void qbus_print(Monitor *mon, BusState *bus, int indent)
771 qdev_printf("bus: %s\n", bus->name);
773 qdev_printf("type %s\n", object_get_typename(OBJECT(bus)));
774 QTAILQ_FOREACH(kid, &bus->children, sibling) {
775 DeviceState *dev = kid->child;
776 qdev_print(mon, dev, indent);
781 void hmp_info_qtree(Monitor *mon, const QDict *qdict)
783 if (sysbus_get_default())
784 qbus_print(mon, sysbus_get_default(), 0);
787 void hmp_info_qdm(Monitor *mon, const QDict *qdict)
789 qdev_print_devinfos(true);
792 void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp)
797 opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, errp);
801 if (!monitor_cur_is_qmp() && qdev_device_help(opts)) {
805 dev = qdev_device_add(opts, errp);
810 object_unref(OBJECT(dev));
813 static DeviceState *find_device_state(const char *id, Error **errp)
818 obj = object_resolve_path(id, NULL);
820 char *root_path = object_get_canonical_path(qdev_get_peripheral());
821 char *path = g_strdup_printf("%s/%s", root_path, id);
824 obj = object_resolve_path_type(path, TYPE_DEVICE, NULL);
829 error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
830 "Device '%s' not found", id);
834 if (!object_dynamic_cast(obj, TYPE_DEVICE)) {
835 error_setg(errp, "%s is not a hotpluggable device", id);
842 void qdev_unplug(DeviceState *dev, Error **errp)
844 DeviceClass *dc = DEVICE_GET_CLASS(dev);
845 HotplugHandler *hotplug_ctrl;
846 HotplugHandlerClass *hdc;
847 Error *local_err = NULL;
849 if (dev->parent_bus && !qbus_is_hotpluggable(dev->parent_bus)) {
850 error_setg(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
854 if (!dc->hotpluggable) {
855 error_setg(errp, QERR_DEVICE_NO_HOTPLUG,
856 object_get_typename(OBJECT(dev)));
860 if (!migration_is_idle() && !dev->allow_unplug_during_migration) {
861 error_setg(errp, "device_del not allowed while migrating");
865 qdev_hot_removed = true;
867 hotplug_ctrl = qdev_get_hotplug_handler(dev);
868 /* hotpluggable device MUST have HotplugHandler, if it doesn't
869 * then something is very wrong with it */
870 g_assert(hotplug_ctrl);
872 /* If device supports async unplug just request it to be done,
873 * otherwise just remove it synchronously */
874 hdc = HOTPLUG_HANDLER_GET_CLASS(hotplug_ctrl);
875 if (hdc->unplug_request) {
876 hotplug_handler_unplug_request(hotplug_ctrl, dev, &local_err);
878 hotplug_handler_unplug(hotplug_ctrl, dev, &local_err);
880 object_unparent(OBJECT(dev));
883 error_propagate(errp, local_err);
886 void qmp_device_del(const char *id, Error **errp)
888 DeviceState *dev = find_device_state(id, errp);
890 if (dev->pending_deleted_event) {
891 error_setg(errp, "Device %s is already in the "
892 "process of unplug", id);
896 qdev_unplug(dev, errp);
900 void hmp_device_add(Monitor *mon, const QDict *qdict)
904 qmp_device_add((QDict *)qdict, NULL, &err);
905 hmp_handle_error(mon, err);
908 void hmp_device_del(Monitor *mon, const QDict *qdict)
910 const char *id = qdict_get_str(qdict, "id");
913 qmp_device_del(id, &err);
914 hmp_handle_error(mon, err);
917 BlockBackend *blk_by_qdev_id(const char *id, Error **errp)
922 dev = find_device_state(id, errp);
927 blk = blk_by_dev(dev);
929 error_setg(errp, "Device does not have a block device backend");
934 void qdev_machine_init(void)
936 qdev_get_peripheral_anon();
937 qdev_get_peripheral();
940 QemuOptsList qemu_device_opts = {
942 .implied_opt_name = "driver",
943 .head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head),
946 * no elements => accept any
947 * sanity checking will happen later
948 * when setting device properties
950 { /* end of list */ }
954 QemuOptsList qemu_global_opts = {
956 .head = QTAILQ_HEAD_INITIALIZER(qemu_global_opts.head),
960 .type = QEMU_OPT_STRING,
963 .type = QEMU_OPT_STRING,
966 .type = QEMU_OPT_STRING,
968 { /* end of list */ }
972 int qemu_global_option(const char *str)
974 char driver[64], property[64];
978 rc = sscanf(str, "%63[^.=].%63[^=]%n", driver, property, &offset);
979 if (rc == 2 && str[offset] == '=') {
980 opts = qemu_opts_create(&qemu_global_opts, NULL, 0, &error_abort);
981 qemu_opt_set(opts, "driver", driver, &error_abort);
982 qemu_opt_set(opts, "property", property, &error_abort);
983 qemu_opt_set(opts, "value", str + offset + 1, &error_abort);
987 opts = qemu_opts_parse_noisily(&qemu_global_opts, str, false);