@@ -320,7 +320,7 @@ void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
DriveInfo *dinfo = drive_get(IF_MTD, 0, unit0 + i);
DeviceState *dev;
- dev = qdev_new(flashtype);
+ dev = qdev_new_dynamic(flashtype, &error_fatal);
if (dinfo) {
qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo));
}
@@ -83,7 +83,7 @@ static void npcm7xx_connect_flash(NPCM7xxFIUState *fiu, int cs_no,
DeviceState *flash;
qemu_irq flash_cs;
- flash = qdev_new(flash_type);
+ flash = qdev_new_dynamic(flash_type, &error_fatal);
if (dinfo) {
qdev_prop_set_drive(flash, "drive", blk_by_legacy_dinfo(dinfo));
}
@@ -419,7 +419,7 @@ static void create_its(SBSAMachineState *sms)
const char *itsclass = its_class_name();
DeviceState *dev;
- dev = qdev_new(itsclass);
+ dev = qdev_new_dynamic(itsclass, &error_fatal);
object_property_set_link(OBJECT(dev), "parent-gicv3", OBJECT(sms->gic),
&error_abort);
@@ -438,7 +438,7 @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem)
gictype = gicv3_class_name();
- sms->gic = qdev_new(gictype);
+ sms->gic = qdev_new_dynamic(gictype, &error_fatal);
qdev_prop_set_uint32(sms->gic, "revision", 3);
qdev_prop_set_uint32(sms->gic, "num-cpu", smp_cpus);
/*
@@ -239,7 +239,7 @@ static void init_cpus(MachineState *ms, const char *cpu_type,
* this must happen after the CPUs are created because a15mpcore_priv
* wires itself up to the CPU's generic_timer gpio out lines.
*/
- dev = qdev_new(privdev);
+ dev = qdev_new_dynamic(privdev, &error_fatal);
qdev_prop_set_uint32(dev, "num-cpu", smp_cpus);
busdev = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(busdev, &error_fatal);
@@ -715,7 +715,7 @@ static void create_its(VirtMachineState *vms)
return;
}
- dev = qdev_new(itsclass);
+ dev = qdev_new_dynamic(itsclass, &error_fatal);
object_property_set_link(OBJECT(dev), "parent-gicv3", OBJECT(vms->gic),
&error_abort);
@@ -791,7 +791,7 @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
default:
g_assert_not_reached();
}
- vms->gic = qdev_new(gictype);
+ vms->gic = qdev_new_dynamic(gictype, &error_fatal);
qdev_prop_set_uint32(vms->gic, "revision", revision);
qdev_prop_set_uint32(vms->gic, "num-cpu", smp_cpus);
/* Note that the num-irq property counts both internal and external
@@ -132,7 +132,7 @@ void soundhw_init(void)
}
if (c->typename) {
- DeviceState *dev = qdev_new(c->typename);
+ DeviceState *dev = qdev_new_dynamic(c->typename, &error_fatal);
qdev_prop_set_string(dev, "audiodev", audiodev_id);
qdev_realize_and_unref(dev, bus, &error_fatal);
} else {
@@ -1034,6 +1034,7 @@ static void xen_block_device_create(XenBackendInstance *backend,
XenDevice *xendev = NULL;
const char *type;
XenBlockDevice *blockdev;
+ DeviceState *dev;
if (qemu_strtoul(name, NULL, 10, &number)) {
error_setg(errp, "failed to parse name '%s'", name);
@@ -1075,7 +1076,11 @@ static void xen_block_device_create(XenBackendInstance *backend,
goto fail;
}
- xendev = XEN_DEVICE(qdev_new(type));
+ dev = qdev_new_dynamic(type, errp);
+ if (!dev) {
+ goto fail;
+ }
+ xendev = XEN_DEVICE(dev);
blockdev = XEN_BLOCK_DEVICE(xendev);
if (!object_property_set_str(OBJECT(xendev), "vdev", vdev,
@@ -221,7 +221,7 @@ DeviceState *sysbus_create_varargs(const char *name,
qemu_irq irq;
int n;
- dev = qdev_new(name);
+ dev = qdev_new_dynamic(name, &error_fatal);
s = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(s, &error_fatal);
if (addr != (hwaddr)-1) {
@@ -369,7 +369,7 @@ I2CSlave *i2c_slave_new(const char *name, uint8_t addr)
{
DeviceState *dev;
- dev = qdev_new(name);
+ dev = qdev_new_dynamic(name, &error_fatal);
qdev_prop_set_uint8(dev, "address", addr);
return I2C_SLAVE(dev);
}
@@ -155,7 +155,7 @@ int isa_register_portio_list(ISADevice *dev,
ISADevice *isa_new(const char *name)
{
- return ISA_DEVICE(qdev_new(name));
+ return ISA_DEVICE(qdev_new_dynamic(name, &error_fatal));
}
ISADevice *isa_create_simple(ISABus *bus, const char *name)
@@ -2186,7 +2186,7 @@ static PCIDevice *pci_new_internal(int devfn, bool multifunction,
{
DeviceState *dev;
- dev = qdev_new(name);
+ dev = qdev_new_dynamic(name, &error_fatal);
qdev_prop_set_int32(dev, "addr", devfn);
qdev_prop_set_bit(dev, "multifunction", multifunction);
return PCI_DEVICE(dev);
@@ -1115,7 +1115,7 @@ static void pnv_init(MachineState *machine)
pnv->chips = g_new0(PnvChip *, pnv->num_chips);
for (i = 0; i < pnv->num_chips; i++) {
char chip_name[32];
- Object *chip = OBJECT(qdev_new(chip_typename));
+ Object *chip = OBJECT(qdev_new_dynamic(chip_typename, &error_fatal));
uint64_t chip_ram_size = pnv_chip_get_ram_size(pnv, i);
pnv->chips[i] = PNV_CHIP(chip);
@@ -242,7 +242,7 @@ static void s390_create_sclpconsole(SCLPDevice *sclp,
BusState *ev_fac_bus = sclp_get_event_facility_bus(ef);
DeviceState *dev;
- dev = qdev_new(type);
+ dev = qdev_new_dynamic(type, &error_fatal);
object_property_add_child(OBJECT(ef), type, OBJECT(dev));
qdev_prop_set_chr(dev, "chardev", chardev);
qdev_realize_and_unref(dev, ev_fac_bus, &error_fatal);
@@ -396,7 +396,10 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
driver = "scsi-hd";
}
}
- dev = qdev_new(driver);
+ dev = qdev_new_dynamic(driver, errp);
+ if (!dev) {
+ return NULL;
+ }
name = g_strdup_printf("legacy[%d]", unit);
object_property_add_child(OBJECT(bus), name, OBJECT(dev));
g_free(name);
@@ -141,7 +141,7 @@ bool ssi_realize_and_unref(DeviceState *dev, SSIBus *bus, Error **errp)
DeviceState *ssi_create_peripheral(SSIBus *bus, const char *name)
{
- DeviceState *dev = qdev_new(name);
+ DeviceState *dev = qdev_new_dynamic(name, &error_fatal);
ssi_realize_and_unref(dev, bus, &error_fatal);
return dev;
@@ -581,7 +581,7 @@ void usb_pcap_data(USBPacket *p, bool setup);
static inline USBDevice *usb_new(const char *name)
{
- return USB_DEVICE(qdev_new(name));
+ return USB_DEVICE(qdev_new_dynamic(name, &error_fatal));
}
static inline bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp)
@@ -654,7 +654,7 @@ Object *object_new_internal(const char *typename);
* @typename: The name of the type of the object to instantiate.
* @errp: pointer to be filled with error details on failure
*
- * This method should be used where @typename is dynamically chosen
+ * This method must be used where @typename is dynamically chosen
* at runtime, which has the possibility of unexpected choices leading
* to failures.
*
@@ -663,7 +663,7 @@ Object *object_new_internal(const char *typename);
* the last reference is dropped.
*
* If an instance of @typename is not permitted to be instantiated, an
- * error will be raised. This can happen if @typename is abstract.
+ * error will be reported. This can happen if @typename is abstract.
*
* Returns: The newly allocated and instantiated object.
*/
@@ -1175,7 +1175,7 @@ DeviceState *qemu_create_nic_device(const char *typename, bool match_default,
return NULL;
}
- dev = qdev_new(typename);
+ dev = qdev_new_dynamic(typename, &error_fatal);
qdev_set_nic_properties(dev, nd);
return dev;
}
@@ -1225,7 +1225,7 @@ void qemu_create_nic_bus_devices(BusState *bus, const char *parent_type,
continue;
}
- dev = qdev_new(model);
+ dev = qdev_new_dynamic(model, &error_fatal);
qdev_set_nic_properties(dev, nd);
qdev_realize_and_unref(dev, bus, &error_fatal);
}
@@ -686,7 +686,10 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
}
/* create device */
- dev = qdev_new(driver);
+ dev = qdev_new_dynamic(driver, errp);
+ if (!dev) {
+ return NULL;
+ }
/* Check whether the hotplug is allowed by the machine */
if (phase_check(PHASE_MACHINE_READY)) {