Revision 0c17542d

b/hw/qdev.c
78 78
    return NULL;
79 79
}
80 80

  
81
static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info)
82
{
83
    DeviceState *dev;
84

  
85
    assert(bus->info == info->bus_info);
86
    dev = qemu_mallocz(info->size);
87
    dev->info = info;
88
    dev->parent_bus = bus;
89
    qdev_prop_set_defaults(dev, dev->info->props);
90
    qdev_prop_set_defaults(dev, dev->parent_bus->info->props);
91
    qdev_prop_set_globals(dev);
92
    QLIST_INSERT_HEAD(&bus->children, dev, sibling);
93
    if (qdev_hotplug) {
94
        assert(bus->allow_hotplug);
95
        dev->hotplugged = 1;
96
    }
97
    dev->state = DEV_STATE_CREATED;
98
    return dev;
99
}
100

  
81 101
/* Create a new device.  This only initializes the device state structure
82 102
   and allows properties to be set.  qdev_init should be called to
83 103
   initialize the actual device emulation.  */
84 104
DeviceState *qdev_create(BusState *bus, const char *name)
85 105
{
86 106
    DeviceInfo *info;
87
    DeviceState *dev;
88 107

  
89 108
    if (!bus) {
90 109
        if (!main_system_bus) {
......
98 117
        hw_error("Unknown device '%s' for bus '%s'\n", name, bus->info->name);
99 118
    }
100 119

  
101
    dev = qemu_mallocz(info->size);
102
    dev->info = info;
103
    dev->parent_bus = bus;
104
    qdev_prop_set_defaults(dev, dev->info->props);
105
    qdev_prop_set_defaults(dev, dev->parent_bus->info->props);
106
    qdev_prop_set_globals(dev);
107
    QLIST_INSERT_HEAD(&bus->children, dev, sibling);
108
    if (qdev_hotplug) {
109
        assert(bus->allow_hotplug);
110
        dev->hotplugged = 1;
111
    }
112
    dev->state = DEV_STATE_CREATED;
113
    return dev;
120
    return qdev_create_from_info(bus, info);
114 121
}
115 122

  
116 123
static void qdev_print_devinfo(DeviceInfo *info)
......
224 231
    }
225 232

  
226 233
    /* create device, set properties */
227
    qdev = qdev_create(bus, driver);
234
    qdev = qdev_create_from_info(bus, info);
228 235
    id = qemu_opts_id(opts);
229 236
    if (id) {
230 237
        qdev->id = id;

Also available in: Unified diff