Skip to contentSkip to conversation

QOM devices patch queue 2013-12-24

GIT PULL Andreas Färber 1 participant 26 messages Dec 24, 2013

lore
Share & tools
lore
#1 lore raw

[Qemu-devel] [PULL 03/24] cpu: Document why cannot_instantiate_with_device_add_yet

In reply to Andreas Färber

From: Markus Armbruster <[email protected]>

---
 qom/cpu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
qom/cpu.c +5 -1
index 09c15e6..9d62479 100644
@@ -254,7 +254,11 @@ static void cpu_class_init(ObjectClass *klass, void *data)
     k->gdb_read_register = cpu_common_gdb_read_register;
     k->gdb_write_register = cpu_common_gdb_write_register;
     dc->realize = cpu_common_realizefn;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
+    /*
+     * Reason: CPUs still need special care by board code: wiring up
+     * IRQs, adding reset handlers, halting non-first CPUs, ...
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo cpu_type_info = {
Signature · 1 line
1.8.4
#0 lore raw

Hello Anthony,

This is my QOM (devices) patch queue. Please pull.

Happy holidays,

Andreas

P.S. I reproducibly get a signal message:
TEST: tests/acpi-test... (pid=6364)
/i386/acpi/tcg: main-loop: WARNING: I/O thread spun for 1000 iterations
qemu: terminating on signal 15 from pid 6364 OK
PASS: tests/acpi-test
both before and after the queue.

Cc Anthony Liguori <[email protected]>
Cc Edgar E. Iglesias <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc xiaoqiang zhao <[email protected]>
Cc Hervé Poussineau <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Peter Crosthwaite <[email protected]>
Cc Alexey Kardashevskiy <[email protected]>
Cc Chen Fan <[email protected]>

The following changes since commit f976b09ea249cccc3fd41c98aaf6512908db0bae:

PPC: Fix compilation with TCG debug (2013-12-22 19:15:55 +0100)

are available in the git repository at:

git://github.com/afaerber/qemu-cpu.git tags/qom-devices-for-anthony

for you to fetch changes up to e6111b371b9f8bc98ae566417ed09bce9e86a772:

qdev-monitor: Improve error message for -device nonexistant (2013-12-24 17:27:18 +0100)

----------------------------------------------------------------
QOM infrastructure fixes and device conversions

* QOM interface fixes and unit test
* Device no_user sanitization and documentation
* Device error reporting improvement
* Conversion of APIC, ICC, IOAPIC to QOM realization model

----------------------------------------------------------------
Hervé Poussineau (1):
qom: Detect bad reentrance during object_class_foreach()

Igor Mammedov (1):
tests: Test QOM interface casting

Markus Armbruster (14):
qdev: Replace no_user by cannot_instantiate_with_device_add_yet
sysbus: Set cannot_instantiate_with_device_add_yet
cpu: Document why cannot_instantiate_with_device_add_yet
apic: Document why cannot_instantiate_with_device_add_yet
pci-host: Consistently set cannot_instantiate_with_device_add_yet
ich9: Document why cannot_instantiate_with_device_add_yet piix3 piix4: Clean up use of cannot_instantiate_with_device_add_yet
vt82c686: Clean up use of cannot_instantiate_with_device_add_yet
isa: Clean up use of cannot_instantiate_with_device_add_yet
qdev: Do not let the user try to device_add when it cannot work
qdev-monitor: Avoid device_add crashing on non-device driver name
hw: cannot_instantiate_with_device_add_yet due to pointer props
qdev: Document that pointer properties kill device_add
qdev-monitor: Improve error message for -device nonexistant

Paolo Bonzini (1):
qom: Do not register interface "types" in the type table and fix names

Peter Crosthwaite (1):
qom: Split out object and class caches

Stefan Hajnoczi (1):
qdev: Drop misleading qbus_free() function

xiaoqiang zhao (5):
apic: Cleanup for QOM'ification
apic: QOM'ify APIC
icc_bus: QOM'ify ICC
ioapic: Cleanup for QOM'ification
ioapic: QOM'ify ioapic

 hw/acpi/piix4.c                   |   6 ++-
 hw/alpha/typhoon.c                |   2 -
 hw/arm/versatilepb.c              |   1 -
 hw/audio/marvell_88w8618.c        |   2 +
 hw/audio/pcspk.c                  |   3 +-
 hw/audio/pl041.c                  |   1 -
 hw/block/fdc.c                    |   1 -
 hw/core/qdev.c                    |   7 +--
 hw/core/sysbus.c                  |   7 +++
 hw/cpu/icc_bus.c                  |  14 +++--
 hw/display/pl110.c                |   1 -
 hw/dma/pl080.c                    |   1 -
 hw/dma/sparc32_dma.c              |   2 +
 hw/gpio/omap_gpio.c               |   4 ++
 hw/i2c/omap_i2c.c                 |   2 +
 hw/i2c/smbus_eeprom.c             |   2 +
 hw/i2c/smbus_ich9.c               |   6 ++-
 hw/i386/kvm/apic.c                |  14 ++---
 hw/i386/kvm/clock.c               |   1 -
 hw/i386/kvm/ioapic.c              |   8 +--
 hw/i386/kvmvapic.c                |   1 -
 hw/i386/pc.c                      |   7 ++-
 hw/ide/piix.c                     |   3 --
 hw/ide/via.c                      |   1 -
 hw/input/pckbd.c                  |   1 -
 hw/input/vmmouse.c                |   3 +-
 hw/intc/apic.c                    |  48 ++++++++---------
 hw/intc/apic_common.c             |  79 ++++++++++++++--------------
 hw/intc/arm_gic.c                 |   1 -
 hw/intc/arm_gic_common.c          |   1 -
 hw/intc/arm_gic_kvm.c             |   1 -
 hw/intc/etraxfs_pic.c             |   4 ++
 hw/intc/grlib_irqmp.c             |   2 +
 hw/intc/i8259_common.c            |   8 ++-
 hw/intc/ioapic.c                  |  13 +++--
 hw/intc/ioapic_common.c           |  16 ++++--
 hw/intc/omap_intc.c               |   4 ++
 hw/intc/pl190.c                   |   1 -
 hw/isa/isa-bus.c                  |   1 -
 hw/isa/lpc_ich9.c                 |   7 ++-
 hw/isa/piix4.c                    |   6 ++-
 hw/isa/vt82c686.c                 |   6 ++-
 hw/mips/gt64xxx_pci.c             |   6 +++
 hw/misc/arm_l2x0.c                |   1 -
 hw/misc/vmport.c                  |   3 +-
 hw/net/etraxfs_eth.c              |   2 +
 hw/net/lance.c                    |   2 +
 hw/nvram/fw_cfg.c                 |   1 -
 hw/pci-bridge/dec.c               |   6 +++
 hw/pci-host/apb.c                 |   6 +++
 hw/pci-host/bonito.c              |   8 +--
 hw/pci-host/grackle.c             |   8 +--
 hw/pci-host/piix.c                |  19 +++++--
 hw/pci-host/ppce500.c             |   5 ++
 hw/pci-host/prep.c                |   7 ++-
 hw/pci-host/q35.c                 |   5 ++
 hw/pci-host/uninorth.c            |  24 +++++++++
 hw/pci-host/versatile.c           |   6 +++
 hw/pci/pci_bridge.c               |   2 +-
 hw/ppc/ppc4xx_pci.c               |   5 ++
 hw/ppc/spapr_vio.c                |   2 -
 hw/s390x/ipl.c                    |   1 -
 hw/s390x/s390-virtio-bus.c        |   2 -
 hw/s390x/virtio-ccw.c             |   2 -
 hw/sd/pl181.c                     |   1 -
 hw/sh4/sh_pci.c                   |   6 +++
 hw/timer/arm_mptimer.c            |   1 -
 hw/timer/hpet.c                   |   1 -
 hw/timer/i8254_common.c           |   7 ++-
 hw/timer/m48t59.c                 |   3 +-
 hw/timer/mc146818rtc.c            |   3 +-
 hw/timer/pl031.c                  |   1 -
 hw/xen/xen_apic.c                 |   6 ++-
 include/hw/cpu/icc_bus.h          |   2 +-
 include/hw/i386/apic_internal.h   |   2 +-
 include/hw/i386/ioapic_internal.h |   3 +-
 include/hw/qdev-core.h            |  15 ++++--
 include/hw/qdev-properties.h      |  17 ++++++
 include/qom/object.h              |   4 +-
 qdev-monitor.c                    |  15 ++++--
 qom/cpu.c                         |   6 ++-
 qom/object.c                      |  50 ++++++++++++------
 tests/Makefile                    |   6 ++-
 tests/check-qom-interface.c       | 105 ++++++++++++++++++++++++++++++++++++++
 84 files changed, 493 insertions(+), 183 deletions(-)
 create mode 100644 tests/check-qom-interface.c
#2 lore raw

[Qemu-devel] [PULL 11/24] qdev-monitor: Avoid device_add crashing on non-device driver name

From: Markus Armbruster <[email protected]>

Watch this:

    $ upstream-qemu -nodefaults -S -display none -monitor stdio
    QEMU 1.7.50 monitor - type 'help' for more information
    (qemu) device_add rng-egd
    /work/armbru/qemu/qdev-monitor.c:491:qdev_device_add: Object 0x2089b00 is not an instance of type device
    Aborted (core dumped)

Crashes because "rng-egd" exists, but isn't a subtype of TYPE_DEVICE. Broken in commit 18b6dad.

---
 qdev-monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qdev-monitor.c +1 -1
index 7877d01..177b849 100644
@@ -478,7 +478,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
         }
     }
 
-    if (!oc) {
+    if (!object_class_dynamic_cast(oc, TYPE_DEVICE)) {
         qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver", "device type");
         return NULL;
     }
Signature · 1 line
1.8.4
#3 lore raw

[Qemu-devel] [PULL 08/24] vt82c686: Clean up use of cannot_instantiate_with_device_add_yet

In reply to Andreas Färber

From: Markus Armbruster <[email protected]>

A VT82C686B southbridge has multiple functions. We model each function as a separate qdev. One of them need some special wiring set up in mips_fulong2e_init() to work: the ISA bridge at 05.0.

The IDE controller at 05.1 (via-ide) has always had cannot_instantiate_with_device_add_yet set, but there is no obvious reason why device_add could not work for them. Drop it.

---
 hw/ide/via.c      | 1 -
 hw/isa/vt82c686.c | 6 +++++-
 2 files changed, 5 insertions(+), 2 deletions(-)
hw/ide/via.c +0 -1
index b556c14..198123b 100644
@@ -225,7 +225,6 @@ static void via_ide_class_init(ObjectClass *klass, void *data)
     k->revision = 0x06;
     k->class_id = PCI_CLASS_STORAGE_IDE;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo via_ide_info = {
hw/isa/vt82c686.c +5 -1
index b06d15e..e639357 100644
@@ -480,8 +480,12 @@ static void via_class_init(ObjectClass *klass, void *data)
     k->class_id = PCI_CLASS_BRIDGE_ISA;
     k->revision = 0x40;
     dc->desc = "ISA bridge";
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_via;
+    /*
+     * Reason: part of VIA VT82C686 southbridge, needs to be wired up,
+     * e.g. by mips_fulong2e_init()
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo via_info = {
Signature · 1 line
1.8.4
#4 lore raw

[Qemu-devel] [PULL 02/24] sysbus: Set cannot_instantiate_with_device_add_yet

In reply to Andreas Färber

From: Markus Armbruster <[email protected]>

device_add plugs devices into suitable bus. For "real" buses, that actually connects the device. For sysbus, the connections need to be made separately, and device_add can't do that. The device would be left unconnected, and could not possibly work.

Quite a few, but not all sysbus devices already set cannot_instantiate_with_device_add_yet in their class init function.

Set it in their abstract base's class init function sysbus_device_class_init(), and remove the now redundant assignments from device class init functions.

---
 hw/alpha/typhoon.c         | 2 --
 hw/arm/versatilepb.c       | 1 -
 hw/audio/pl041.c           | 1 -
 hw/core/sysbus.c           | 7 +++++++
 hw/display/pl110.c         | 1 -
 hw/dma/pl080.c             | 1 -
 hw/i386/kvm/clock.c        | 1 -
 hw/i386/kvmvapic.c         | 1 -
 hw/intc/arm_gic.c          | 1 -
 hw/intc/arm_gic_common.c   | 1 -
 hw/intc/arm_gic_kvm.c      | 1 -
 hw/intc/ioapic_common.c    | 1 -
 hw/intc/pl190.c            | 1 -
 hw/isa/isa-bus.c           | 1 -
 hw/misc/arm_l2x0.c         | 1 -
 hw/nvram/fw_cfg.c          | 1 -
 hw/pci-host/bonito.c       | 2 --
 hw/pci-host/grackle.c      | 2 --
 hw/pci-host/piix.c         | 1 -
 hw/pci-host/prep.c         | 1 -
 hw/ppc/spapr_vio.c         | 2 --
 hw/s390x/ipl.c             | 1 -
 hw/s390x/s390-virtio-bus.c | 2 --
 hw/s390x/virtio-ccw.c      | 2 --
 hw/sd/pl181.c              | 1 -
 hw/timer/arm_mptimer.c     | 1 -
 hw/timer/hpet.c            | 1 -
 hw/timer/pl031.c           | 1 -
 28 files changed, 7 insertions(+), 33 deletions(-)
hw/alpha/typhoon.c +0 -2
index 60987ed..71a5a37 100644
@@ -934,11 +934,9 @@ static int typhoon_pcihost_init(SysBusDevice *dev)
 
 static void typhoon_pcihost_class_init(ObjectClass *klass, void *data)
 {
-    DeviceClass *dc = DEVICE_CLASS(klass);
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = typhoon_pcihost_init;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo typhoon_pcihost_info = {
hw/arm/versatilepb.c +0 -1
index bb0c0ba..aef2bde 100644
@@ -390,7 +390,6 @@ static void vpb_sic_class_init(ObjectClass *klass, void *data)
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = vpb_sic_init;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_vpb_sic;
 }
 
hw/audio/pl041.c +0 -1
index 8ba661a..ed82be5 100644
@@ -632,7 +632,6 @@ static void pl041_device_class_init(ObjectClass *klass, void *data)
 
     k->init = pl041_init;
     set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset = pl041_device_reset;
     dc->vmsd = &vmstate_pl041;
     dc->props = pl041_device_properties;
hw/core/sysbus.c +7 -0
index 146f50a..f4e760d 100644
@@ -257,6 +257,13 @@ static void sysbus_device_class_init(ObjectClass *klass, void *data)
     DeviceClass *k = DEVICE_CLASS(klass);
     k->init = sysbus_device_init;
     k->bus_type = TYPE_SYSTEM_BUS;
+    /*
+     * device_add plugs devices into suitable bus.  For "real" buses,
+     * that actually connects the device.  For sysbus, the connections
+     * need to be made separately, and device_add can't do that.  The
+     * device would be left unconnected, and could not possibly work.
+     */
+    k->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo sysbus_device_type_info = {
hw/display/pl110.c +0 -1
index 7ad5972..ab689e9 100644
@@ -496,7 +496,6 @@ static void pl110_class_init(ObjectClass *klass, void *data)
 
     k->init = pl110_initfn;
     set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_pl110;
 }
 
hw/dma/pl080.c +0 -1
index a515621..cb7bda9 100644
@@ -381,7 +381,6 @@ static void pl080_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
 
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_pl080;
 }
 
hw/i386/kvm/clock.c +0 -1
index abd2ce8..892aa02 100644
@@ -114,7 +114,6 @@ static void kvmclock_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = kvmclock_realize;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &kvmclock_vmsd;
 }
 
hw/i386/kvmvapic.c +0 -1
index f1a0a9d..44ee62a 100644
@@ -827,7 +827,6 @@ static void vapic_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset   = vapic_reset;
     dc->vmsd    = &vmstate_vapic;
     dc->realize = vapic_realize;
hw/intc/arm_gic.c +0 -1
index 24ad276..f13a927 100644
@@ -704,7 +704,6 @@ static void arm_gic_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     ARMGICClass *agc = ARM_GIC_CLASS(klass);
 
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     agc->parent_realize = dc->realize;
     dc->realize = arm_gic_realize;
 }
hw/intc/arm_gic_common.c +0 -1
index 214a585..a47004b 100644
@@ -156,7 +156,6 @@ static void arm_gic_common_class_init(ObjectClass *klass, void *data)
     dc->realize = arm_gic_common_realize;
     dc->props = arm_gic_common_properties;
     dc->vmsd = &vmstate_gic;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo arm_gic_common_type = {
hw/intc/arm_gic_kvm.c +0 -1
index a0bbf12..59a3da5 100644
@@ -150,7 +150,6 @@ static void kvm_arm_gic_class_init(ObjectClass *klass, void *data)
     kgc->parent_reset = dc->reset;
     dc->realize = kvm_arm_gic_realize;
     dc->reset = kvm_arm_gic_reset;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo kvm_arm_gic_info = {
hw/intc/ioapic_common.c +0 -1
index cc5a80d..9ba1a26 100644
@@ -98,7 +98,6 @@ static void ioapic_common_class_init(ObjectClass *klass, void *data)
 
     dc->realize = ioapic_common_realize;
     dc->vmsd = &vmstate_ioapic_common;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo ioapic_common_type = {
hw/intc/pl190.c +0 -1
index b16bc02..2bf359a 100644
@@ -273,7 +273,6 @@ static void pl190_class_init(ObjectClass *klass, void *data)
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = pl190_init;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset = pl190_reset;
     dc->vmsd = &vmstate_pl190;
 }
hw/isa/isa-bus.c +0 -1
index 6b2114d..55d0100 100644
@@ -197,7 +197,6 @@ static void isabus_bridge_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->fw_name = "isa";
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo isabus_bridge_info = {
hw/misc/arm_l2x0.c +0 -1
index ceea99d..9e220c9 100644
@@ -179,7 +179,6 @@ static void l2x0_class_init(ObjectClass *klass, void *data)
 
     k->init = l2x0_priv_init;
     dc->vmsd = &vmstate_l2x0;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->props = l2x0_properties;
     dc->reset = l2x0_priv_reset;
 }
hw/nvram/fw_cfg.c +0 -1
index 6075bfc..ee96c16 100644
@@ -599,7 +599,6 @@ static void fw_cfg_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = fw_cfg_realize;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset = fw_cfg_reset;
     dc->vmsd = &vmstate_fw_cfg;
     dc->props = fw_cfg_properties;
hw/pci-host/bonito.c +0 -2
index 2e08e9d..bfb9820 100644
@@ -819,11 +819,9 @@ static const TypeInfo bonito_info = {
 
 static void bonito_pcihost_class_init(ObjectClass *klass, void *data)
 {
-    DeviceClass *dc = DEVICE_CLASS(klass);
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = bonito_pcihost_initfn;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo bonito_pcihost_info = {
hw/pci-host/grackle.c +0 -2
index ba6017f..b0da33d 100644
@@ -143,10 +143,8 @@ static const TypeInfo grackle_pci_info = {
 static void pci_grackle_class_init(ObjectClass *klass, void *data)
 {
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
-    DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init = pci_grackle_init_device;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo grackle_pci_host_info = {
hw/pci-host/piix.c +0 -1
index 333358e..98ebe6c 100644
@@ -727,7 +727,6 @@ static void i440fx_pcihost_class_init(ObjectClass *klass, void *data)
     hc->root_bus_path = i440fx_pcihost_root_bus_path;
     dc->realize = i440fx_pcihost_realize;
     dc->fw_name = "pci";
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->props = i440fx_props;
 }
 
hw/pci-host/prep.c +0 -1
index 58b8c5e..ebc40c6 100644
@@ -215,7 +215,6 @@ static void raven_pcihost_class_init(ObjectClass *klass, void *data)
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->realize = raven_pcihost_realizefn;
     dc->fw_name = "pci";
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo raven_pcihost_info = {
hw/ppc/spapr_vio.c +0 -2
index e328f53..4e33f46 100644
@@ -528,11 +528,9 @@ static int spapr_vio_bridge_init(SysBusDevice *dev)
 
 static void spapr_vio_bridge_class_init(ObjectClass *klass, void *data)
 {
-    DeviceClass *dc = DEVICE_CLASS(klass);
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = spapr_vio_bridge_init;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo spapr_vio_bridge_info = {
hw/s390x/ipl.c +0 -1
index 26a717c..1a6397b 100644
@@ -182,7 +182,6 @@ static void s390_ipl_class_init(ObjectClass *klass, void *data)
     k->init = s390_ipl_init;
     dc->props = s390_ipl_properties;
     dc->reset = s390_ipl_reset;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo s390_ipl_info = {
hw/s390x/s390-virtio-bus.c +0 -2
index eccc3e7..46c5ff1 100644
@@ -676,11 +676,9 @@ static int s390_virtio_bridge_init(SysBusDevice *dev)
 
 static void s390_virtio_bridge_class_init(ObjectClass *klass, void *data)
 {
-    DeviceClass *dc = DEVICE_CLASS(klass);
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = s390_virtio_bridge_init;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo s390_virtio_bridge_info = {
hw/s390x/virtio-ccw.c +0 -2
index 3be9268..4b6250d 100644
@@ -1283,11 +1283,9 @@ static int virtual_css_bridge_init(SysBusDevice *dev)
 
 static void virtual_css_bridge_class_init(ObjectClass *klass, void *data)
 {
-    DeviceClass *dc = DEVICE_CLASS(klass);
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = virtual_css_bridge_init;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo virtual_css_bridge_info = {
hw/sd/pl181.c +0 -1
index d830188..462558b 100644
@@ -506,7 +506,6 @@ static void pl181_class_init(ObjectClass *klass, void *data)
     sdc->init = pl181_init;
     k->vmsd = &vmstate_pl181;
     k->reset = pl181_reset;
-    k->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo pl181_info = {
hw/timer/arm_mptimer.c +0 -1
index 1dc44cd..35a0a23 100644
@@ -274,7 +274,6 @@ static void arm_mptimer_class_init(ObjectClass *klass, void *data)
     dc->realize = arm_mptimer_realize;
     dc->vmsd = &vmstate_arm_mptimer;
     dc->reset = arm_mptimer_reset;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->props = arm_mptimer_properties;
 }
 
hw/timer/hpet.c +0 -1
index 74e0297..2fbbeb1 100644
@@ -765,7 +765,6 @@ static void hpet_device_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = hpet_realize;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset = hpet_reset;
     dc->vmsd = &vmstate_hpet;
     dc->props = hpet_device_properties;
hw/timer/pl031.c +0 -1
index 2f7360c..34d9b44 100644
@@ -251,7 +251,6 @@ static void pl031_class_init(ObjectClass *klass, void *data)
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = pl031_init;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_pl031;
 }
 
Signature · 1 line
1.8.4
#5 lore raw

[Qemu-devel] [PULL 04/24] apic: Document why cannot_instantiate_with_device_add_yet

In reply to Andreas Färber

From: Markus Armbruster <[email protected]>

---
 hw/intc/apic_common.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/intc/apic_common.c +5 -1
index ea420c7..aaef054 100644
@@ -386,9 +386,13 @@ static void apic_common_class_init(ObjectClass *klass, void *data)
 
     dc->vmsd = &vmstate_apic_common;
     dc->reset = apic_reset_common;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->props = apic_properties_common;
     idc->init = apic_init_common;
+    /*
+     * Reason: APIC and CPU need to be wired up by
+     * x86_cpu_apic_create()
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo apic_common_type = {
Signature · 1 line
1.8.4
#6 lore raw

[Qemu-devel] [PULL 06/24] ich9: Document why cannot_instantiate_with_device_add_yet

In reply to Andreas Färber

From: Markus Armbruster <[email protected]>

An ICH9 southbridge contains several PCI devices, some of them with multiple functions. We model each function as a separate qdev. Two of them need some special wiring set up in pc_q35_init() to work: the LPC controller at 00:1f.0, and the SMBus controller at 00:1f.3.

---
 hw/i2c/smbus_ich9.c | 6 +++++-
 hw/isa/lpc_ich9.c   | 7 +++++--
 2 files changed, 10 insertions(+), 3 deletions(-)
hw/i2c/smbus_ich9.c +5 -1
index c1ffa34..8d47eaf 100644
@@ -97,11 +97,15 @@ static void ich9_smb_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_INTEL_ICH9_6;
     k->revision = ICH9_A2_SMB_REVISION;
     k->class_id = PCI_CLASS_SERIAL_SMBUS;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_ich9_smbus;
     dc->desc = "ICH9 SMBUS Bridge";
     k->init = ich9_smbus_initfn;
     k->config_write = ich9_smbus_write_config;
+    /*
+     * Reason: part of ICH9 southbridge, needs to be wired up by
+     * pc_q35_init()
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 i2c_bus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base)
hw/isa/lpc_ich9.c +5 -2
index c1ca4d4..51ce12d 100644
@@ -644,14 +644,17 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)
     dc->reset = ich9_lpc_reset;
     k->init = ich9_lpc_initfn;
     dc->vmsd = &vmstate_ich9_lpc;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     k->config_write = ich9_lpc_config_write;
     dc->desc = "ICH9 LPC bridge";
     k->vendor_id = PCI_VENDOR_ID_INTEL;
     k->device_id = PCI_DEVICE_ID_INTEL_ICH9_8;
     k->revision = ICH9_A2_LPC_REVISION;
     k->class_id = PCI_CLASS_BRIDGE_ISA;
-
+    /*
+     * Reason: part of ICH9 southbridge, needs to be wired up by
+     * pc_q35_init()
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo ich9_lpc_info = {
Signature · 1 line
1.8.4
#7 lore raw

[Qemu-devel] [PULL 09/24] isa: Clean up use of cannot_instantiate_with_device_add_yet

In reply to Andreas Färber

From: Markus Armbruster <[email protected]>

Drop it when there's no obvious reason why device_add could not work. Else keep and document why.

* isa-fdc: drop

* i8042: drop, even though its I/O base is hardcoded (because you could conceivably still add one to a board that has none), and even though PC board code wires up the A20 line (because that wiring is optional)

* port92: keep because it needs additional wiring by port92_init()

* mc146818rtc: keep because it needs to be wired up by rtc_init()

* m48t59_isa: keep because needs to be wired up by m48t59_init_isa()

* isa-pit, kvm-pit: keep (in their abstract base pic-common) because the PIT needs additional wiring by board code, depending on HPET presence

* pcspk: keep because of pointer property pit, and because realize sets global pcspk_state

* vmmouse: keep because of pointer property ps2_mouse

* vmport: keep because realize sets global port_state

* isa-i8259, kvm-i8259: keep (in their abstract base pic-common), because the PICs' IRQ input lines are set up by board code, and the wiring of the slave to the master is hard-coded in device model code

---
 hw/audio/pcspk.c        | 3 ++-
 hw/block/fdc.c          | 1 -
 hw/i386/pc.c            | 7 ++++++-
 hw/input/pckbd.c        | 1 -
 hw/input/vmmouse.c      | 3 ++-
 hw/intc/i8259_common.c  | 8 +++++++-
 hw/misc/vmport.c        | 3 ++-
 hw/timer/i8254_common.c | 7 ++++++-
 hw/timer/m48t59.c       | 3 ++-
 hw/timer/mc146818rtc.c  | 3 ++-
 10 files changed, 29 insertions(+), 10 deletions(-)
hw/audio/pcspk.c +2 -1
index 8e3e178..f980d66 100644
@@ -192,8 +192,9 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data)
 
     dc->realize = pcspk_realizefn;
     set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->props = pcspk_properties;
+    /* Reason: pointer property "pit", realize sets global pcspk_state */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo pcspk_info = {
hw/block/fdc.c +0 -1
index 86f4920..592b58f 100644
@@ -2234,7 +2234,6 @@ static void isabus_fdc_class_init(ObjectClass *klass, void *data)
 
     dc->realize = isabus_fdc_realize;
     dc->fw_name = "fdc";
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset = fdctrl_external_reset_isa;
     dc->vmsd = &vmstate_isa_fdc;
     dc->props = isa_fdc_properties;
hw/i386/pc.c +6 -1
index 1e6e8af..e9831ca 100644
@@ -547,10 +547,15 @@ static void port92_class_initfn(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->realize = port92_realizefn;
     dc->reset = port92_reset;
     dc->vmsd = &vmstate_port92_isa;
+    /*
+     * Reason: unlike ordinary ISA devices, this one needs additional
+     * wiring: its A20 output line needs to be wired up by
+     * port92_init().
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo port92_info = {
hw/input/pckbd.c +0 -1
index dee31a6..655b8c5 100644
@@ -522,7 +522,6 @@ static void i8042_class_initfn(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = i8042_realizefn;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_kbd_isa;
 }
 
hw/input/vmmouse.c +2 -1
index 600e4a2..6a50533 100644
@@ -282,10 +282,11 @@ static void vmmouse_class_initfn(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = vmmouse_realizefn;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset = vmmouse_reset;
     dc->vmsd = &vmstate_vmmouse;
     dc->props = vmmouse_properties;
+    /* Reason: pointer property "ps2_mouse" */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo vmmouse_info = {
hw/intc/i8259_common.c +7 -1
index 2acdbfe..9d29399 100644
@@ -135,9 +135,15 @@ static void pic_common_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->vmsd = &vmstate_pic_common;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->props = pic_properties_common;
     dc->realize = pic_common_realize;
+    /*
+     * Reason: unlike ordinary ISA devices, the PICs need additional
+     * wiring: its IRQ input lines are set up by board code, and the
+     * wiring of the slave to the master is hard-coded in device model
+     * code.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo pic_common_type = {
hw/misc/vmport.c +2 -1
index 94ae6ae..cd5716a 100644
@@ -162,7 +162,8 @@ static void vmport_class_initfn(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = vmport_realizefn;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
+    /* Reason: realize sets global port_state */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo vmport_info = {
hw/timer/i8254_common.c +6 -1
index dc2196c..9db5c9d 100644
@@ -282,7 +282,12 @@ static void pit_common_class_init(ObjectClass *klass, void *data)
 
     dc->realize = pit_common_realize;
     dc->vmsd = &vmstate_pit_common;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
+    /*
+     * Reason: unlike ordinary ISA devices, the PIT may need to be
+     * wired to the HPET, and because of that, some wiring is always
+     * done by board code.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo pit_common_type = {
hw/timer/m48t59.c +2 -1
index e079d41..3cfb18a 100644
@@ -750,9 +750,10 @@ static void m48t59_isa_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = m48t59_isa_realize;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset = m48t59_reset_isa;
     dc->props = m48t59_isa_properties;
+    /* Reason: needs to be wired up by m48t59_init_isa() */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo m48t59_isa_info = {
hw/timer/mc146818rtc.c +2 -1
index ad61e2c..6fb124f 100644
@@ -899,9 +899,10 @@ static void rtc_class_initfn(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = rtc_realizefn;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_rtc;
     dc->props = mc146818rtc_properties;
+    /* Reason: needs to be wired up by rtc_init() */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo mc146818rtc_info = {
Signature · 1 line
1.8.4
#8 lore raw

[Qemu-devel] [PULL 10/24] qdev: Do not let the user try to device_add when it cannot work

In reply to Andreas Färber

From: Markus Armbruster <[email protected]>

Such devices have always been unavailable and omitted from the list of available devices shown by device_add help. Until commit 18b6dad silently broke the former, setting up nasty traps for unwary users, like this one:

    $ qemu-system-x86_64 -nodefaults -monitor stdio -display none
    QEMU 1.6.50 monitor - type 'help' for more information
    (qemu) device_add apic
    Segmentation fault (core dumped)

I call that a regression. Fix it.

---
 qdev-monitor.c | 5 +++++
 1 file changed, 5 insertions(+)
qdev-monitor.c +5 -0
index f2a5a6f..7877d01 100644
@@ -490,6 +490,11 @@ DeviceState *qdev_device_add(QemuOpts *opts)
     }
 
     dc = DEVICE_CLASS(oc);
+    if (dc->cannot_instantiate_with_device_add_yet) {
+        qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver",
+                      "pluggable device type");
+        return NULL;
+    }
 
     /* find bus */
     path = qemu_opt_get(opts, "bus");
Signature · 1 line
1.8.4
#9 lore raw

[Qemu-devel] [PULL 14/24] qom: Split out object and class caches

In reply to Andreas Färber

From: Peter Crosthwaite <[email protected]>

The object-cast and class-cast caches cannot be shared because class caching is conditional on the target type not being an interface and object caching is unconditional. Leads to a bug when a class cast to an interface follows an object cast to the same interface type:

FooObject = FOO(obj);
FooClass = FOO_GET_CLASS(obj);

Where TYPE_FOO is an interface. The first (object) cast will be successful and cache the casting result (i.e. TYPE_FOO will be cached). The second (class) cast will then check the shared cast cache and register a hit. The issue is, when a class cast hits in the cache it just returns a pointer cast of the input class (i.e. the concrete class).

When casting to an interface, the cast itself must return the interface class, not the concrete class. The implementation of class cast caching already ensures that the returned cast result is only a pointer cast before caching. The object cast logic however does not have this check.

Resolve by just splitting the object and class caches.

---
 include/qom/object.h |  3 ++-
 qom/object.c         | 13 +++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)
include/qom/object.h +2 -1
index a275db2..5f78847 100644
@@ -358,7 +358,8 @@ struct ObjectClass
     Type type;
     GSList *interfaces;
 
-    const char *cast_cache[OBJECT_CLASS_CAST_CACHE];
+    const char *object_cast_cache[OBJECT_CLASS_CAST_CACHE];
+    const char *class_cast_cache[OBJECT_CLASS_CAST_CACHE];
 
     ObjectUnparent *unparent;
 };
qom/object.c +7 -6
index fc19cf6..21b5a0b 100644
@@ -458,7 +458,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char *typename,
     Object *inst;
 
     for (i = 0; obj && i < OBJECT_CLASS_CAST_CACHE; i++) {
-        if (obj->class->cast_cache[i] == typename) {
+        if (obj->class->object_cast_cache[i] == typename) {
             goto out;
         }
     }
@@ -475,9 +475,10 @@ Object *object_dynamic_cast_assert(Object *obj, const char *typename,
 
     if (obj && obj == inst) {
         for (i = 1; i < OBJECT_CLASS_CAST_CACHE; i++) {
-            obj->class->cast_cache[i - 1] = obj->class->cast_cache[i];
+            obj->class->object_cast_cache[i - 1] =
+                    obj->class->object_cast_cache[i];
         }
-        obj->class->cast_cache[i - 1] = typename;
+        obj->class->object_cast_cache[i - 1] = typename;
     }
 
 out:
@@ -547,7 +548,7 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
     int i;
 
     for (i = 0; class && i < OBJECT_CLASS_CAST_CACHE; i++) {
-        if (class->cast_cache[i] == typename) {
+        if (class->class_cast_cache[i] == typename) {
             ret = class;
             goto out;
         }
@@ -568,9 +569,9 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
 #ifdef CONFIG_QOM_CAST_DEBUG
     if (class && ret == class) {
         for (i = 1; i < OBJECT_CLASS_CAST_CACHE; i++) {
-            class->cast_cache[i - 1] = class->cast_cache[i];
+            class->class_cast_cache[i - 1] = class->class_cast_cache[i];
         }
-        class->cast_cache[i - 1] = typename;
+        class->class_cast_cache[i - 1] = typename;
     }
 out:
 #endif
Signature · 1 line
1.8.4
#10 lore raw

[Qemu-devel] [PULL 17/24] qom: Detect bad reentrance during object_class_foreach()

In reply to Andreas Färber

From: Hervé Poussineau <[email protected]>

We should not modify the type hash table while it is being iterated on. Assert that it does not happen.

---
 qom/object.c | 5 +++++
 1 file changed, 5 insertions(+)
qom/object.c +5 -0
index 470a1ac..2aab30b 100644
@@ -78,8 +78,11 @@ static GHashTable *type_table_get(void)
     return type_table;
 }
 
+static bool enumerating_types;
+
 static void type_table_add(TypeImpl *ti)
 {
+    assert(!enumerating_types);
     g_hash_table_insert(type_table_get(), (void *)ti->name, ti);
 }
 
@@ -670,7 +673,9 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
 {
     OCFData data = { fn, implements_type, include_abstract, opaque };
 
+    enumerating_types = true;
     g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &data);
+    enumerating_types = false;
 }
 
 int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
Signature · 1 line
1.8.4
#11 lore raw

[Qemu-devel] [PULL 01/24] qdev: Replace no_user by cannot_instantiate_with_device_add_yet

In reply to Andreas Färber

From: Markus Armbruster <[email protected]>

In an ideal world, machines can be built by wiring devices together with configuration, not code. Unfortunately, that's not the world we live in right now. We still have quite a few devices that need to be wired up by code. If you try to device_add such a device, it'll fail in sometimes mysterious ways. If you're lucky, you get an unmysterious immediate crash.

To protect users from such badness, DeviceClass member no_user used to make device models unavailable with -device / device_add, but that regressed in commit 18b6dad. The device model is still omitted from help, but is available anyway.

Attempts to fix the regression have been rejected with the argument that the purpose of no_user isn't clear, and it's prone to misuse.

This commit clarifies no_user's purpose. Anthony suggested to rename it cannot_instantiate_with_device_add_yet_due_to_internal_bugs, which I shorten somewhat to keep checkpatch happy. While there, make it bool.

Every use of cannot_instantiate_with_device_add_yet gets a FIXME comment asking for rationale. The next few commits will clean them all up, either by providing a rationale, or by getting rid of the use.

With that done, the regression fix is hopefully acceptable.

---
 hw/acpi/piix4.c            |  2 +-
 hw/alpha/typhoon.c         |  2 +-
 hw/arm/versatilepb.c       |  2 +-
 hw/audio/pcspk.c           |  2 +-
 hw/audio/pl041.c           |  2 +-
 hw/block/fdc.c             |  2 +-
 hw/display/pl110.c         |  2 +-
 hw/dma/pl080.c             |  2 +-
 hw/i2c/smbus_ich9.c        |  2 +-
 hw/i386/kvm/clock.c        |  2 +-
 hw/i386/kvmvapic.c         |  2 +-
 hw/i386/pc.c               |  2 +-
 hw/ide/piix.c              |  6 +++---
 hw/ide/via.c               |  2 +-
 hw/input/pckbd.c           |  2 +-
 hw/input/vmmouse.c         |  2 +-
 hw/intc/apic_common.c      |  2 +-
 hw/intc/arm_gic.c          |  2 +-
 hw/intc/arm_gic_common.c   |  2 +-
 hw/intc/arm_gic_kvm.c      |  2 +-
 hw/intc/i8259_common.c     |  2 +-
 hw/intc/ioapic_common.c    |  2 +-
 hw/intc/pl190.c            |  2 +-
 hw/isa/isa-bus.c           |  2 +-
 hw/isa/lpc_ich9.c          |  2 +-
 hw/isa/piix4.c             |  2 +-
 hw/isa/vt82c686.c          |  2 +-
 hw/misc/arm_l2x0.c         |  2 +-
 hw/misc/vmport.c           |  2 +-
 hw/nvram/fw_cfg.c          |  2 +-
 hw/pci-host/bonito.c       |  4 ++--
 hw/pci-host/grackle.c      |  4 ++--
 hw/pci-host/piix.c         |  8 ++++----
 hw/pci-host/prep.c         |  4 ++--
 hw/ppc/spapr_vio.c         |  2 +-
 hw/s390x/ipl.c             |  2 +-
 hw/s390x/s390-virtio-bus.c |  2 +-
 hw/s390x/virtio-ccw.c      |  2 +-
 hw/sd/pl181.c              |  2 +-
 hw/timer/arm_mptimer.c     |  2 +-
 hw/timer/hpet.c            |  2 +-
 hw/timer/i8254_common.c    |  2 +-
 hw/timer/m48t59.c          |  2 +-
 hw/timer/mc146818rtc.c     |  2 +-
 hw/timer/pl031.c           |  2 +-
 include/hw/qdev-core.h     | 13 ++++++++++++-
 qdev-monitor.c             |  5 +++--
 qom/cpu.c                  |  2 +-
 48 files changed, 69 insertions(+), 57 deletions(-)
hw/acpi/piix4.c +1 -1
index 93849c8..dd11534 100644
@@ -544,7 +544,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
     k->revision = 0x03;
     k->class_id = PCI_CLASS_BRIDGE_OTHER;
     dc->desc = "PM";
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_acpi;
     dc->props = piix4_pm_properties;
 }
hw/alpha/typhoon.c +1 -1
index 59e1bb8..60987ed 100644
@@ -938,7 +938,7 @@ static void typhoon_pcihost_class_init(ObjectClass *klass, void *data)
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = typhoon_pcihost_init;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo typhoon_pcihost_info = {
hw/arm/versatilepb.c +1 -1
index f7e8b7e..bb0c0ba 100644
@@ -390,7 +390,7 @@ static void vpb_sic_class_init(ObjectClass *klass, void *data)
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = vpb_sic_init;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_vpb_sic;
 }
 
hw/audio/pcspk.c +1 -1
index 9004ce3..8e3e178 100644
@@ -192,7 +192,7 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data)
 
     dc->realize = pcspk_realizefn;
     set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->props = pcspk_properties;
 }
 
hw/audio/pl041.c +1 -1
index 5393b52..8ba661a 100644
@@ -632,7 +632,7 @@ static void pl041_device_class_init(ObjectClass *klass, void *data)
 
     k->init = pl041_init;
     set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset = pl041_device_reset;
     dc->vmsd = &vmstate_pl041;
     dc->props = pl041_device_properties;
hw/block/fdc.c +1 -1
index c5a6c21..86f4920 100644
@@ -2234,7 +2234,7 @@ static void isabus_fdc_class_init(ObjectClass *klass, void *data)
 
     dc->realize = isabus_fdc_realize;
     dc->fw_name = "fdc";
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset = fdctrl_external_reset_isa;
     dc->vmsd = &vmstate_isa_fdc;
     dc->props = isa_fdc_properties;
hw/display/pl110.c +1 -1
index 790e510..7ad5972 100644
@@ -496,7 +496,7 @@ static void pl110_class_init(ObjectClass *klass, void *data)
 
     k->init = pl110_initfn;
     set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_pl110;
 }
 
hw/dma/pl080.c +1 -1
index 35b9015..a515621 100644
@@ -381,7 +381,7 @@ static void pl080_class_init(ObjectClass *oc, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
 
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_pl080;
 }
 
hw/i2c/smbus_ich9.c +1 -1
index ca22978..c1ffa34 100644
@@ -97,7 +97,7 @@ static void ich9_smb_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_INTEL_ICH9_6;
     k->revision = ICH9_A2_SMB_REVISION;
     k->class_id = PCI_CLASS_SERIAL_SMBUS;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_ich9_smbus;
     dc->desc = "ICH9 SMBUS Bridge";
     k->init = ich9_smbus_initfn;
hw/i386/kvm/clock.c +1 -1
index 383938d..abd2ce8 100644
@@ -114,7 +114,7 @@ static void kvmclock_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = kvmclock_realize;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &kvmclock_vmsd;
 }
 
hw/i386/kvmvapic.c +1 -1
index 2d87600..f1a0a9d 100644
@@ -827,7 +827,7 @@ static void vapic_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset   = vapic_reset;
     dc->vmsd    = &vmstate_vapic;
     dc->realize = vapic_realize;
hw/i386/pc.c +1 -1
index 3cd8f38..1e6e8af 100644
@@ -547,7 +547,7 @@ static void port92_class_initfn(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->realize = port92_realizefn;
     dc->reset = port92_reset;
     dc->vmsd = &vmstate_port92_isa;
hw/ide/piix.c +3 -3
index ab36749..27b08e1 100644
@@ -248,7 +248,7 @@ static void piix3_ide_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;
     k->class_id = PCI_CLASS_STORAGE_IDE;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo piix3_ide_info = {
@@ -267,7 +267,7 @@ static void piix3_ide_xen_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;
     k->class_id = PCI_CLASS_STORAGE_IDE;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->unplug = pci_piix3_xen_ide_unplug;
 }
 
@@ -289,7 +289,7 @@ static void piix4_ide_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_INTEL_82371AB;
     k->class_id = PCI_CLASS_STORAGE_IDE;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo piix4_ide_info = {
hw/ide/via.c +1 -1
index 99468c7..b556c14 100644
@@ -225,7 +225,7 @@ static void via_ide_class_init(ObjectClass *klass, void *data)
     k->revision = 0x06;
     k->class_id = PCI_CLASS_STORAGE_IDE;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo via_ide_info = {
hw/input/pckbd.c +1 -1
index ce86237..dee31a6 100644
@@ -522,7 +522,7 @@ static void i8042_class_initfn(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = i8042_realizefn;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_kbd_isa;
 }
 
hw/input/vmmouse.c +1 -1
index abd032b..600e4a2 100644
@@ -282,7 +282,7 @@ static void vmmouse_class_initfn(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = vmmouse_realizefn;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset = vmmouse_reset;
     dc->vmsd = &vmstate_vmmouse;
     dc->props = vmmouse_properties;
hw/intc/apic_common.c +1 -1
index a0beb10..ea420c7 100644
@@ -386,7 +386,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data)
 
     dc->vmsd = &vmstate_apic_common;
     dc->reset = apic_reset_common;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->props = apic_properties_common;
     idc->init = apic_init_common;
 }
hw/intc/arm_gic.c +1 -1
index d431b7a..24ad276 100644
@@ -704,7 +704,7 @@ static void arm_gic_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     ARMGICClass *agc = ARM_GIC_CLASS(klass);
 
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     agc->parent_realize = dc->realize;
     dc->realize = arm_gic_realize;
 }
hw/intc/arm_gic_common.c +1 -1
index c765850..214a585 100644
@@ -156,7 +156,7 @@ static void arm_gic_common_class_init(ObjectClass *klass, void *data)
     dc->realize = arm_gic_common_realize;
     dc->props = arm_gic_common_properties;
     dc->vmsd = &vmstate_gic;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo arm_gic_common_type = {
hw/intc/arm_gic_kvm.c +1 -1
index f713975..a0bbf12 100644
@@ -150,7 +150,7 @@ static void kvm_arm_gic_class_init(ObjectClass *klass, void *data)
     kgc->parent_reset = dc->reset;
     dc->realize = kvm_arm_gic_realize;
     dc->reset = kvm_arm_gic_reset;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo kvm_arm_gic_info = {
hw/intc/i8259_common.c +1 -1
index 803d037..2acdbfe 100644
@@ -135,7 +135,7 @@ static void pic_common_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->vmsd = &vmstate_pic_common;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->props = pic_properties_common;
     dc->realize = pic_common_realize;
 }
hw/intc/ioapic_common.c +1 -1
index 6b705c1..cc5a80d 100644
@@ -98,7 +98,7 @@ static void ioapic_common_class_init(ObjectClass *klass, void *data)
 
     dc->realize = ioapic_common_realize;
     dc->vmsd = &vmstate_ioapic_common;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo ioapic_common_type = {
hw/intc/pl190.c +1 -1
index 329680d..b16bc02 100644
@@ -273,7 +273,7 @@ static void pl190_class_init(ObjectClass *klass, void *data)
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = pl190_init;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset = pl190_reset;
     dc->vmsd = &vmstate_pl190;
 }
hw/isa/isa-bus.c +1 -1
index 9e104eb..6b2114d 100644
@@ -197,7 +197,7 @@ static void isabus_bridge_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->fw_name = "isa";
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo isabus_bridge_info = {
hw/isa/lpc_ich9.c +1 -1
index 19b2198..c1ca4d4 100644
@@ -644,7 +644,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)
     dc->reset = ich9_lpc_reset;
     k->init = ich9_lpc_initfn;
     dc->vmsd = &vmstate_ich9_lpc;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     k->config_write = ich9_lpc_config_write;
     dc->desc = "ICH9 LPC bridge";
     k->vendor_id = PCI_VENDOR_ID_INTEL;
hw/isa/piix4.c +1 -1
index 1a1d451..d9dac61 100644
@@ -113,7 +113,7 @@ static void piix4_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_INTEL_82371AB_0;
     k->class_id = PCI_CLASS_BRIDGE_ISA;
     dc->desc = "ISA bridge";
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_piix4;
 }
 
hw/isa/vt82c686.c +1 -1
index 5fb8086..b06d15e 100644
@@ -480,7 +480,7 @@ static void via_class_init(ObjectClass *klass, void *data)
     k->class_id = PCI_CLASS_BRIDGE_ISA;
     k->revision = 0x40;
     dc->desc = "ISA bridge";
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_via;
 }
 
hw/misc/arm_l2x0.c +1 -1
index 8e192cd..ceea99d 100644
@@ -179,7 +179,7 @@ static void l2x0_class_init(ObjectClass *klass, void *data)
 
     k->init = l2x0_priv_init;
     dc->vmsd = &vmstate_l2x0;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->props = l2x0_properties;
     dc->reset = l2x0_priv_reset;
 }
hw/misc/vmport.c +1 -1
index 0b5a564..94ae6ae 100644
@@ -162,7 +162,7 @@ static void vmport_class_initfn(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = vmport_realizefn;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo vmport_info = {
hw/nvram/fw_cfg.c +1 -1
index f5dc3ea..6075bfc 100644
@@ -599,7 +599,7 @@ static void fw_cfg_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = fw_cfg_realize;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset = fw_cfg_reset;
     dc->vmsd = &vmstate_fw_cfg;
     dc->props = fw_cfg_properties;
hw/pci-host/bonito.c +2 -2
index 5086d42..2e08e9d 100644
@@ -806,7 +806,7 @@ static void bonito_class_init(ObjectClass *klass, void *data)
     k->revision = 0x01;
     k->class_id = PCI_CLASS_BRIDGE_HOST;
     dc->desc = "Host bridge";
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_bonito;
 }
 
@@ -823,7 +823,7 @@ static void bonito_pcihost_class_init(ObjectClass *klass, void *data)
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = bonito_pcihost_initfn;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo bonito_pcihost_info = {
hw/pci-host/grackle.c +2 -2
index 75b60d3..ba6017f 100644
@@ -130,7 +130,7 @@ static void grackle_pci_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_MOTOROLA_MPC106;
     k->revision  = 0x00;
     k->class_id  = PCI_CLASS_BRIDGE_HOST;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo grackle_pci_info = {
@@ -146,7 +146,7 @@ static void pci_grackle_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init = pci_grackle_init_device;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo grackle_pci_host_info = {
hw/pci-host/piix.c +4 -4
index 63be7f6..333358e 100644
@@ -635,7 +635,7 @@ static void piix3_class_init(ObjectClass *klass, void *data)
 
     dc->desc        = "ISA bridge";
     dc->vmsd        = &vmstate_piix3;
-    dc->no_user     = 1,
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     k->no_hotplug   = 1;
     k->init         = piix3_initfn;
     k->config_write = piix3_write_config;
@@ -659,7 +659,7 @@ static void piix3_xen_class_init(ObjectClass *klass, void *data)
 
     dc->desc        = "ISA bridge";
     dc->vmsd        = &vmstate_piix3;
-    dc->no_user     = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     k->no_hotplug   = 1;
     k->init         = piix3_initfn;
     k->config_write = piix3_write_config_xen;
@@ -689,7 +689,7 @@ static void i440fx_class_init(ObjectClass *klass, void *data)
     k->revision = 0x02;
     k->class_id = PCI_CLASS_BRIDGE_HOST;
     dc->desc = "Host bridge";
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_i440fx;
 }
 
@@ -727,7 +727,7 @@ static void i440fx_pcihost_class_init(ObjectClass *klass, void *data)
     hc->root_bus_path = i440fx_pcihost_root_bus_path;
     dc->realize = i440fx_pcihost_realize;
     dc->fw_name = "pci";
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->props = i440fx_props;
 }
 
hw/pci-host/prep.c +2 -2
index 0e71fdb..58b8c5e 100644
@@ -198,7 +198,7 @@ static void raven_class_init(ObjectClass *klass, void *data)
     k->class_id = PCI_CLASS_BRIDGE_HOST;
     dc->desc = "PReP Host Bridge - Motorola Raven";
     dc->vmsd = &vmstate_raven;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo raven_info = {
@@ -215,7 +215,7 @@ static void raven_pcihost_class_init(ObjectClass *klass, void *data)
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->realize = raven_pcihost_realizefn;
     dc->fw_name = "pci";
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo raven_pcihost_info = {
hw/ppc/spapr_vio.c +1 -1
index fee6195..e328f53 100644
@@ -532,7 +532,7 @@ static void spapr_vio_bridge_class_init(ObjectClass *klass, void *data)
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = spapr_vio_bridge_init;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo spapr_vio_bridge_info = {
hw/s390x/ipl.c +1 -1
index 65d39da..26a717c 100644
@@ -182,7 +182,7 @@ static void s390_ipl_class_init(ObjectClass *klass, void *data)
     k->init = s390_ipl_init;
     dc->props = s390_ipl_properties;
     dc->reset = s390_ipl_reset;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo s390_ipl_info = {
hw/s390x/s390-virtio-bus.c +1 -1
index 6a83111..eccc3e7 100644
@@ -680,7 +680,7 @@ static void s390_virtio_bridge_class_init(ObjectClass *klass, void *data)
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = s390_virtio_bridge_init;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo s390_virtio_bridge_info = {
hw/s390x/virtio-ccw.c +1 -1
index ecc80ec..3be9268 100644
@@ -1287,7 +1287,7 @@ static void virtual_css_bridge_class_init(ObjectClass *klass, void *data)
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = virtual_css_bridge_init;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo virtual_css_bridge_info = {
hw/sd/pl181.c +1 -1
index c35896d..d830188 100644
@@ -506,7 +506,7 @@ static void pl181_class_init(ObjectClass *klass, void *data)
     sdc->init = pl181_init;
     k->vmsd = &vmstate_pl181;
     k->reset = pl181_reset;
-    k->no_user = 1;
+    k->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo pl181_info = {
hw/timer/arm_mptimer.c +1 -1
index d9f9494..1dc44cd 100644
@@ -274,7 +274,7 @@ static void arm_mptimer_class_init(ObjectClass *klass, void *data)
     dc->realize = arm_mptimer_realize;
     dc->vmsd = &vmstate_arm_mptimer;
     dc->reset = arm_mptimer_reset;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->props = arm_mptimer_properties;
 }
 
hw/timer/hpet.c +1 -1
index bb3bf98..74e0297 100644
@@ -765,7 +765,7 @@ static void hpet_device_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = hpet_realize;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset = hpet_reset;
     dc->vmsd = &vmstate_hpet;
     dc->props = hpet_device_properties;
hw/timer/i8254_common.c +1 -1
index e8fb971..dc2196c 100644
@@ -282,7 +282,7 @@ static void pit_common_class_init(ObjectClass *klass, void *data)
 
     dc->realize = pit_common_realize;
     dc->vmsd = &vmstate_pit_common;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo pit_common_type = {
hw/timer/m48t59.c +1 -1
index be0592b..e079d41 100644
@@ -750,7 +750,7 @@ static void m48t59_isa_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = m48t59_isa_realize;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->reset = m48t59_reset_isa;
     dc->props = m48t59_isa_properties;
 }
hw/timer/mc146818rtc.c +1 -1
index b011638..ad61e2c 100644
@@ -899,7 +899,7 @@ static void rtc_class_initfn(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = rtc_realizefn;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_rtc;
     dc->props = mc146818rtc_properties;
 }
hw/timer/pl031.c +1 -1
index 65928a4..2f7360c 100644
@@ -251,7 +251,7 @@ static void pl031_class_init(ObjectClass *klass, void *data)
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
     k->init = pl031_init;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_pl031;
 }
 
include/hw/qdev-core.h +12 -1
index f2043a6..c8945a4 100644
@@ -97,7 +97,18 @@ typedef struct DeviceClass {
     const char *fw_name;
     const char *desc;
     Property *props;
-    int no_user;
+
+    /*
+     * Shall we hide this device model from -device / device_add?
+     * All devices should support instantiation with device_add, and
+     * this flag should not exist.  But we're not there, yet.  Some
+     * devices fail to instantiate with cryptic error messages.
+     * Others instantiate, but don't work.  Exposing users to such
+     * behavior would be cruel; this flag serves to protect them.  It
+     * should never be set without a comment explaining why it is set.
+     * TODO remove once we're there
+     */
+    bool cannot_instantiate_with_device_add_yet;
 
     /* callbacks */
     void (*reset)(DeviceState *dev);
qdev-monitor.c +3 -2
index dc37a43..f2a5a6f 100644
@@ -87,7 +87,7 @@ static void qdev_print_devinfo(DeviceClass *dc)
     if (dc->desc) {
         error_printf(", desc \"%s\"", dc->desc);
     }
-    if (dc->no_user) {
+    if (dc->cannot_instantiate_with_device_add_yet) {
         error_printf(", no-user");
     }
     error_printf("\n");
@@ -127,7 +127,8 @@ static void qdev_print_devinfos(bool show_no_user)
             if ((i < DEVICE_CATEGORY_MAX
                  ? !test_bit(i, dc->categories)
                  : !bitmap_empty(dc->categories, DEVICE_CATEGORY_MAX))
-                || (!show_no_user && dc->no_user)) {
+                || (!show_no_user
+                    && dc->cannot_instantiate_with_device_add_yet)) {
                 continue;
             }
             if (!cat_printed) {
qom/cpu.c +1 -1
index 818fb26..09c15e6 100644
@@ -254,7 +254,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
     k->gdb_read_register = cpu_common_gdb_read_register;
     k->gdb_write_register = cpu_common_gdb_write_register;
     dc->realize = cpu_common_realizefn;
-    dc->no_user = 1;
+    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo cpu_type_info = {
Signature · 1 line
1.8.4
#12 lore raw

[Qemu-devel] [PULL 05/24] pci-host: Consistently set cannot_instantiate_with_device_add_yet

In reply to Andreas Färber

From: Markus Armbruster <[email protected]>

Many PCI host bridges consist of a sysbus device and a PCI device. You need both for the thing to work. Arguably, these bridges should be modelled as a single, composite devices instead of pairs of seemingly independent devices you can only use together, but we're not there, yet.

Since the sysbus part can't be instantiated with device_add, yet, permitting it with the PCI part is useless. We shouldn't offer useless options to the user, so let's set cannot_instantiate_with_device_add_yet for them.

It's already set for Bonito, Grackle, i440FX and Raven. Document why.

Set it for the others: dec-21154, e500-host-bridge, gt64120_pci, mch, pbm-pci, ppc4xx-host-bridge, sh_pci_host, u3-agp, uni-north-agp, uni-north-internal-pci, uni-north-pci, and versatile_pci_host.

---
 hw/mips/gt64xxx_pci.c   |  6 ++++++
 hw/pci-bridge/dec.c     |  6 ++++++
 hw/pci-host/apb.c       |  6 ++++++
 hw/pci-host/bonito.c    |  6 +++++-
 hw/pci-host/grackle.c   |  6 +++++-
 hw/pci-host/piix.c      |  6 +++++-
 hw/pci-host/ppce500.c   |  5 +++++
 hw/pci-host/prep.c      |  6 +++++-
 hw/pci-host/q35.c       |  5 +++++
 hw/pci-host/uninorth.c  | 24 ++++++++++++++++++++++++
 hw/pci-host/versatile.c |  6 ++++++
 hw/ppc/ppc4xx_pci.c     |  5 +++++
 hw/sh4/sh_pci.c         |  6 ++++++
 13 files changed, 89 insertions(+), 4 deletions(-)
hw/mips/gt64xxx_pci.c +6 -0
index 3da2e67..6398514 100644
@@ -1151,12 +1151,18 @@ static int gt64120_pci_init(PCIDevice *d)
 static void gt64120_pci_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init = gt64120_pci_init;
     k->vendor_id = PCI_VENDOR_ID_MARVELL;
     k->device_id = PCI_DEVICE_ID_MARVELL_GT6412X;
     k->revision = 0x10;
     k->class_id = PCI_CLASS_BRIDGE_HOST;
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo gt64120_pci_info = {
hw/pci-bridge/dec.c +6 -0
index e5e3be8..a6ca940 100644
@@ -116,6 +116,7 @@ static int dec_21154_pci_host_init(PCIDevice *d)
 static void dec_21154_pci_host_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init = dec_21154_pci_host_init;
     k->vendor_id = PCI_VENDOR_ID_DEC;
@@ -123,6 +124,11 @@ static void dec_21154_pci_host_class_init(ObjectClass *klass, void *data)
     k->revision = 0x02;
     k->class_id = PCI_CLASS_BRIDGE_PCI;
     k->is_bridge = 1;
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo dec_21154_pci_host_info = {
hw/pci-host/apb.c +6 -0
index 92f289f..1b399dd 100644
@@ -516,11 +516,17 @@ static int pbm_pci_host_init(PCIDevice *d)
 static void pbm_pci_host_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init = pbm_pci_host_init;
     k->vendor_id = PCI_VENDOR_ID_SUN;
     k->device_id = PCI_DEVICE_ID_SUN_SABRE;
     k->class_id = PCI_CLASS_BRIDGE_HOST;
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo pbm_pci_host_info = {
hw/pci-host/bonito.c +5 -1
index bfb9820..902441f 100644
@@ -806,8 +806,12 @@ static void bonito_class_init(ObjectClass *klass, void *data)
     k->revision = 0x01;
     k->class_id = PCI_CLASS_BRIDGE_HOST;
     dc->desc = "Host bridge";
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_bonito;
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo bonito_info = {
hw/pci-host/grackle.c +5 -1
index b0da33d..6c7cfdb 100644
@@ -130,7 +130,11 @@ static void grackle_pci_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_MOTOROLA_MPC106;
     k->revision  = 0x00;
     k->class_id  = PCI_CLASS_BRIDGE_HOST;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo grackle_pci_info = {
hw/pci-host/piix.c +5 -1
index 98ebe6c..0a8f6c1 100644
@@ -689,8 +689,12 @@ static void i440fx_class_init(ObjectClass *klass, void *data)
     k->revision = 0x02;
     k->class_id = PCI_CLASS_BRIDGE_HOST;
     dc->desc = "Host bridge";
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_i440fx;
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo i440fx_info = {
hw/pci-host/ppce500.c +5 -0
index f00793d..c80b7cb 100644
@@ -387,6 +387,11 @@ static void e500_host_bridge_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_MPC8533E;
     k->class_id = PCI_CLASS_PROCESSOR_POWERPC;
     dc->desc = "Host bridge";
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo e500_host_bridge_info = {
hw/pci-host/prep.c +5 -1
index ebc40c6..042dc8f 100644
@@ -198,7 +198,11 @@ static void raven_class_init(ObjectClass *klass, void *data)
     k->class_id = PCI_CLASS_BRIDGE_HOST;
     dc->desc = "PReP Host Bridge - Motorola Raven";
     dc->vmsd = &vmstate_raven;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo raven_info = {
hw/pci-host/q35.c +5 -0
index 81c8240..4bc2e01 100644
@@ -403,6 +403,11 @@ static void mch_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_INTEL_Q35_MCH;
     k->revision = MCH_HOST_BRIDGE_REVISION_DEFAULT;
     k->class_id = PCI_CLASS_BRIDGE_HOST;
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo mch_info = {
hw/pci-host/uninorth.c +24 -0
index adc1d89..e72fe2a 100644
@@ -351,12 +351,18 @@ static int unin_internal_pci_host_init(PCIDevice *d)
 static void unin_main_pci_host_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init      = unin_main_pci_host_init;
     k->vendor_id = PCI_VENDOR_ID_APPLE;
     k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_PCI;
     k->revision  = 0x00;
     k->class_id  = PCI_CLASS_BRIDGE_HOST;
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo unin_main_pci_host_info = {
@@ -369,12 +375,18 @@ static const TypeInfo unin_main_pci_host_info = {
 static void u3_agp_pci_host_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init      = u3_agp_pci_host_init;
     k->vendor_id = PCI_VENDOR_ID_APPLE;
     k->device_id = PCI_DEVICE_ID_APPLE_U3_AGP;
     k->revision  = 0x00;
     k->class_id  = PCI_CLASS_BRIDGE_HOST;
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo u3_agp_pci_host_info = {
@@ -387,12 +399,18 @@ static const TypeInfo u3_agp_pci_host_info = {
 static void unin_agp_pci_host_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init      = unin_agp_pci_host_init;
     k->vendor_id = PCI_VENDOR_ID_APPLE;
     k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_AGP;
     k->revision  = 0x00;
     k->class_id  = PCI_CLASS_BRIDGE_HOST;
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo unin_agp_pci_host_info = {
@@ -405,12 +423,18 @@ static const TypeInfo unin_agp_pci_host_info = {
 static void unin_internal_pci_host_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init      = unin_internal_pci_host_init;
     k->vendor_id = PCI_VENDOR_ID_APPLE;
     k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_I_PCI;
     k->revision  = 0x00;
     k->class_id  = PCI_CLASS_BRIDGE_HOST;
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo unin_internal_pci_host_info = {
hw/pci-host/versatile.c +6 -0
index 6b28929..71ff0de 100644
@@ -467,11 +467,17 @@ static int versatile_pci_host_init(PCIDevice *d)
 static void versatile_pci_host_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init = versatile_pci_host_init;
     k->vendor_id = PCI_VENDOR_ID_XILINX;
     k->device_id = PCI_DEVICE_ID_XILINX_XC2VP30;
     k->class_id = PCI_CLASS_PROCESSOR_CO;
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo versatile_pci_host_info = {
hw/ppc/ppc4xx_pci.c +5 -0
index d2d6f65..4cb7851 100644
@@ -380,6 +380,11 @@ static void ppc4xx_host_bridge_class_init(ObjectClass *klass, void *data)
     k->vendor_id    = PCI_VENDOR_ID_IBM;
     k->device_id    = PCI_DEVICE_ID_IBM_440GX;
     k->class_id     = PCI_CLASS_BRIDGE_OTHER;
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo ppc4xx_host_bridge_info = {
hw/sh4/sh_pci.c +6 -0
index e81176a..a2f6d9e 100644
@@ -162,10 +162,16 @@ static int sh_pci_host_init(PCIDevice *d)
 static void sh_pci_host_class_init(ObjectClass *klass, void *data)
 {
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init = sh_pci_host_init;
     k->vendor_id = PCI_VENDOR_ID_HITACHI;
     k->device_id = PCI_DEVICE_ID_HITACHI_SH7751R;
+    /*
+     * PCI-facing part of the host bridge, not usable without the
+     * host-facing part, which can't be device_add'ed, yet.
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo sh_pci_host_info = {
Signature · 1 line
1.8.4
#13 lore raw

[Qemu-devel] [PULL 07/24] piix3 piix4: Clean up use of cannot_instantiate_with_device_add_yet

In reply to Andreas Färber

From: Markus Armbruster <[email protected]>

A PIIX3/PIIX4 southbridge has multiple functions. We model each function as a separate qdev. Two of them need some special wiring set up in pc_init1() or mips_malta_init() to work: the ISA bridge at 01.0, and the SMBus controller at 01.3.

The IDE controller at 01.1 (piix3-ide, piix3-ide-xen, piix4-ide) has always had cannot_instantiate_with_device_add_yet set, but there is no obvious reason why device_add could not work for them. Drop it.

---
 hw/acpi/piix4.c    |  6 +++++-
 hw/ide/piix.c      |  3 ---
 hw/isa/piix4.c     |  6 +++++-
 hw/pci-host/piix.c | 12 ++++++++++--
 4 files changed, 20 insertions(+), 7 deletions(-)
hw/acpi/piix4.c +5 -1
index dd11534..9e8a89c 100644
@@ -544,9 +544,13 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
     k->revision = 0x03;
     k->class_id = PCI_CLASS_BRIDGE_OTHER;
     dc->desc = "PM";
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_acpi;
     dc->props = piix4_pm_properties;
+    /*
+     * Reason: part of PIIX4 southbridge, needs to be wired up,
+     * e.g. by mips_malta_init()
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo piix4_pm_info = {
hw/ide/piix.c +0 -3
index 27b08e1..9b5960b 100644
@@ -248,7 +248,6 @@ static void piix3_ide_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;
     k->class_id = PCI_CLASS_STORAGE_IDE;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo piix3_ide_info = {
@@ -267,7 +266,6 @@ static void piix3_ide_xen_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_INTEL_82371SB_1;
     k->class_id = PCI_CLASS_STORAGE_IDE;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->unplug = pci_piix3_xen_ide_unplug;
 }
 
@@ -289,7 +287,6 @@ static void piix4_ide_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_INTEL_82371AB;
     k->class_id = PCI_CLASS_STORAGE_IDE;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
 }
 
 static const TypeInfo piix4_ide_info = {
hw/isa/piix4.c +5 -1
index d9dac61..def6fe3 100644
@@ -113,8 +113,12 @@ static void piix4_class_init(ObjectClass *klass, void *data)
     k->device_id = PCI_DEVICE_ID_INTEL_82371AB_0;
     k->class_id = PCI_CLASS_BRIDGE_ISA;
     dc->desc = "ISA bridge";
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     dc->vmsd = &vmstate_piix4;
+    /*
+     * Reason: part of PIIX4 southbridge, needs to be wired up,
+     * e.g. by mips_malta_init()
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo piix4_info = {
hw/pci-host/piix.c +10 -2
index 0a8f6c1..cc97150 100644
@@ -635,7 +635,6 @@ static void piix3_class_init(ObjectClass *klass, void *data)
 
     dc->desc        = "ISA bridge";
     dc->vmsd        = &vmstate_piix3;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     k->no_hotplug   = 1;
     k->init         = piix3_initfn;
     k->config_write = piix3_write_config;
@@ -643,6 +642,11 @@ static void piix3_class_init(ObjectClass *klass, void *data)
     /* 82371SB PIIX3 PCI-to-ISA bridge (Step A1) */
     k->device_id    = PCI_DEVICE_ID_INTEL_82371SB_0;
     k->class_id     = PCI_CLASS_BRIDGE_ISA;
+    /*
+     * Reason: part of PIIX3 southbridge, needs to be wired up by
+     * pc_piix.c's pc_init1()
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo piix3_info = {
@@ -659,7 +663,6 @@ static void piix3_xen_class_init(ObjectClass *klass, void *data)
 
     dc->desc        = "ISA bridge";
     dc->vmsd        = &vmstate_piix3;
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
     k->no_hotplug   = 1;
     k->init         = piix3_initfn;
     k->config_write = piix3_write_config_xen;
@@ -667,6 +670,11 @@ static void piix3_xen_class_init(ObjectClass *klass, void *data)
     /* 82371SB PIIX3 PCI-to-ISA bridge (Step A1) */
     k->device_id    = PCI_DEVICE_ID_INTEL_82371SB_0;
     k->class_id     = PCI_CLASS_BRIDGE_ISA;
+    /*
+     * Reason: part of PIIX3 southbridge, needs to be wired up by
+     * pc_piix.c's pc_init1()
+     */
+    dc->cannot_instantiate_with_device_add_yet = true;
 };
 
 static const TypeInfo piix3_xen_info = {
Signature · 1 line
1.8.4
#14 lore raw

[Qemu-devel] [PULL 12/24] hw: cannot_instantiate_with_device_add_yet due to pointer props

In reply to Andreas Färber

From: Markus Armbruster <[email protected]>

Pointer properties can be set only by code, not by device_add. A device with a pointer property can work with device_add only when the property may remain null.

This is the case for property "interrupt_vector" of device "etraxfs,pic". Add a comment there.

Set cannot_instantiate_with_device_add_yet for the other devices with pointer properties, with a comment explaining why.

Juha Riihimäki and Peter Maydell deserve my thanks for making "pointer property must not remain null" blatantly obvious in the OMAP devices.

Only device "smbus-eeprom" is actually changed. The others are all sysbus devices, which get cannot_instantiate_with_device_add_yet set in their abstract base's class init function. Setting it again in their class init function is technically redundant, but serves as insurance for when sysbus devices become available with device_add, and as documentation.

---
 hw/audio/marvell_88w8618.c | 2 ++
 hw/dma/sparc32_dma.c       | 2 ++
 hw/gpio/omap_gpio.c        | 4 ++++
 hw/i2c/omap_i2c.c          | 2 ++
 hw/i2c/smbus_eeprom.c      | 2 ++
 hw/intc/etraxfs_pic.c      | 4 ++++
 hw/intc/grlib_irqmp.c      | 2 ++
 hw/intc/omap_intc.c        | 4 ++++
 hw/net/etraxfs_eth.c       | 2 ++
 hw/net/lance.c             | 2 ++
 10 files changed, 26 insertions(+)
hw/audio/marvell_88w8618.c +2 -0
index 97194ce..cdce238 100644
@@ -288,6 +288,8 @@ static void mv88w8618_audio_class_init(ObjectClass *klass, void *data)
     dc->reset = mv88w8618_audio_reset;
     dc->vmsd = &mv88w8618_audio_vmsd;
     dc->props = mv88w8618_audio_properties;
+    /* Reason: pointer property "wm8750" */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo mv88w8618_audio_info = {
hw/dma/sparc32_dma.c +2 -0
index 2a92ffb..eac338f 100644
@@ -304,6 +304,8 @@ static void sparc32_dma_class_init(ObjectClass *klass, void *data)
     dc->reset = dma_reset;
     dc->vmsd = &vmstate_dma;
     dc->props = sparc32_dma_properties;
+    /* Reason: pointer property "iommu_opaque" */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo sparc32_dma_info = {
hw/gpio/omap_gpio.c +4 -0
index b8f572b..938782a 100644
@@ -759,6 +759,8 @@ static void omap_gpio_class_init(ObjectClass *klass, void *data)
     k->init = omap_gpio_init;
     dc->reset = omap_gpif_reset;
     dc->props = omap_gpio_properties;
+    /* Reason: pointer property "clk" */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo omap_gpio_info = {
@@ -788,6 +790,8 @@ static void omap2_gpio_class_init(ObjectClass *klass, void *data)
     k->init = omap2_gpio_init;
     dc->reset = omap2_gpif_reset;
     dc->props = omap2_gpio_properties;
+    /* Reason: pointer properties "iclk", "fclk0", ..., "fclk5" */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo omap2_gpio_info = {
hw/i2c/omap_i2c.c +2 -0
index f528b2b..2d8e2b7 100644
@@ -475,6 +475,8 @@ static void omap_i2c_class_init(ObjectClass *klass, void *data)
     k->init = omap_i2c_init;
     dc->props = omap_i2c_properties;
     dc->reset = omap_i2c_reset;
+    /* Reason: pointer properties "iclk", "fclk" */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo omap_i2c_info = {
hw/i2c/smbus_eeprom.c +2 -0
index 0154283..0218f8a 100644
@@ -121,6 +121,8 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data)
     sc->write_data = eeprom_write_data;
     sc->read_data = eeprom_read_data;
     dc->props = smbus_eeprom_properties;
+    /* Reason: pointer property "data" */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo smbus_eeprom_info = {
hw/intc/etraxfs_pic.c +4 -0
index e02da53..636262b 100644
@@ -170,6 +170,10 @@ static void etraxfs_pic_class_init(ObjectClass *klass, void *data)
 
     k->init = etraxfs_pic_init;
     dc->props = etraxfs_pic_properties;
+    /*
+     * Note: pointer property "interrupt_vector" may remain null, thus
+     * no need for dc->cannot_instantiate_with_device_add_yet = true;
+     */
 }
 
 static const TypeInfo etraxfs_pic_info = {
hw/intc/grlib_irqmp.c +2 -0
index 42e00bc..d1813f7 100644
@@ -355,6 +355,8 @@ static void grlib_irqmp_class_init(ObjectClass *klass, void *data)
     k->init = grlib_irqmp_init;
     dc->reset = grlib_irqmp_reset;
     dc->props = grlib_irqmp_properties;
+    /* Reason: pointer properties "set_pil_in", "set_pil_in_opaque" */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo grlib_irqmp_info = {
hw/intc/omap_intc.c +4 -0
index 7dd63da..ad3931c 100644
@@ -392,6 +392,8 @@ static void omap_intc_class_init(ObjectClass *klass, void *data)
     k->init = omap_intc_init;
     dc->reset = omap_inth_reset;
     dc->props = omap_intc_properties;
+    /* Reason: pointer property "clk" */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo omap_intc_info = {
@@ -637,6 +639,8 @@ static void omap2_intc_class_init(ObjectClass *klass, void *data)
     k->init = omap2_intc_init;
     dc->reset = omap_inth_reset;
     dc->props = omap2_intc_properties;
+    /* Reason: pointer property "iclk", "fclk" */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo omap2_intc_info = {
hw/net/etraxfs_eth.c +2 -0
index 78ebbbc..6a3c86d 100644
@@ -646,6 +646,8 @@ static void etraxfs_eth_class_init(ObjectClass *klass, void *data)
 
     k->init = fs_eth_init;
     dc->props = etraxfs_eth_properties;
+    /* Reason: pointer properties "dma_out", "dma_in" */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo etraxfs_eth_info = {
hw/net/lance.c +2 -0
index e339f02..fe18564 100644
@@ -161,6 +161,8 @@ static void lance_class_init(ObjectClass *klass, void *data)
     dc->reset = lance_reset;
     dc->vmsd = &vmstate_lance;
     dc->props = lance_properties;
+    /* Reason: pointer property "dma" */
+    dc->cannot_instantiate_with_device_add_yet = true;
 }
 
 static const TypeInfo lance_info = {
Signature · 1 line
1.8.4
#15 lore raw

[Qemu-devel] [PULL 13/24] qdev: Document that pointer properties kill device_add

In reply to Andreas Färber

From: Markus Armbruster <[email protected]>

Ask users of DEFINE_PROP_PTR() to set cannot_instantiate_with_device_add_yet, or explain why it's not needed.

---
 include/hw/qdev-properties.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
include/hw/qdev-properties.h +17 -0
index 692f82e..77c6f7c 100644
@@ -122,8 +122,25 @@ extern PropertyInfo qdev_prop_arraylen;
 #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d)                   \
     DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
 
+/*
+ * Please avoid pointer properties.  If you must use them, you must
+ * cover them in their device's class init function as follows:
+ *
+ * - If the property must be set, the device cannot be used with
+ *   device_add, so add code like this:
+ *   |* Reason: pointer property "NAME-OF-YOUR-PROP" *|
+ *   DeviceClass *dc = DEVICE_CLASS(class);
+ *   dc->cannot_instantiate_with_device_add_yet = true;
+ *
+ * - If the property may safely remain null, document it like this:
+ *   |*
+ *    * Note: pointer property "interrupt_vector" may remain null, thus
+ *    * no need for dc->cannot_instantiate_with_device_add_yet = true;
+ *    *|
+ */
 #define DEFINE_PROP_PTR(_n, _s, _f)             \
     DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
+
 #define DEFINE_PROP_CHR(_n, _s, _f)             \
     DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
 #define DEFINE_PROP_STRING(_n, _s, _f)             \
Signature · 1 line
1.8.4
#16 lore raw

[Qemu-devel] [PULL 15/24] qom: Do not register interface "types" in the type table and fix names

In reply to Andreas Färber

From: Paolo Bonzini <[email protected]>

There should be no need to look up nor enumerate the interface "types", whose "classes" are really just vtables. Just create the types and add them to the interface list of the parent type.

Interfaces not registering their type anymore means that accessing superclass::interface by type name will fail when initializing subclass::interface. Thus, we need to pre-initialize the subclass's parent_type field before calling type_initialize. Apart from this, the interface "types" should never be used and thus it is harmless to leave them out of the hashtable.

Further, the interface types had a bug with interfaces that are inherited from a superclass: The implementation type name was wrong (for example it was subclass::superclass::interface rather than just subclass::interface). This patch fixes this as well.

---
 include/qom/object.h |  1 +
 qom/object.c         | 32 +++++++++++++++++++++-----------
 2 files changed, 22 insertions(+), 11 deletions(-)
include/qom/object.h +1 -0
index 5f78847..e0ff212 100644
@@ -536,6 +536,7 @@ struct InterfaceClass
     ObjectClass parent_class;
     /*< private >*/
     ObjectClass *concrete_class;
+    Type interface_type;
 };
 
 #define TYPE_INTERFACE "interface"
qom/object.c +21 -11
index 21b5a0b..470a1ac 100644
@@ -88,7 +88,7 @@ static TypeImpl *type_table_lookup(const char *name)
     return g_hash_table_lookup(type_table_get(), name);
 }
 
-static TypeImpl *type_register_internal(const TypeInfo *info)
+static TypeImpl *type_new(const TypeInfo *info)
 {
     TypeImpl *ti = g_malloc0(sizeof(*ti));
     int i;
@@ -122,8 +122,15 @@ static TypeImpl *type_register_internal(const TypeInfo *info)
     }
     ti->num_interfaces = i;
 
-    type_table_add(ti);
+    return ti;
+}
 
+static TypeImpl *type_register_internal(const TypeInfo *info)
+{
+    TypeImpl *ti;
+    ti = type_new(info);
+
+    type_table_add(ti);
     return ti;
 }
 
@@ -206,22 +213,25 @@ static bool type_is_ancestor(TypeImpl *type, TypeImpl *target_type)
 
 static void type_initialize(TypeImpl *ti);
 
-static void type_initialize_interface(TypeImpl *ti, const char *parent)
+static void type_initialize_interface(TypeImpl *ti, TypeImpl *interface_type,
+                                      TypeImpl *parent_type)
 {
     InterfaceClass *new_iface;
     TypeInfo info = { };
     TypeImpl *iface_impl;
 
-    info.parent = parent;
-    info.name = g_strdup_printf("%s::%s", ti->name, info.parent);
+    info.parent = parent_type->name;
+    info.name = g_strdup_printf("%s::%s", ti->name, interface_type->name);
     info.abstract = true;
 
-    iface_impl = type_register(&info);
+    iface_impl = type_new(&info);
+    iface_impl->parent_type = parent_type;
     type_initialize(iface_impl);
     g_free((char *)info.name);
 
     new_iface = (InterfaceClass *)iface_impl->class;
     new_iface->concrete_class = ti->class;
+    new_iface->interface_type = interface_type;
 
     ti->class->interfaces = g_slist_append(ti->class->interfaces,
                                            iface_impl->class);
@@ -251,8 +261,10 @@ static void type_initialize(TypeImpl *ti)
         ti->class->interfaces = NULL;
 
         for (e = parent->class->interfaces; e; e = e->next) {
-            ObjectClass *iface = e->data;
-            type_initialize_interface(ti, object_class_get_name(iface));
+            InterfaceClass *iface = e->data;
+            ObjectClass *klass = OBJECT_CLASS(iface);
+
+            type_initialize_interface(ti, iface->interface_type, klass->type);
         }
 
         for (i = 0; i < ti->num_interfaces; i++) {
@@ -269,7 +281,7 @@ static void type_initialize(TypeImpl *ti)
                 continue;
             }
 
-            type_initialize_interface(ti, ti->interfaces[i].typename);
+            type_initialize_interface(ti, t, t);
         }
     }
 
@@ -285,8 +297,6 @@ static void type_initialize(TypeImpl *ti)
     if (ti->class_init) {
         ti->class_init(ti->class, ti->class_data);
     }
-
-
 }
 
 static void object_init_with_type(Object *obj, TypeImpl *ti)
Signature · 1 line
1.8.4
#17 lore raw

[Qemu-devel] [PULL 16/24] tests: Test QOM interface casting

In reply to Andreas Färber

From: Igor Mammedov <[email protected]>

Add basic regression testing for QOM Interface usage. Test checks casting to interface type/class for following cases:
- interface implementation in leaf class
- interface implementation in intermediate (parent) class

---
 tests/Makefile              |   6 ++-
 tests/check-qom-interface.c | 105 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 110 insertions(+), 1 deletion(-)
 create mode 100644 tests/check-qom-interface.c
tests/Makefile +5 -1
index 8d25878..0b85a34 100644
@@ -52,6 +52,8 @@ check-unit-y += tests/test-int128$(EXESUF)
 gcov-files-test-int128-y =
 check-unit-y += tests/test-bitops$(EXESUF)
 check-unit-y += tests/test-qdev-global-props$(EXESUF)
+check-unit-y += tests/check-qom-interface$(EXESUF)
+gcov-files-check-qom-interface-y = qom/object.c
 
 check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh
 
@@ -138,6 +140,7 @@ test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o
 
 $(test-obj-y): QEMU_INCLUDES += -Itests
 QEMU_CFLAGS += -I$(SRC_PATH)/tests
+qom-core-obj = qom/object.o qom/qom-qobject.o qom/container.o
 
 tests/test-x86-cpuid.o: QEMU_INCLUDES += -I$(SRC_PATH)/target-i386
 
@@ -147,6 +150,7 @@ tests/check-qdict$(EXESUF): tests/check-qdict.o libqemuutil.a
 tests/check-qlist$(EXESUF): tests/check-qlist.o libqemuutil.a
 tests/check-qfloat$(EXESUF): tests/check-qfloat.o libqemuutil.a
 tests/check-qjson$(EXESUF): tests/check-qjson.o libqemuutil.a libqemustub.a
+tests/check-qom-interface$(EXESUF): tests/check-qom-interface.o $(qom-core-obj) libqemuutil.a
 tests/test-coroutine$(EXESUF): tests/test-coroutine.o $(block-obj-y) libqemuutil.a libqemustub.a
 tests/test-aio$(EXESUF): tests/test-aio.o $(block-obj-y) libqemuutil.a libqemustub.a
 tests/test-throttle$(EXESUF): tests/test-throttle.o $(block-obj-y) libqemuutil.a libqemustub.a
@@ -160,7 +164,7 @@ tests/test-int128$(EXESUF): tests/test-int128.o
 tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
 	hw/core/qdev.o hw/core/qdev-properties.o \
 	hw/core/irq.o \
-	qom/object.o qom/container.o qom/qom-qobject.o \
+	$(qom-core-obj) \
 	$(test-qapi-obj-y) \
 	libqemuutil.a libqemustub.a
 
tests/check-qom-interface.c new file +105 -0

105 lines not on this page · raw message

Signature · 1 line
1.8.4
#18 lore raw

[Qemu-devel] [PULL 18/24] qdev: Drop misleading qbus_free() function

In reply to Andreas Färber

From: Stefan Hajnoczi <[email protected]>

Same reasoning as commit 02a5c4c97422b40034f31265e0f139f7846172a8 ("qdev: Drop misleading qdev_free() function"). The qbus_free() function removes the child from the namespace and decrements the reference count. It does not, however, guarantee to free the child since the refcount may still be held.

Just call object_unparent() directly.

---
 hw/core/qdev.c         | 7 +------
 hw/pci/pci_bridge.c    | 2 +-
 include/hw/qdev-core.h | 2 --
 3 files changed, 2 insertions(+), 9 deletions(-)
hw/core/qdev.c +1 -6
index e374a93..bbd780a 100644
@@ -481,11 +481,6 @@ BusState *qbus_create(const char *typename, DeviceState *parent, const char *nam
     return bus;
 }
 
-void qbus_free(BusState *bus)
-{
-    object_unparent(OBJECT(bus));
-}
-
 static char *bus_get_fw_dev_path(BusState *bus, DeviceState *dev)
 {
     BusClass *bc = BUS_GET_CLASS(bus);
@@ -794,7 +789,7 @@ static void device_unparent(Object *obj)
 
     while (dev->num_child_bus) {
         bus = QLIST_FIRST(&dev->child_bus);
-        qbus_free(bus);
+        object_unparent(OBJECT(bus));
     }
     if (dev->realized) {
         object_property_set_bool(obj, false, "realized", NULL);
hw/pci/pci_bridge.c +1 -1
index f72872e..355c3e1 100644
@@ -391,7 +391,7 @@ void pci_bridge_exitfn(PCIDevice *pci_dev)
     pci_bridge_region_cleanup(s, s->windows);
     memory_region_destroy(&s->address_space_mem);
     memory_region_destroy(&s->address_space_io);
-    /* qbus_free() is called automatically during device deletion */
+    /* object_unparent() is called automatically during device deletion */
 }
 
 /*
include/hw/qdev-core.h +0 -2
index c8945a4..651c3e5 100644
@@ -283,8 +283,6 @@ void qdev_reset_all(DeviceState *dev);
 void qbus_reset_all(BusState *bus);
 void qbus_reset_all_fn(void *opaque);
 
-void qbus_free(BusState *bus);
-
 /* This should go away once we get rid of the NULL bus hack */
 BusState *sysbus_get_default(void);
 
Signature · 1 line
1.8.4
#19 lore raw

[Qemu-devel] [PULL 21/24] icc_bus: QOM'ify ICC

In reply to Andreas Färber

From: xiaoqiang zhao <[email protected]>

For consistency, QOM'ify APIC's parent bus.

---
 hw/cpu/icc_bus.c         | 14 ++++++--------
 hw/intc/apic_common.c    | 13 +++++++------
 include/hw/cpu/icc_bus.h |  2 +-
 3 files changed, 14 insertions(+), 15 deletions(-)
hw/cpu/icc_bus.c +6 -8
index 9a4ea7e..7f44c59 100644
@@ -43,15 +43,13 @@ static const TypeInfo icc_bus_info = {
 
 static void icc_device_realize(DeviceState *dev, Error **errp)
 {
-    ICCDevice *id = ICC_DEVICE(dev);
-    ICCDeviceClass *idc = ICC_DEVICE_GET_CLASS(id);
-
-    if (idc->init) {
-        if (idc->init(id) < 0) {
-            error_setg(errp, "%s initialization failed.",
-                       object_get_typename(OBJECT(dev)));
-        }
+    ICCDeviceClass *idc = ICC_DEVICE_GET_CLASS(dev);
+
+    /* convert to QOM */
+    if (idc->realize) {
+        idc->realize(dev, errp);
     }
+
 }
 
 static void icc_device_class_init(ObjectClass *oc, void *data)
hw/intc/apic_common.c +7 -6
index 2842655..c623fcc 100644
@@ -284,7 +284,7 @@ static int apic_load_old(QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-static int apic_init_common(ICCDevice *dev)
+static void apic_common_realize(DeviceState *dev, Error **errp)
 {
     APICCommonState *s = APIC_COMMON(dev);
     APICCommonClass *info;
@@ -293,14 +293,16 @@ static int apic_init_common(ICCDevice *dev)
     static bool mmio_registered;
 
     if (apic_no >= MAX_APICS) {
-        return -1;
+        error_setg(errp, "%s initialization failed.",
+                   object_get_typename(OBJECT(dev)));
+        return;
     }
     s->idx = apic_no++;
 
     info = APIC_COMMON_GET_CLASS(s);
-    info->realize(DEVICE(dev), NULL);
+    info->realize(dev, errp);
     if (!mmio_registered) {
-        ICCBus *b = ICC_BUS(qdev_get_parent_bus(DEVICE(dev)));
+        ICCBus *b = ICC_BUS(qdev_get_parent_bus(dev));
         memory_region_add_subregion(b->apic_address_space, 0, &s->io_memory);
         mmio_registered = true;
     }
@@ -315,7 +317,6 @@ static int apic_init_common(ICCDevice *dev)
         info->enable_tpr_reporting(s, true);
     }
 
-    return 0;
 }
 
 static void apic_dispatch_pre_save(void *opaque)
@@ -387,7 +388,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_apic_common;
     dc->reset = apic_reset_common;
     dc->props = apic_properties_common;
-    idc->init = apic_init_common;
+    idc->realize = apic_common_realize;
     /*
      * Reason: APIC and CPU need to be wired up by
      * x86_cpu_apic_create()
include/hw/cpu/icc_bus.h +1 -1
index b550070..98a979f 100644
@@ -66,7 +66,7 @@ typedef struct ICCDeviceClass {
     DeviceClass parent_class;
     /*< public >*/
 
-    int (*init)(ICCDevice *dev); /* TODO replace with QOM realize */
+    DeviceRealize realize;
 } ICCDeviceClass;
 
 #define TYPE_ICC_DEVICE "icc-device"
Signature · 1 line
1.8.4
#20 lore raw

[Qemu-devel] [PULL 24/24] qdev-monitor: Improve error message for -device nonexistant

In reply to Andreas Färber

From: Markus Armbruster <[email protected]>

Once upon a time, the error message was:

qemu: -device nonexistant: Device "nonexistant" not found. Try -device '?' for a list.

But progress marches on, and conversion to QError (commit 0204276) changed it into:

Invalid parameter 'driver'
Try with argument '?' for a list.

Progress didn't stop there, of course. After a couple of iterations, we arrived at the current message (commit 6acbe4c):

qemu: -device nonexistant: Parameter 'driver' expects device type

Mission accomplished: this is complete mush.

We've since abandoned our quest for "rich" error objects, fortunately before it turned all error messages into mush. Time to undo the damage to this one. Make it:

qemu: -device nonexistant: nonexistant is not a valid device model name

---
 qdev-monitor.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
qdev-monitor.c +2 -1
index 177b849..ef63cbd 100644
@@ -479,7 +479,8 @@ DeviceState *qdev_device_add(QemuOpts *opts)
     }
 
     if (!object_class_dynamic_cast(oc, TYPE_DEVICE)) {
-        qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver", "device type");
+        qerror_report(ERROR_CLASS_GENERIC_ERROR,
+                      "'%s' is not a valid device model name", driver);
         return NULL;
     }
 
Signature · 1 line
1.8.4
#21 lore raw

[Qemu-devel] [PULL 19/24] apic: Cleanup for QOM'ification

In reply to Andreas Färber

From: xiaoqiang zhao <[email protected]>

Do some cleanup, including:
1. Remove DO_UPCAST() for APICCommonState
2. Change DeviceState pointers from 'd' to 'dev', better to understand
3. Rename 'register_types' to specifically 'apic_common_register_types'

---
 hw/i386/kvm/apic.c    |  8 +++----
 hw/intc/apic.c        | 42 ++++++++++++++++++------------------
 hw/intc/apic_common.c | 60 +++++++++++++++++++++++++--------------------------
 3 files changed, 55 insertions(+), 55 deletions(-)
hw/i386/kvm/apic.c +4 -4
index 5609063..84f6056 100644
@@ -25,9 +25,9 @@ static inline uint32_t kvm_apic_get_reg(struct kvm_lapic_state *kapic,
     return *((uint32_t *)(kapic->regs + (reg_id << 4)));
 }
 
-void kvm_put_apic_state(DeviceState *d, struct kvm_lapic_state *kapic)
+void kvm_put_apic_state(DeviceState *dev, struct kvm_lapic_state *kapic)
 {
-    APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
+    APICCommonState *s = APIC_COMMON(dev);
     int i;
 
     memset(kapic, 0, sizeof(*kapic));
@@ -51,9 +51,9 @@ void kvm_put_apic_state(DeviceState *d, struct kvm_lapic_state *kapic)
     kvm_apic_set_reg(kapic, 0x3e, s->divide_conf);
 }
 
-void kvm_get_apic_state(DeviceState *d, struct kvm_lapic_state *kapic)
+void kvm_get_apic_state(DeviceState *dev, struct kvm_lapic_state *kapic)
 {
-    APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
+    APICCommonState *s = APIC_COMMON(dev);
     int i, v;
 
     s->id = kvm_apic_get_reg(kapic, 0x2) >> 24;
hw/intc/apic.c +21 -21

118 lines not on this page · raw message

hw/intc/apic_common.c +30 -30

162 lines not on this page · raw message

Signature · 1 line
1.8.4
#22 lore raw

[Qemu-devel] [PULL 20/24] apic: QOM'ify APIC

In reply to Andreas Färber

From: xiaoqiang zhao <[email protected]>

Convert 'init' function to QOM's 'realize' for apic, kvm/apic and xen/xen_apic.

---
 hw/i386/kvm/apic.c              | 6 ++++--
 hw/intc/apic.c                  | 6 ++++--
 hw/intc/apic_common.c           | 2 +-
 hw/xen/xen_apic.c               | 6 ++++--
 include/hw/i386/apic_internal.h | 2 +-
 5 files changed, 14 insertions(+), 8 deletions(-)
hw/i386/kvm/apic.c +4 -2
index 84f6056..e873b50 100644
@@ -171,8 +171,10 @@ static const MemoryRegionOps kvm_apic_io_ops = {
     .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
-static void kvm_apic_init(APICCommonState *s)
+static void kvm_apic_realize(DeviceState *dev, Error **errp)
 {
+    APICCommonState *s = APIC_COMMON(dev);
+
     memory_region_init_io(&s->io_memory, NULL, &kvm_apic_io_ops, s, "kvm-apic-msi",
                           APIC_SPACE_SIZE);
 
@@ -185,7 +187,7 @@ static void kvm_apic_class_init(ObjectClass *klass, void *data)
 {
     APICCommonClass *k = APIC_COMMON_CLASS(klass);
 
-    k->init = kvm_apic_init;
+    k->realize = kvm_apic_realize;
     k->set_base = kvm_apic_set_base;
     k->set_tpr = kvm_apic_set_tpr;
     k->get_tpr = kvm_apic_get_tpr;
hw/intc/apic.c +4 -2
index b542628..3d3deb6 100644
@@ -871,8 +871,10 @@ static const MemoryRegionOps apic_io_ops = {
     .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
-static void apic_init(APICCommonState *s)
+static void apic_realize(DeviceState *dev, Error **errp)
 {
+    APICCommonState *s = APIC_COMMON(dev);
+
     memory_region_init_io(&s->io_memory, OBJECT(s), &apic_io_ops, s, "apic-msi",
                           APIC_SPACE_SIZE);
 
@@ -886,7 +888,7 @@ static void apic_class_init(ObjectClass *klass, void *data)
 {
     APICCommonClass *k = APIC_COMMON_CLASS(klass);
 
-    k->init = apic_init;
+    k->realize = apic_realize;
     k->set_base = apic_set_base;
     k->set_tpr = apic_set_tpr;
     k->get_tpr = apic_get_tpr;
hw/intc/apic_common.c +1 -1
index de5e190..2842655 100644
@@ -298,7 +298,7 @@ static int apic_init_common(ICCDevice *dev)
     s->idx = apic_no++;
 
     info = APIC_COMMON_GET_CLASS(s);
-    info->init(s);
+    info->realize(DEVICE(dev), NULL);
     if (!mmio_registered) {
         ICCBus *b = ICC_BUS(qdev_get_parent_bus(DEVICE(dev)));
         memory_region_add_subregion(b->apic_address_space, 0, &s->io_memory);
hw/xen/xen_apic.c +4 -2
index 9f91e0f..63bb7f7 100644
@@ -36,8 +36,10 @@ static const MemoryRegionOps xen_apic_io_ops = {
     .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
-static void xen_apic_init(APICCommonState *s)
+static void xen_apic_realize(DeviceState *dev, Error **errp)
 {
+    APICCommonState *s = APIC_COMMON(dev);
+
     memory_region_init_io(&s->io_memory, OBJECT(s), &xen_apic_io_ops, s,
                           "xen-apic-msi", APIC_SPACE_SIZE);
 
@@ -72,7 +74,7 @@ static void xen_apic_class_init(ObjectClass *klass, void *data)
 {
     APICCommonClass *k = APIC_COMMON_CLASS(klass);
 
-    k->init = xen_apic_init;
+    k->realize = xen_apic_realize;
     k->set_base = xen_apic_set_base;
     k->set_tpr = xen_apic_set_tpr;
     k->get_tpr = xen_apic_get_tpr;
include/hw/i386/apic_internal.h +1 -1
index 1b0a7fb..70542a6 100644
@@ -80,7 +80,7 @@ typedef struct APICCommonClass
 {
     ICCDeviceClass parent_class;
 
-    void (*init)(APICCommonState *s);
+    DeviceRealize realize;
     void (*set_base)(APICCommonState *s, uint64_t val);
     void (*set_tpr)(APICCommonState *s, uint8_t val);
     uint8_t (*get_tpr)(APICCommonState *s);
Signature · 1 line
1.8.4
#23 lore raw

[Qemu-devel] [PULL 22/24] ioapic: Cleanup for QOM'ification

In reply to Andreas Färber

From: xiaoqiang zhao <[email protected]>

Some cleanups:
* ioapic_common.c: Rename 'register_types' to 'ioapic_common_register_types'
* Replace inline 'DEVICE(s)' with local 'DeviceState *dev' variable

---
 hw/i386/kvm/ioapic.c    | 4 +++-
 hw/intc/ioapic.c        | 4 +++-
 hw/intc/ioapic_common.c | 4 ++--
 3 files changed, 8 insertions(+), 4 deletions(-)
hw/i386/kvm/ioapic.c +3 -1
index f11a540..772a712 100644
@@ -129,9 +129,11 @@ static void kvm_ioapic_set_irq(void *opaque, int irq, int level)
 
 static void kvm_ioapic_init(IOAPICCommonState *s, int instance_no)
 {
+    DeviceState *dev = DEVICE(s);
+
     memory_region_init_reservation(&s->io_memory, NULL, "kvm-ioapic", 0x1000);
 
-    qdev_init_gpio_in(DEVICE(s), kvm_ioapic_set_irq, IOAPIC_NUM_PINS);
+    qdev_init_gpio_in(dev, kvm_ioapic_set_irq, IOAPIC_NUM_PINS);
 }
 
 static Property kvm_ioapic_properties[] = {
hw/intc/ioapic.c +3 -1
index d866e00..8842845 100644
@@ -227,10 +227,12 @@ static const MemoryRegionOps ioapic_io_ops = {
 
 static void ioapic_init(IOAPICCommonState *s, int instance_no)
 {
+    DeviceState *dev = DEVICE(s);
+
     memory_region_init_io(&s->io_memory, OBJECT(s), &ioapic_io_ops, s,
                           "ioapic", 0x1000);
 
-    qdev_init_gpio_in(DEVICE(s), ioapic_set_irq, IOAPIC_NUM_PINS);
+    qdev_init_gpio_in(dev, ioapic_set_irq, IOAPIC_NUM_PINS);
 
     ioapics[instance_no] = s;
 }
hw/intc/ioapic_common.c +2 -2
index 9ba1a26..4611f7f 100644
@@ -109,9 +109,9 @@ static const TypeInfo ioapic_common_type = {
     .abstract = true,
 };
 
-static void register_types(void)
+static void ioapic_common_register_types(void)
 {
     type_register_static(&ioapic_common_type);
 }
 
-type_init(register_types)
+type_init(ioapic_common_register_types)
Signature · 1 line
1.8.4
#24 lore raw

[Qemu-devel] [PULL 23/24] ioapic: QOM'ify ioapic

In reply to Andreas Färber

From: xiaoqiang zhao <[email protected]>

Convert 'init' function to QOM's 'realize' for ioapic and kvm-ioapic. Change variable 'ioapic_no' from static to global. Then we can drop the 'instance_no' function argument.

---
 hw/i386/kvm/ioapic.c              |  6 +++---
 hw/intc/ioapic.c                  | 11 +++++++----
 hw/intc/ioapic_common.c           | 11 +++++++++--
 include/hw/i386/ioapic_internal.h |  3 ++-
 4 files changed, 21 insertions(+), 10 deletions(-)
hw/i386/kvm/ioapic.c +3 -3
index 772a712..d2a6c4c 100644
@@ -127,9 +127,9 @@ static void kvm_ioapic_set_irq(void *opaque, int irq, int level)
     apic_report_irq_delivered(delivered);
 }
 
-static void kvm_ioapic_init(IOAPICCommonState *s, int instance_no)
+static void kvm_ioapic_realize(DeviceState *dev, Error **errp)
 {
-    DeviceState *dev = DEVICE(s);
+    IOAPICCommonState *s = IOAPIC_COMMON(dev);
 
     memory_region_init_reservation(&s->io_memory, NULL, "kvm-ioapic", 0x1000);
 
@@ -146,7 +146,7 @@ static void kvm_ioapic_class_init(ObjectClass *klass, void *data)
     IOAPICCommonClass *k = IOAPIC_COMMON_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    k->init      = kvm_ioapic_init;
+    k->realize   = kvm_ioapic_realize;
     k->pre_save  = kvm_ioapic_get;
     k->post_load = kvm_ioapic_put;
     dc->reset    = kvm_ioapic_reset;
hw/intc/ioapic.c +7 -4
index 8842845..652dd47 100644
@@ -36,6 +36,9 @@
 
 static IOAPICCommonState *ioapics[MAX_IOAPICS];
 
+/* global variable from ioapic_common.c */
+extern int ioapic_no;
+
 static void ioapic_service(IOAPICCommonState *s)
 {
     uint8_t i;
@@ -225,16 +228,16 @@ static const MemoryRegionOps ioapic_io_ops = {
     .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
-static void ioapic_init(IOAPICCommonState *s, int instance_no)
+static void ioapic_realize(DeviceState *dev, Error **errp)
 {
-    DeviceState *dev = DEVICE(s);
+    IOAPICCommonState *s = IOAPIC_COMMON(dev);
 
     memory_region_init_io(&s->io_memory, OBJECT(s), &ioapic_io_ops, s,
                           "ioapic", 0x1000);
 
     qdev_init_gpio_in(dev, ioapic_set_irq, IOAPIC_NUM_PINS);
 
-    ioapics[instance_no] = s;
+    ioapics[ioapic_no] = s;
 }
 
 static void ioapic_class_init(ObjectClass *klass, void *data)
@@ -242,7 +245,7 @@ static void ioapic_class_init(ObjectClass *klass, void *data)
     IOAPICCommonClass *k = IOAPIC_COMMON_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
-    k->init = ioapic_init;
+    k->realize = ioapic_realize;
     dc->reset = ioapic_reset_common;
 }
 
hw/intc/ioapic_common.c +9 -2
index 4611f7f..4d3d309 100644
@@ -23,6 +23,14 @@
 #include "hw/i386/ioapic_internal.h"
 #include "hw/sysbus.h"
 
+/* ioapic_no count start from 0 to MAX_IOAPICS,
+ * remove as static variable from ioapic_common_init.
+ * now as a global variable, let child to increase the counter
+ * then we can drop the 'instance_no' argument
+ * and convert to our QOM's realize function
+ */
+int ioapic_no;
+
 void ioapic_reset_common(DeviceState *dev)
 {
     IOAPICCommonState *s = IOAPIC_COMMON(dev);
@@ -61,7 +69,6 @@ static void ioapic_common_realize(DeviceState *dev, Error **errp)
 {
     IOAPICCommonState *s = IOAPIC_COMMON(dev);
     IOAPICCommonClass *info;
-    static int ioapic_no;
 
     if (ioapic_no >= MAX_IOAPICS) {
         error_setg(errp, "Only %d ioapics allowed", MAX_IOAPICS);
@@ -69,7 +76,7 @@ static void ioapic_common_realize(DeviceState *dev, Error **errp)
     }
 
     info = IOAPIC_COMMON_GET_CLASS(s);
-    info->init(s, ioapic_no);
+    info->realize(dev, errp);
 
     sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->io_memory);
     ioapic_no++;
include/hw/i386/ioapic_internal.h +2 -1
index 25576c8..3be3352 100644
@@ -83,7 +83,8 @@ typedef struct IOAPICCommonState IOAPICCommonState;
 
 typedef struct IOAPICCommonClass {
     SysBusDeviceClass parent_class;
-    void (*init)(IOAPICCommonState *s, int instance_no);
+
+    DeviceRealize realize;
     void (*pre_save)(IOAPICCommonState *s);
     void (*post_load)(IOAPICCommonState *s);
 } IOAPICCommonClass;
Signature · 1 line
1.8.4
#25 lore raw
In reply to Andreas Färber

Am 24.12.2013 17:56, schrieb Andreas Färber:

Quoted 19 lines

Hello Anthony,

This is my QOM (devices) patch queue. Please pull.

Happy holidays,

Andreas

P.S. I reproducibly get a signal message:
TEST: tests/acpi-test... (pid=6364)
/i386/acpi/tcg: main-loop: WARNING: I/O thread spun for 1000 iterations
qemu: terminating on signal 15 from pid 6364 OK
PASS: tests/acpi-test
both before and after the queue.

Cc Anthony Liguori <[email protected]>
Cc Edgar E. Iglesias <[email protected]>
Quoted 8 lines
Cc Markus Armbruster <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc xiaoqiang zhao <[email protected]>
Cc Hervé Poussineau <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Peter Crosthwaite <[email protected]>
Cc Alexey Kardashevskiy <[email protected]>

Crap, got that typo in the commit as well, v2 coming up...

Andreas

Quoted 149 lines
Cc Chen Fan <[email protected]>

The following changes since commit f976b09ea249cccc3fd41c98aaf6512908db0bae:

PPC: Fix compilation with TCG debug (2013-12-22 19:15:55 +0100)

are available in the git repository at:

git://github.com/afaerber/qemu-cpu.git tags/qom-devices-for-anthony

for you to fetch changes up to e6111b371b9f8bc98ae566417ed09bce9e86a772:

qdev-monitor: Improve error message for -device nonexistant (2013-12-24 17:27:18 +0100)

----------------------------------------------------------------
QOM infrastructure fixes and device conversions

* QOM interface fixes and unit test
* Device no_user sanitization and documentation
* Device error reporting improvement
* Conversion of APIC, ICC, IOAPIC to QOM realization model

----------------------------------------------------------------
Hervé Poussineau (1):
qom: Detect bad reentrance during object_class_foreach()

Igor Mammedov (1):
tests: Test QOM interface casting

Markus Armbruster (14):
qdev: Replace no_user by cannot_instantiate_with_device_add_yet
sysbus: Set cannot_instantiate_with_device_add_yet
cpu: Document why cannot_instantiate_with_device_add_yet
apic: Document why cannot_instantiate_with_device_add_yet
pci-host: Consistently set cannot_instantiate_with_device_add_yet
ich9: Document why cannot_instantiate_with_device_add_yet piix3 piix4: Clean up use of cannot_instantiate_with_device_add_yet
vt82c686: Clean up use of cannot_instantiate_with_device_add_yet
isa: Clean up use of cannot_instantiate_with_device_add_yet
qdev: Do not let the user try to device_add when it cannot work
qdev-monitor: Avoid device_add crashing on non-device driver name
hw: cannot_instantiate_with_device_add_yet due to pointer props
qdev: Document that pointer properties kill device_add
qdev-monitor: Improve error message for -device nonexistant

Paolo Bonzini (1):
qom: Do not register interface "types" in the type table and fix names

Peter Crosthwaite (1):
qom: Split out object and class caches

Stefan Hajnoczi (1):
qdev: Drop misleading qbus_free() function

xiaoqiang zhao (5):
apic: Cleanup for QOM'ification
apic: QOM'ify APIC
icc_bus: QOM'ify ICC
ioapic: Cleanup for QOM'ification
ioapic: QOM'ify ioapic

 hw/acpi/piix4.c                   |   6 ++-
 hw/alpha/typhoon.c                |   2 -
 hw/arm/versatilepb.c              |   1 -
 hw/audio/marvell_88w8618.c        |   2 +
 hw/audio/pcspk.c                  |   3 +-
 hw/audio/pl041.c                  |   1 -
 hw/block/fdc.c                    |   1 -
 hw/core/qdev.c                    |   7 +--
 hw/core/sysbus.c                  |   7 +++
 hw/cpu/icc_bus.c                  |  14 +++--
 hw/display/pl110.c                |   1 -
 hw/dma/pl080.c                    |   1 -
 hw/dma/sparc32_dma.c              |   2 +
 hw/gpio/omap_gpio.c               |   4 ++
 hw/i2c/omap_i2c.c                 |   2 +
 hw/i2c/smbus_eeprom.c             |   2 +
 hw/i2c/smbus_ich9.c               |   6 ++-
 hw/i386/kvm/apic.c                |  14 ++---
 hw/i386/kvm/clock.c               |   1 -
 hw/i386/kvm/ioapic.c              |   8 +--
 hw/i386/kvmvapic.c                |   1 -
 hw/i386/pc.c                      |   7 ++-
 hw/ide/piix.c                     |   3 --
 hw/ide/via.c                      |   1 -
 hw/input/pckbd.c                  |   1 -
 hw/input/vmmouse.c                |   3 +-
 hw/intc/apic.c                    |  48 ++++++++---------
 hw/intc/apic_common.c             |  79 ++++++++++++++--------------
 hw/intc/arm_gic.c                 |   1 -
 hw/intc/arm_gic_common.c          |   1 -
 hw/intc/arm_gic_kvm.c             |   1 -
 hw/intc/etraxfs_pic.c             |   4 ++
 hw/intc/grlib_irqmp.c             |   2 +
 hw/intc/i8259_common.c            |   8 ++-
 hw/intc/ioapic.c                  |  13 +++--
 hw/intc/ioapic_common.c           |  16 ++++--
 hw/intc/omap_intc.c               |   4 ++
 hw/intc/pl190.c                   |   1 -
 hw/isa/isa-bus.c                  |   1 -
 hw/isa/lpc_ich9.c                 |   7 ++-
 hw/isa/piix4.c                    |   6 ++-
 hw/isa/vt82c686.c                 |   6 ++-
 hw/mips/gt64xxx_pci.c             |   6 +++
 hw/misc/arm_l2x0.c                |   1 -
 hw/misc/vmport.c                  |   3 +-
 hw/net/etraxfs_eth.c              |   2 +
 hw/net/lance.c                    |   2 +
 hw/nvram/fw_cfg.c                 |   1 -
 hw/pci-bridge/dec.c               |   6 +++
 hw/pci-host/apb.c                 |   6 +++
 hw/pci-host/bonito.c              |   8 +--
 hw/pci-host/grackle.c             |   8 +--
 hw/pci-host/piix.c                |  19 +++++--
 hw/pci-host/ppce500.c             |   5 ++
 hw/pci-host/prep.c                |   7 ++-
 hw/pci-host/q35.c                 |   5 ++
 hw/pci-host/uninorth.c            |  24 +++++++++
 hw/pci-host/versatile.c           |   6 +++
 hw/pci/pci_bridge.c               |   2 +-
 hw/ppc/ppc4xx_pci.c               |   5 ++
 hw/ppc/spapr_vio.c                |   2 -
 hw/s390x/ipl.c                    |   1 -
 hw/s390x/s390-virtio-bus.c        |   2 -
 hw/s390x/virtio-ccw.c             |   2 -
 hw/sd/pl181.c                     |   1 -
 hw/sh4/sh_pci.c                   |   6 +++
 hw/timer/arm_mptimer.c            |   1 -
 hw/timer/hpet.c                   |   1 -
 hw/timer/i8254_common.c           |   7 ++-
 hw/timer/m48t59.c                 |   3 +-
 hw/timer/mc146818rtc.c            |   3 +-
 hw/timer/pl031.c                  |   1 -
 hw/xen/xen_apic.c                 |   6 ++-
 include/hw/cpu/icc_bus.h          |   2 +-
 include/hw/i386/apic_internal.h   |   2 +-
 include/hw/i386/ioapic_internal.h |   3 +-
 include/hw/qdev-core.h            |  15 ++++--
 include/hw/qdev-properties.h      |  17 ++++++
 include/qom/object.h              |   4 +-
 qdev-monitor.c                    |  15 ++++--
 qom/cpu.c                         |   6 ++-
 qom/object.c                      |  50 ++++++++++++------
 tests/Makefile                    |   6 ++-
 tests/check-qom-interface.c       | 105 ++++++++++++++++++++++++++++++++++++++
 84 files changed, 493 insertions(+), 183 deletions(-)
 create mode 100644 tests/check-qom-interface.c
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg