diff options
author | Markus Armbruster <armbru@redhat.com> | 2010-02-19 19:12:18 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2010-03-16 16:58:32 +0100 |
commit | 0c17542d90a3863048ad6daff5de31c5c4d367d4 (patch) | |
tree | 21436fdc416eb2d46d16d7224435bedb41c1e8ff /hw | |
parent | 327867b62a121a93ab1e8e9278eba2cd44eee650 (diff) | |
download | hqemu-0c17542d90a3863048ad6daff5de31c5c4d367d4.zip hqemu-0c17542d90a3863048ad6daff5de31c5c4d367d4.tar.gz |
qdev: Factor qdev_create_from_info() out of qdev_create()
To make it obvious that -device and device_add can't die in
hw_error().
Diffstat (limited to 'hw')
-rw-r--r-- | hw/qdev.c | 37 |
1 files changed, 22 insertions, 15 deletions
@@ -78,13 +78,32 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name) return NULL; } +static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info) +{ + DeviceState *dev; + + assert(bus->info == info->bus_info); + dev = qemu_mallocz(info->size); + dev->info = info; + dev->parent_bus = bus; + qdev_prop_set_defaults(dev, dev->info->props); + qdev_prop_set_defaults(dev, dev->parent_bus->info->props); + qdev_prop_set_globals(dev); + QLIST_INSERT_HEAD(&bus->children, dev, sibling); + if (qdev_hotplug) { + assert(bus->allow_hotplug); + dev->hotplugged = 1; + } + dev->state = DEV_STATE_CREATED; + return dev; +} + /* Create a new device. This only initializes the device state structure and allows properties to be set. qdev_init should be called to initialize the actual device emulation. */ DeviceState *qdev_create(BusState *bus, const char *name) { DeviceInfo *info; - DeviceState *dev; if (!bus) { if (!main_system_bus) { @@ -98,19 +117,7 @@ DeviceState *qdev_create(BusState *bus, const char *name) hw_error("Unknown device '%s' for bus '%s'\n", name, bus->info->name); } - dev = qemu_mallocz(info->size); - dev->info = info; - dev->parent_bus = bus; - qdev_prop_set_defaults(dev, dev->info->props); - qdev_prop_set_defaults(dev, dev->parent_bus->info->props); - qdev_prop_set_globals(dev); - QLIST_INSERT_HEAD(&bus->children, dev, sibling); - if (qdev_hotplug) { - assert(bus->allow_hotplug); - dev->hotplugged = 1; - } - dev->state = DEV_STATE_CREATED; - return dev; + return qdev_create_from_info(bus, info); } static void qdev_print_devinfo(DeviceInfo *info) @@ -224,7 +231,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) } /* create device, set properties */ - qdev = qdev_create(bus, driver); + qdev = qdev_create_from_info(bus, info); id = qemu_opts_id(opts); if (id) { qdev->id = id; |