Revision 30fbb9fc

b/hw/acpi_piix4.c
280 280
    s->pci0_hotplug_enable = ~0;
281 281

  
282 282
    QTAILQ_FOREACH_SAFE(qdev, &bus->children, sibling, next) {
283
        PCIDeviceInfo *info = container_of(qdev->info, PCIDeviceInfo, qdev);
283
        PCIDeviceInfo *info = container_of(qdev_get_info(qdev), PCIDeviceInfo, qdev);
284 284
        PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, qdev);
285 285
        int slot = PCI_SLOT(pdev->devfn);
286 286

  
......
491 491

  
492 492
    QTAILQ_FOREACH_SAFE(qdev, &bus->children, sibling, next) {
493 493
        dev = DO_UPCAST(PCIDevice, qdev, qdev);
494
        info = container_of(qdev->info, PCIDeviceInfo, qdev);
494
        info = container_of(qdev_get_info(qdev), PCIDeviceInfo, qdev);
495 495
        if (PCI_SLOT(dev->devfn) == slot && !info->no_hotplug) {
496 496
            qdev_free(qdev);
497 497
        }
b/hw/apic_common.c
31 31
    trace_cpu_set_apic_base(val);
32 32

  
33 33
    if (s) {
34
        info = DO_UPCAST(APICCommonInfo, busdev.qdev, s->busdev.qdev.info);
34
        info = DO_UPCAST(APICCommonInfo, busdev.qdev, qdev_get_info(&s->busdev.qdev));
35 35
        info->set_base(s, val);
36 36
    }
37 37
}
......
51 51
    APICCommonInfo *info;
52 52

  
53 53
    if (s) {
54
        info = DO_UPCAST(APICCommonInfo, busdev.qdev, s->busdev.qdev.info);
54
        info = DO_UPCAST(APICCommonInfo, busdev.qdev, qdev_get_info(&s->busdev.qdev));
55 55
        info->set_tpr(s, val);
56 56
    }
57 57
}
......
89 89
    APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
90 90
    APICCommonInfo *info;
91 91

  
92
    info = DO_UPCAST(APICCommonInfo, busdev.qdev, s->busdev.qdev.info);
92
    info = DO_UPCAST(APICCommonInfo, busdev.qdev, qdev_get_info(&s->busdev.qdev));
93 93
    info->external_nmi(s);
94 94
}
95 95

  
......
232 232
    }
233 233
    s->idx = apic_no++;
234 234

  
235
    info = DO_UPCAST(APICCommonInfo, busdev.qdev, s->busdev.qdev.info);
235
    info = DO_UPCAST(APICCommonInfo, busdev.qdev, qdev_get_info(&s->busdev.qdev));
236 236
    info->init(s);
237 237

  
238 238
    sysbus_init_mmio(&s->busdev, &s->io_memory);
......
243 243
{
244 244
    APICCommonState *s = opaque;
245 245
    APICCommonInfo *info =
246
        DO_UPCAST(APICCommonInfo, busdev.qdev, s->busdev.qdev.info);
246
        DO_UPCAST(APICCommonInfo, busdev.qdev, qdev_get_info(&s->busdev.qdev));
247 247

  
248 248
    if (info->post_load) {
249 249
        info->post_load(s);
b/hw/cirrus_vga.c
2921 2921
{
2922 2922
     PCICirrusVGAState *d = DO_UPCAST(PCICirrusVGAState, dev, dev);
2923 2923
     CirrusVGAState *s = &d->cirrus_vga;
2924
     PCIDeviceInfo *info = DO_UPCAST(PCIDeviceInfo, qdev, dev->qdev.info);
2924
     PCIDeviceInfo *info = DO_UPCAST(PCIDeviceInfo, qdev, qdev_get_info(&dev->qdev));
2925 2925
     int16_t device_id = info->device_id;
2926 2926

  
2927 2927
     /* setup VGA */
b/hw/e1000.c
1182 1182
    d->eeprom_data[EEPROM_CHECKSUM_REG] = checksum;
1183 1183

  
1184 1184
    d->nic = qemu_new_nic(&net_e1000_info, &d->conf,
1185
                          d->dev.qdev.info->name, d->dev.qdev.id, d);
1185
                          qdev_get_info(&d->dev.qdev)->name, d->dev.qdev.id, d);
1186 1186

  
1187 1187
    qemu_format_nic_info_str(&d->nic->nc, macaddr);
1188 1188

  
b/hw/eepro100.c
1848 1848
{
1849 1849
    EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
1850 1850
    E100PCIDeviceInfo *e100_device = DO_UPCAST(E100PCIDeviceInfo, pci.qdev,
1851
                                               pci_dev->qdev.info);
1851
                                               qdev_get_info(&pci_dev->qdev));
1852 1852

  
1853 1853
    TRACE(OTHER, logout("\n"));
1854 1854

  
......
1878 1878
    nic_reset(s);
1879 1879

  
1880 1880
    s->nic = qemu_new_nic(&net_eepro100_info, &s->conf,
1881
                          pci_dev->qdev.info->name, pci_dev->qdev.id, s);
1881
                          qdev_get_info(&pci_dev->qdev)->name, pci_dev->qdev.id, s);
1882 1882

  
1883 1883
    qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
1884 1884
    TRACE(OTHER, logout("%s\n", s->nic->nc.info_str));
b/hw/hda-audio.c
777 777
    uint32_t i, type;
778 778

  
779 779
    a->desc = desc;
780
    a->name = a->hda.qdev.info->name;
780
    a->name = qdev_get_info(&a->hda.qdev)->name;
781 781
    dprint(a, 1, "%s: cad %d\n", __FUNCTION__, a->hda.cad);
782 782

  
783 783
    AUD_register_card("hda", &a->card);
b/hw/i8259_common.c
49 49
{
50 50
    PICCommonState *s = opaque;
51 51
    PICCommonInfo *info =
52
        DO_UPCAST(PICCommonInfo, isadev.qdev, s->dev.qdev.info);
52
        DO_UPCAST(PICCommonInfo, isadev.qdev, qdev_get_info(&s->dev.qdev));
53 53

  
54 54
    if (info->pre_save) {
55 55
        info->pre_save(s);
......
60 60
{
61 61
    PICCommonState *s = opaque;
62 62
    PICCommonInfo *info =
63
        DO_UPCAST(PICCommonInfo, isadev.qdev, s->dev.qdev.info);
63
        DO_UPCAST(PICCommonInfo, isadev.qdev, qdev_get_info(&s->dev.qdev));
64 64

  
65 65
    if (info->post_load) {
66 66
        info->post_load(s);
......
72 72
{
73 73
    PICCommonState *s = DO_UPCAST(PICCommonState, dev, dev);
74 74
    PICCommonInfo *info =
75
        DO_UPCAST(PICCommonInfo, isadev.qdev, dev->qdev.info);
75
        DO_UPCAST(PICCommonInfo, isadev.qdev, qdev_get_info(&dev->qdev));
76 76

  
77 77
    info->init(s);
78 78

  
b/hw/ide/piix.c
195 195
    PCIDevice *dev;
196 196

  
197 197
    dev = pci_create_simple(bus, devfn, "piix3-ide-xen");
198
    dev->qdev.info->unplug = pci_piix3_xen_ide_unplug;
199 198
    pci_ide_create_devs(dev, hd_table);
200 199
    return dev;
201 200
}
......
253 252
        .qdev.name    = "piix3-ide-xen",
254 253
        .qdev.size    = sizeof(PCIIDEState),
255 254
        .qdev.no_user = 1,
255
        .qdev.unplug  = pci_piix3_xen_ide_unplug,
256 256
        .init         = pci_piix_ide_initfn,
257 257
        .vendor_id    = PCI_VENDOR_ID_INTEL,
258 258
        .device_id    = PCI_DEVICE_ID_INTEL_82371SB_1,
b/hw/intel-hda.c
1116 1116
    /* reset codecs */
1117 1117
    QTAILQ_FOREACH(qdev, &d->codecs.qbus.children, sibling) {
1118 1118
        cdev = DO_UPCAST(HDACodecDevice, qdev, qdev);
1119
        if (qdev->info->reset) {
1120
            qdev->info->reset(qdev);
1119
        if (qdev_get_info(qdev)->reset) {
1120
            qdev_get_info(qdev)->reset(qdev);
1121 1121
        }
1122 1122
        d->state_sts |= (1 << cdev->cad);
1123 1123
    }
......
1129 1129
    IntelHDAState *d = DO_UPCAST(IntelHDAState, pci, pci);
1130 1130
    uint8_t *conf = d->pci.config;
1131 1131

  
1132
    d->name = d->pci.qdev.info->name;
1132
    d->name = qdev_get_info(&d->pci.qdev)->name;
1133 1133

  
1134 1134
    pci_config_set_interrupt_pin(conf, 1);
1135 1135

  
b/hw/ioapic_common.c
40 40
{
41 41
    IOAPICCommonState *s = opaque;
42 42
    IOAPICCommonInfo *info =
43
        DO_UPCAST(IOAPICCommonInfo, busdev.qdev, s->busdev.qdev.info);
43
        DO_UPCAST(IOAPICCommonInfo, busdev.qdev, qdev_get_info(&s->busdev.qdev));
44 44

  
45 45
    if (info->pre_save) {
46 46
        info->pre_save(s);
......
51 51
{
52 52
    IOAPICCommonState *s = opaque;
53 53
    IOAPICCommonInfo *info =
54
        DO_UPCAST(IOAPICCommonInfo, busdev.qdev, s->busdev.qdev.info);
54
        DO_UPCAST(IOAPICCommonInfo, busdev.qdev, qdev_get_info(&s->busdev.qdev));
55 55

  
56 56
    if (info->post_load) {
57 57
        info->post_load(s);
......
69 69
        return -1;
70 70
    }
71 71

  
72
    info = DO_UPCAST(IOAPICCommonInfo, busdev.qdev, s->busdev.qdev.info);
72
    info = DO_UPCAST(IOAPICCommonInfo, busdev.qdev, qdev_get_info(&s->busdev.qdev));
73 73
    info->init(s, ioapic_no);
74 74

  
75 75
    sysbus_init_mmio(&s->busdev, &s->io_memory);
b/hw/lan9118.c
1221 1221
    qemu_macaddr_default_if_unset(&s->conf.macaddr);
1222 1222

  
1223 1223
    s->nic = qemu_new_nic(&net_lan9118_info, &s->conf,
1224
                          dev->qdev.info->name, dev->qdev.id, s);
1224
                          qdev_get_info(&dev->qdev)->name, dev->qdev.id, s);
1225 1225
    qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
1226 1226
    s->eeprom[0] = 0xa5;
1227 1227
    for (i = 0; i < 6; i++) {
b/hw/lsi53c895a.c
1681 1681
                DeviceState *dev;
1682 1682

  
1683 1683
                QTAILQ_FOREACH(dev, &s->bus.qbus.children, sibling) {
1684
                    dev->info->reset(dev);
1684
                    qdev_get_info(dev)->reset(dev);
1685 1685
                }
1686 1686
                s->sstat0 |= LSI_SSTAT0_RST;
1687 1687
                lsi_script_scsi_interrupt(s, LSI_SIST0_RST, 0);
b/hw/mipsnet.c
240 240
    sysbus_init_irq(dev, &s->irq);
241 241

  
242 242
    s->nic = qemu_new_nic(&net_mipsnet_info, &s->conf,
243
                          dev->qdev.info->name, dev->qdev.id, s);
243
                          qdev_get_info(&dev->qdev)->name, dev->qdev.id, s);
244 244
    qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
245 245

  
246 246
    return 0;
b/hw/ne2000-isa.c
76 76
    ne2000_reset(s);
77 77

  
78 78
    s->nic = qemu_new_nic(&net_ne2000_isa_info, &s->c,
79
                          dev->qdev.info->name, dev->qdev.id, s);
79
                          qdev_get_info(&dev->qdev)->name, dev->qdev.id, s);
80 80
    qemu_format_nic_info_str(&s->nic->nc, s->c.macaddr.a);
81 81

  
82 82
    return 0;
b/hw/ne2000.c
760 760
    ne2000_reset(s);
761 761

  
762 762
    s->nic = qemu_new_nic(&net_ne2000_info, &s->c,
763
                          pci_dev->qdev.info->name, pci_dev->qdev.id, s);
763
                          qdev_get_info(&pci_dev->qdev)->name, pci_dev->qdev.id, s);
764 764
    qemu_format_nic_info_str(&s->nic->nc, s->c.macaddr.a);
765 765

  
766 766
    if (!pci_dev->qdev.hotplugged) {
b/hw/opencores_eth.c
717 717
    sysbus_init_irq(dev, &s->irq);
718 718

  
719 719
    s->nic = qemu_new_nic(&net_open_eth_info, &s->conf,
720
                          s->dev.qdev.info->name, s->dev.qdev.id, s);
720
                          qdev_get_info(&s->dev.qdev)->name, s->dev.qdev.id, s);
721 721
    return 0;
722 722
}
723 723

  
b/hw/pci.c
841 841
static int pci_unregister_device(DeviceState *dev)
842 842
{
843 843
    PCIDevice *pci_dev = DO_UPCAST(PCIDevice, qdev, dev);
844
    PCIDeviceInfo *info = DO_UPCAST(PCIDeviceInfo, qdev, dev->info);
844
    PCIDeviceInfo *info = DO_UPCAST(PCIDeviceInfo, qdev, qdev_get_info(dev));
845 845
    int ret = 0;
846 846

  
847 847
    if (info->exit)
......
1531 1531
static int pci_unplug_device(DeviceState *qdev)
1532 1532
{
1533 1533
    PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev);
1534
    PCIDeviceInfo *info = container_of(qdev->info, PCIDeviceInfo, qdev);
1534
    PCIDeviceInfo *info = container_of(qdev_get_info(qdev), PCIDeviceInfo, qdev);
1535 1535

  
1536 1536
    if (info->no_hotplug) {
1537 1537
        qerror_report(QERR_DEVICE_NO_HOTPLUG, info->qdev.name);
......
1544 1544
void pci_qdev_register(PCIDeviceInfo *info)
1545 1545
{
1546 1546
    info->qdev.init = pci_qdev_init;
1547
    info->qdev.unplug = pci_unplug_device;
1547
    if (!info->qdev.unplug) {
1548
        info->qdev.unplug = pci_unplug_device;
1549
    }
1548 1550
    info->qdev.exit = pci_unregister_device;
1549 1551
    info->qdev.bus_info = &pci_bus_info;
1550 1552
    qdev_register(&info->qdev);
......
1737 1739
        size = 1 << qemu_fls(size);
1738 1740
    }
1739 1741

  
1740
    if (pdev->qdev.info->vmsd)
1741
        snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->vmsd->name);
1742
    if (qdev_get_info(&pdev->qdev)->vmsd)
1743
        snprintf(name, sizeof(name), "%s.rom", qdev_get_info(&pdev->qdev)->vmsd->name);
1742 1744
    else
1743
        snprintf(name, sizeof(name), "%s.rom", pdev->qdev.info->name);
1745
        snprintf(name, sizeof(name), "%s.rom", qdev_get_info(&pdev->qdev)->name);
1744 1746
    pdev->has_rom = true;
1745 1747
    memory_region_init_ram(&pdev->rom, name, size);
1746 1748
    vmstate_register_ram(&pdev->rom, &pdev->qdev);
......
1981 1983
    }
1982 1984

  
1983 1985
    /* roughly check if given qdev is pci device */
1984
    if (qdev->info->init == &pci_qdev_init &&
1986
    if (qdev_get_info(qdev)->init == &pci_qdev_init &&
1985 1987
        qdev->parent_bus->info == &pci_bus_info) {
1986 1988
        *pdev = DO_UPCAST(PCIDevice, qdev, qdev);
1987 1989
        return 0;
b/hw/pcnet.c
1718 1718
    s->poll_timer = qemu_new_timer_ns(vm_clock, pcnet_poll_timer, s);
1719 1719

  
1720 1720
    qemu_macaddr_default_if_unset(&s->conf.macaddr);
1721
    s->nic = qemu_new_nic(info, &s->conf, dev->info->name, dev->id, s);
1721
    s->nic = qemu_new_nic(info, &s->conf, qdev_get_info(dev)->name, dev->id, s);
1722 1722
    qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
1723 1723

  
1724 1724
    add_boot_device_path(s->conf.bootindex, dev, "/ethernet-phy@0");
b/hw/qdev-properties.c
966 966
    Property *prop;
967 967

  
968 968
    /* device properties */
969
    prop = qdev_prop_walk(dev->info->props, name);
969
    prop = qdev_prop_walk(qdev_get_info(dev)->props, name);
970 970
    if (prop)
971 971
        return prop;
972 972

  
......
989 989
    switch (ret) {
990 990
    case -EEXIST:
991 991
        error_set(errp, QERR_PROPERTY_VALUE_IN_USE,
992
                  dev->info->name, prop->name, value);
992
                  qdev_get_info(dev)->name, prop->name, value);
993 993
        break;
994 994
    default:
995 995
    case -EINVAL:
996 996
        error_set(errp, QERR_PROPERTY_VALUE_BAD,
997
                  dev->info->name, prop->name, value);
997
                  qdev_get_info(dev)->name, prop->name, value);
998 998
        break;
999 999
    case -ENOENT:
1000 1000
        error_set(errp, QERR_PROPERTY_VALUE_NOT_FOUND,
1001
                  dev->info->name, prop->name, value);
1001
                  qdev_get_info(dev)->name, prop->name, value);
1002 1002
        break;
1003 1003
    case 0:
1004 1004
        break;
......
1018 1018
     * removed along with it.
1019 1019
     */
1020 1020
    if (!prop || !prop->info->parse) {
1021
        qerror_report(QERR_PROPERTY_NOT_FOUND, dev->info->name, name);
1021
        qerror_report(QERR_PROPERTY_NOT_FOUND, qdev_get_info(dev)->name, name);
1022 1022
        return -1;
1023 1023
    }
1024 1024
    ret = prop->info->parse(dev, prop, value);
......
1039 1039
    prop = qdev_prop_find(dev, name);
1040 1040
    if (!prop) {
1041 1041
        fprintf(stderr, "%s: property \"%s.%s\" not found\n",
1042
                __FUNCTION__, dev->info->name, name);
1042
                __FUNCTION__, qdev_get_info(dev)->name, name);
1043 1043
        abort();
1044 1044
    }
1045 1045
    if (prop->info->type != type) {
1046 1046
        fprintf(stderr, "%s: property \"%s.%s\" type mismatch\n",
1047
                __FUNCTION__, dev->info->name, name);
1047
                __FUNCTION__, qdev_get_info(dev)->name, name);
1048 1048
        abort();
1049 1049
    }
1050 1050
    qdev_prop_cpy(dev, prop, src);
......
1093 1093
    if (res < 0) {
1094 1094
        error_report("Can't attach drive %s to %s.%s: %s",
1095 1095
                     bdrv_get_device_name(value),
1096
                     dev->id ? dev->id : dev->info->name,
1096
                     dev->id ? dev->id : qdev_get_info(dev)->name,
1097 1097
                     name, strerror(-res));
1098 1098
        return -1;
1099 1099
    }
......
1165 1165
    GlobalProperty *prop;
1166 1166

  
1167 1167
    QTAILQ_FOREACH(prop, &global_props, next) {
1168
        if (strcmp(dev->info->name, prop->driver) != 0 &&
1169
            strcmp(dev->info->bus_info->name, prop->driver) != 0) {
1168
        if (strcmp(qdev_get_info(dev)->name, prop->driver) != 0 &&
1169
            strcmp(qdev_get_info(dev)->bus_info->name, prop->driver) != 0) {
1170 1170
            continue;
1171 1171
        }
1172 1172
        if (qdev_prop_parse(dev, prop->property, prop->value) != 0) {
b/hw/qdev.c
45 45
static BusState *qbus_find(const char *path);
46 46

  
47 47
/* Register a new device type.  */
48
static void qdev_subclass_init(ObjectClass *klass, void *data)
49
{
50
    DeviceClass *dc = DEVICE_CLASS(klass);
51
    dc->info = data;
52
}
53

  
54
DeviceInfo *qdev_get_info(DeviceState *dev)
55
{
56
    return DEVICE_GET_CLASS(dev)->info;
57
}
58

  
48 59
void qdev_register(DeviceInfo *info)
49 60
{
50 61
    TypeInfo type_info = {};
......
55 66
    type_info.name = info->name;
56 67
    type_info.parent = TYPE_DEVICE;
57 68
    type_info.instance_size = info->size;
69
    type_info.class_init = qdev_subclass_init;
70
    type_info.class_data = info;
58 71

  
59 72
    type_register_static(&type_info);
60 73

  
......
102 115

  
103 116
    assert(bus->info == info->bus_info);
104 117
    dev = DEVICE(object_new(info->name));
105
    dev->info = info;
106 118
    dev->parent_bus = bus;
107
    qdev_prop_set_defaults(dev, dev->info->props);
119
    qdev_prop_set_defaults(dev, qdev_get_info(dev)->props);
108 120
    qdev_prop_set_defaults(dev, dev->parent_bus->info->props);
109 121
    qdev_prop_set_globals(dev);
110 122
    QTAILQ_INSERT_HEAD(&bus->children, dev, sibling);
......
117 129
    QTAILQ_INIT(&dev->properties);
118 130
    dev->state = DEV_STATE_CREATED;
119 131

  
120
    for (prop = dev->info->props; prop && prop->name; prop++) {
132
    for (prop = qdev_get_info(dev)->props; prop && prop->name; prop++) {
121 133
        qdev_property_add_legacy(dev, prop, NULL);
122 134
        qdev_property_add_static(dev, prop, NULL);
123 135
    }
124 136

  
125
    for (prop = dev->info->bus_info->props; prop && prop->name; prop++) {
137
    for (prop = qdev_get_info(dev)->bus_info->props; prop && prop->name; prop++) {
126 138
        qdev_property_add_legacy(dev, prop, NULL);
127 139
        qdev_property_add_static(dev, prop, NULL);
128 140
    }
......
355 367
    int rc;
356 368

  
357 369
    assert(dev->state == DEV_STATE_CREATED);
358
    rc = dev->info->init(dev, dev->info);
370
    rc = qdev_get_info(dev)->init(dev, qdev_get_info(dev));
359 371
    if (rc < 0) {
360 372
        qdev_free(dev);
361 373
        return rc;
362 374
    }
363
    if (dev->info->vmsd) {
364
        vmstate_register_with_alias_id(dev, -1, dev->info->vmsd, dev,
375
    if (qdev_get_info(dev)->vmsd) {
376
        vmstate_register_with_alias_id(dev, -1, qdev_get_info(dev)->vmsd, dev,
365 377
                                       dev->instance_id_alias,
366 378
                                       dev->alias_required_for_version);
367 379
    }
368 380
    dev->state = DEV_STATE_INITIALIZED;
369
    if (dev->hotplugged && dev->info->reset) {
370
        dev->info->reset(dev);
381
    if (dev->hotplugged && qdev_get_info(dev)->reset) {
382
        qdev_get_info(dev)->reset(dev);
371 383
    }
372 384
    return 0;
373 385
}
......
386 398
        qerror_report(QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
387 399
        return -1;
388 400
    }
389
    assert(dev->info->unplug != NULL);
401
    assert(qdev_get_info(dev)->unplug != NULL);
390 402

  
391 403
    qdev_hot_removed = true;
392 404

  
393
    return dev->info->unplug(dev);
405
    return qdev_get_info(dev)->unplug(dev);
394 406
}
395 407

  
396 408
static int qdev_reset_one(DeviceState *dev, void *opaque)
397 409
{
398
    if (dev->info->reset) {
399
        dev->info->reset(dev);
410
    if (qdev_get_info(dev)->reset) {
411
        qdev_get_info(dev)->reset(dev);
400 412
    }
401 413

  
402 414
    return 0;
......
447 459
   way is somewhat unclean, and best avoided.  */
448 460
void qdev_init_nofail(DeviceState *dev)
449 461
{
450
    DeviceInfo *info = dev->info;
462
    DeviceInfo *info = qdev_get_info(dev);
451 463

  
452 464
    if (qdev_init(dev) < 0) {
453 465
        error_report("Initialization of device %s failed", info->name);
......
508 520
            bus = QLIST_FIRST(&dev->child_bus);
509 521
            qbus_free(bus);
510 522
        }
511
        if (dev->info->vmsd)
512
            vmstate_unregister(dev, dev->info->vmsd, dev);
513
        if (dev->info->exit)
514
            dev->info->exit(dev);
523
        if (qdev_get_info(dev)->vmsd)
524
            vmstate_unregister(dev, qdev_get_info(dev)->vmsd, dev);
525
        if (qdev_get_info(dev)->exit)
526
            qdev_get_info(dev)->exit(dev);
515 527
        if (dev->opts)
516 528
            qemu_opts_del(dev->opts);
517 529
    }
518 530
    QTAILQ_REMOVE(&dev->parent_bus->children, dev, sibling);
519
    for (prop = dev->info->props; prop && prop->name; prop++) {
531
    for (prop = qdev_get_info(dev)->props; prop && prop->name; prop++) {
520 532
        if (prop->info->free) {
521 533
            prop->info->free(dev, prop);
522 534
        }
......
708 720
    const char *sep = " ";
709 721

  
710 722
    error_printf("child busses at \"%s\":",
711
                 dev->id ? dev->id : dev->info->name);
723
                 dev->id ? dev->id : qdev_get_info(dev)->name);
712 724
    QLIST_FOREACH(child, &dev->child_bus, sibling) {
713 725
        error_printf("%s\"%s\"", sep, child->name);
714 726
        sep = ", ";
......
723 735

  
724 736
    error_printf("devices at \"%s\":", bus->name);
725 737
    QTAILQ_FOREACH(dev, &bus->children, sibling) {
726
        error_printf("%s\"%s\"", sep, dev->info->name);
738
        error_printf("%s\"%s\"", sep, qdev_get_info(dev)->name);
727 739
        if (dev->id)
728 740
            error_printf("/\"%s\"", dev->id);
729 741
        sep = ", ";
......
759 771
        }
760 772
    }
761 773
    QTAILQ_FOREACH(dev, &bus->children, sibling) {
762
        if (strcmp(dev->info->name, elem) == 0) {
774
        if (strcmp(qdev_get_info(dev)->name, elem) == 0) {
763 775
            return dev;
764 776
        }
765 777
    }
766 778
    QTAILQ_FOREACH(dev, &bus->children, sibling) {
767
        if (dev->info->alias && strcmp(dev->info->alias, elem) == 0) {
779
        if (qdev_get_info(dev)->alias && strcmp(qdev_get_info(dev)->alias, elem) == 0) {
768 780
            return dev;
769 781
        }
770 782
    }
......
966 978
static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
967 979
{
968 980
    BusState *child;
969
    qdev_printf("dev: %s, id \"%s\"\n", dev->info->name,
981
    qdev_printf("dev: %s, id \"%s\"\n", qdev_get_info(dev)->name,
970 982
                dev->id ? dev->id : "");
971 983
    indent += 2;
972 984
    if (dev->num_gpio_in) {
......
975 987
    if (dev->num_gpio_out) {
976 988
        qdev_printf("gpio-out %d\n", dev->num_gpio_out);
977 989
    }
978
    qdev_print_props(mon, dev, dev->info->props, "dev", indent);
990
    qdev_print_props(mon, dev, qdev_get_info(dev)->props, "dev", indent);
979 991
    qdev_print_props(mon, dev, dev->parent_bus->info->props, "bus", indent);
980 992
    if (dev->parent_bus->info->print_dev)
981 993
        dev->parent_bus->info->print_dev(mon, dev, indent);
......
1056 1068
            l += snprintf(p + l, size - l, "%s", d);
1057 1069
            g_free(d);
1058 1070
        } else {
1059
            l += snprintf(p + l, size - l, "%s", dev->info->name);
1071
            l += snprintf(p + l, size - l, "%s", qdev_get_info(dev)->name);
1060 1072
        }
1061 1073
    }
1062 1074
    l += snprintf(p + l , size - l, "/");
......
1078 1090

  
1079 1091
char *qdev_get_type(DeviceState *dev, Error **errp)
1080 1092
{
1081
    return g_strdup(dev->info->name);
1093
    return g_strdup(qdev_get_info(dev)->name);
1082 1094
}
1083 1095

  
1084 1096
void qdev_ref(DeviceState *dev)
......
1288 1300
{
1289 1301
    gchar *type;
1290 1302

  
1291
    type = g_strdup_printf("child<%s>", child->info->name);
1303
    type = g_strdup_printf("child<%s>", qdev_get_info(child)->name);
1292 1304

  
1293 1305
    qdev_property_add(dev, name, type, qdev_get_child_property,
1294 1306
                      NULL, qdev_release_child_property,
......
1340 1352
        if (target) {
1341 1353
            gchar *target_type;
1342 1354

  
1343
            target_type = g_strdup_printf("link<%s>", target->info->name);
1355
            target_type = g_strdup_printf("link<%s>", qdev_get_info(target)->name);
1344 1356
            if (strcmp(target_type, type) == 0) {
1345 1357
                *child = target;
1346 1358
                qdev_ref(target);
b/hw/qdev.h
69 69

  
70 70
#define TYPE_DEVICE "device"
71 71
#define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)
72
#define DEVICE_CLASS(klass) OBJECT_CLASS_CHECK(DeviceClass, (klass), TYPE_DEVICE)
73
#define DEVICE_GET_CLASS(obj) OBJECT_GET_CLASS(DeviceClass, (obj), TYPE_DEVICE)
72 74

  
73 75
typedef struct DeviceClass {
74 76
    ObjectClass parent_class;
77
    DeviceInfo *info;
75 78
} DeviceClass;
76 79

  
77 80
/* This structure should not be accessed directly.  We declare it here
......
83 86
    enum DevState state;
84 87
    QemuOpts *opts;
85 88
    int hotplugged;
86
    DeviceInfo *info;
87 89
    BusState *parent_bus;
88 90
    int num_gpio_out;
89 91
    qemu_irq *gpio_out;
......
389 391
void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
390 392
                                    Property *prop, const char *value);
391 393

  
394
DeviceInfo *qdev_get_info(DeviceState *dev);
395

  
392 396
static inline const char *qdev_fw_name(DeviceState *dev)
393 397
{
394
    return dev->info->fw_name ? : dev->info->alias ? : dev->info->name;
398
    DeviceInfo *info = qdev_get_info(dev);
399

  
400
    if (info->fw_name) {
401
        return info->fw_name;
402
    } else if (info->alias) {
403
        return info->alias;
404
    }
405

  
406
    return info->name;
395 407
}
396 408

  
397 409
char *qdev_get_fw_dev_path(DeviceState *dev);
b/hw/rtl8139.c
3478 3478
    s->eeprom.contents[9] = s->conf.macaddr.a[4] | s->conf.macaddr.a[5] << 8;
3479 3479

  
3480 3480
    s->nic = qemu_new_nic(&net_rtl8139_info, &s->conf,
3481
                          dev->qdev.info->name, dev->qdev.id, s);
3481
                          qdev_get_info(&dev->qdev)->name, dev->qdev.id, s);
3482 3482
    qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
3483 3483

  
3484 3484
    s->cplus_txbuffer = NULL;
b/hw/smc91c111.c
752 752
    sysbus_init_irq(dev, &s->irq);
753 753
    qemu_macaddr_default_if_unset(&s->conf.macaddr);
754 754
    s->nic = qemu_new_nic(&net_smc91c111_info, &s->conf,
755
                          dev->qdev.info->name, dev->qdev.id, s);
755
                          qdev_get_info(&dev->qdev)->name, dev->qdev.id, s);
756 756
    qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
757 757
    /* ??? Save/restore.  */
758 758
    return 0;
b/hw/spapr_vio.c
75 75

  
76 76
static char *vio_format_dev_name(VIOsPAPRDevice *dev)
77 77
{
78
    VIOsPAPRDeviceInfo *info = (VIOsPAPRDeviceInfo *)dev->qdev.info;
78
    VIOsPAPRDeviceInfo *info = (VIOsPAPRDeviceInfo *)qdev_get_info(&dev->qdev);
79 79
    char *name;
80 80

  
81 81
    /* Device tree style name device@reg */
......
90 90
static int vio_make_devnode(VIOsPAPRDevice *dev,
91 91
                            void *fdt)
92 92
{
93
    VIOsPAPRDeviceInfo *info = (VIOsPAPRDeviceInfo *)dev->qdev.info;
93
    VIOsPAPRDeviceInfo *info = (VIOsPAPRDeviceInfo *)qdev_get_info(&dev->qdev);
94 94
    int vdevice_off, node_off, ret;
95 95
    char *dt_name;
96 96

  
......
700 700
        return H_PARAMETER;
701 701
    }
702 702

  
703
    info = (VIOsPAPRDeviceInfo *)dev->qdev.info;
703
    info = (VIOsPAPRDeviceInfo *)qdev_get_info(&dev->qdev);
704 704

  
705 705
    if (mode & ~info->signal_mask) {
706 706
        return H_PARAMETER;
b/hw/spapr_vty.c
163 163
    selected = NULL;
164 164
    QTAILQ_FOREACH(iter, &bus->bus.children, sibling) {
165 165
        /* Only look at VTY devices */
166
        if (iter->info != &spapr_vty.qdev) {
166
        if (qdev_get_info(iter) != &spapr_vty.qdev) {
167 167
            continue;
168 168
        }
169 169

  
b/hw/usb-bus.c
250 250
            return -1;
251 251
        }
252 252
    } else {
253
        if (bus->nfree == 1 && strcmp(dev->qdev.info->name, "usb-hub") != 0) {
253
        if (bus->nfree == 1 && strcmp(qdev_get_info(&dev->qdev)->name, "usb-hub") != 0) {
254 254
            /* Create a new hub and chain it on */
255 255
            usb_create_simple(bus, "usb-hub");
256 256
        }
b/hw/usb-ccid.c
1114 1114
{
1115 1115
    int ret = 0;
1116 1116
    CCIDCardState *card = DO_UPCAST(CCIDCardState, qdev, qdev);
1117
    CCIDCardInfo *info = DO_UPCAST(CCIDCardInfo, qdev, qdev->info);
1117
    CCIDCardInfo *info = DO_UPCAST(CCIDCardInfo, qdev, qdev_get_info(qdev));
1118 1118
    USBCCIDState *s =
1119 1119
        DO_UPCAST(USBCCIDState, dev.qdev, card->qdev.parent_bus->parent);
1120 1120

  
b/hw/usb-net.c
1337 1337

  
1338 1338
    qemu_macaddr_default_if_unset(&s->conf.macaddr);
1339 1339
    s->nic = qemu_new_nic(&net_usbnet_info, &s->conf,
1340
                          s->dev.qdev.info->name, s->dev.qdev.id, s);
1340
                          qdev_get_info(&s->dev.qdev)->name, s->dev.qdev.id, s);
1341 1341
    qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
1342 1342
    snprintf(s->usbstring_mac, sizeof(s->usbstring_mac),
1343 1343
             "%02x%02x%02x%02x%02x%02x",
b/hw/usb-ohci.c
1777 1777
    memory_region_init_io(&ohci->mem, &ohci_mem_ops, ohci, "ohci", 256);
1778 1778
    ohci->localmem_base = localmem_base;
1779 1779

  
1780
    ohci->name = dev->info->name;
1780
    ohci->name = qdev_get_info(dev)->name;
1781 1781
    usb_packet_init(&ohci->usb_packet);
1782 1782

  
1783 1783
    ohci->async_td = 0;
b/hw/virtio-console.c
110 110
{
111 111
    VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
112 112
    VirtIOSerialPortInfo *info = DO_UPCAST(VirtIOSerialPortInfo, qdev,
113
                                           vcon->port.dev.info);
113
                                           qdev_get_info(&vcon->port.dev));
114 114

  
115 115
    if (port->id == 0 && !info->is_console) {
116 116
        error_report("Port number 0 on virtio-serial devices reserved for virtconsole devices for backward compatibility.");
b/hw/virtio-net.c
1030 1030
    memcpy(&n->mac[0], &conf->macaddr, sizeof(n->mac));
1031 1031
    n->status = VIRTIO_NET_S_LINK_UP;
1032 1032

  
1033
    n->nic = qemu_new_nic(&net_virtio_info, conf, dev->info->name, dev->id, n);
1033
    n->nic = qemu_new_nic(&net_virtio_info, conf, qdev_get_info(dev)->name, dev->id, n);
1034 1034

  
1035 1035
    qemu_format_nic_info_str(&n->nic->nc, conf->macaddr.a);
1036 1036

  
b/hw/virtio-serial-bus.c
138 138
    assert(port);
139 139
    assert(virtio_queue_ready(vq));
140 140

  
141
    info = DO_UPCAST(VirtIOSerialPortInfo, qdev, port->dev.info);
141
    info = DO_UPCAST(VirtIOSerialPortInfo, qdev, qdev_get_info(&port->dev));
142 142

  
143 143
    while (!port->throttled) {
144 144
        unsigned int i;
......
373 373

  
374 374
    trace_virtio_serial_handle_control_message_port(port->id);
375 375

  
376
    info = DO_UPCAST(VirtIOSerialPortInfo, qdev, port->dev.info);
376
    info = DO_UPCAST(VirtIOSerialPortInfo, qdev, qdev_get_info(&port->dev));
377 377

  
378 378
    switch(cpkt.event) {
379 379
    case VIRTIO_CONSOLE_PORT_READY:
......
824 824
{
825 825
    VirtIOSerialPort *port = DO_UPCAST(VirtIOSerialPort, dev, qdev);
826 826
    VirtIOSerialPortInfo *info = DO_UPCAST(VirtIOSerialPortInfo, qdev,
827
                                           port->dev.info);
827
                                           qdev_get_info(&port->dev));
828 828
    VirtIOSerial *vser = port->vser;
829 829

  
830 830
    qemu_bh_delete(port->bh);
b/hw/xgmac.c
390 390

  
391 391
    qemu_macaddr_default_if_unset(&s->conf.macaddr);
392 392
    s->nic = qemu_new_nic(&net_xgmac_enet_info, &s->conf,
393
                          dev->qdev.info->name, dev->qdev.id, s);
393
                          qdev_get_info(&dev->qdev)->name, dev->qdev.id, s);
394 394
    qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
395 395

  
396 396
    s->regs[XGMAC_ADDR_HIGH(0)] = (s->conf.macaddr.a[5] << 8) |

Also available in: Unified diff