@@ -996,7 +996,11 @@ static Chardev *chardev_new(const char *id, const char *typename,
assert(g_str_has_prefix(typename, "chardev-"));
assert(id);
- obj = object_new(typename);
+ obj = object_new_dynamic(typename, errp);
+ if (!obj) {
+ return NULL;
+ }
+
chr = CHARDEV(obj);
chr->handover_yank_instance = handover_yank_instance;
chr->label = g_strdup(id);
@@ -385,7 +385,7 @@ static void aspeed_machine_init(MachineState *machine)
DriveInfo *emmc0 = NULL;
bool boot_emmc;
- bmc->soc = ASPEED_SOC(object_new(amc->soc_name));
+ bmc->soc = ASPEED_SOC(object_new_dynamic(amc->soc_name, &error_fatal));
object_property_add_child(OBJECT(machine), "soc", OBJECT(bmc->soc));
object_unref(OBJECT(bmc->soc));
sc = ASPEED_SOC_GET_CLASS(bmc->soc);
@@ -1594,7 +1594,7 @@ static void aspeed_minibmc_machine_init(MachineState *machine)
sysclk = clock_new(OBJECT(machine), "SYSCLK");
clock_set_hz(sysclk, SYSCLK_FRQ);
- bmc->soc = ASPEED_SOC(object_new(amc->soc_name));
+ bmc->soc = ASPEED_SOC(object_new_dynamic(amc->soc_name, &error_fatal));
object_property_add_child(OBJECT(machine), "soc", OBJECT(bmc->soc));
object_unref(OBJECT(bmc->soc));
qdev_connect_clock_in(DEVICE(bmc->soc), "sysclk", sysclk);
@@ -554,7 +554,8 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
int i, n;
for (n = 0; n < EXYNOS4210_NCPUS; n++) {
- Object *cpuobj = object_new(ARM_CPU_TYPE_NAME("cortex-a9"));
+ Object *cpuobj = object_new_dynamic(ARM_CPU_TYPE_NAME("cortex-a9"),
+ &error_fatal);
object_property_add_child(OBJECT(s), "cpu[*]", cpuobj);
/* By default A9 CPUs have EL3 enabled. This board does not currently
@@ -206,7 +206,7 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
Object *cpuobj;
ARMCPU *cpu;
- cpuobj = object_new(machine->cpu_type);
+ cpuobj = object_new_dynamic(machine->cpu_type, &error_abort);
cpu = ARM_CPU(cpuobj);
object_property_add_child(OBJECT(machine), "cpu[*]", cpuobj);
@@ -595,7 +595,7 @@ static void integratorcp_init(MachineState *machine)
DriveInfo *dinfo;
int i;
- cpuobj = object_new(machine->cpu_type);
+ cpuobj = object_new_dynamic(machine->cpu_type, &error_fatal);
/* By default ARM1176 CPUs have EL3 enabled. This board does not
* currently support EL3 so the CPU EL3 property is disabled before
@@ -387,7 +387,8 @@ static void mps3r_common_init(MachineState *machine)
memory_region_add_subregion_overlap(&mms->cpu_sysmem[i], 0,
&mms->sysmem_alias[i], -1);
- mms->cpu[i] = object_new(machine->cpu_type);
+ mms->cpu[i] = object_new_dynamic(machine->cpu_type,
+ &error_fatal);
object_property_set_link(mms->cpu[i], "memory",
OBJECT(&mms->cpu_sysmem[i]), &error_abort);
object_property_set_int(mms->cpu[i], "reset-cbar",
@@ -116,7 +116,8 @@ static void realview_init(MachineState *machine,
}
for (n = 0; n < smp_cpus; n++) {
- Object *cpuobj = object_new(machine->cpu_type);
+ Object *cpuobj = object_new_dynamic(machine->cpu_type,
+ &error_fatal);
/* By default A9,A15 and ARM1176 CPUs have EL3 enabled. This board
* does not currently support EL3 so the CPU EL3 property is disabled
@@ -767,7 +767,8 @@ static void sbsa_ref_init(MachineState *machine)
break;
}
- cpuobj = object_new(possible_cpus->cpus[n].type);
+ cpuobj = object_new_dynamic(possible_cpus->cpus[n].type,
+ &error_fatal);
object_property_set_int(cpuobj, "mp-affinity",
possible_cpus->cpus[n].arch_id, NULL);
@@ -205,7 +205,7 @@ static void versatile_init(MachineState *machine, int board_id)
exit(1);
}
- cpuobj = object_new(machine->cpu_type);
+ cpuobj = object_new_dynamic(machine->cpu_type, &error_fatal);
/* By default ARM1176 CPUs have EL3 enabled. This board does not
* currently support EL3 so the CPU EL3 property is disabled before
@@ -217,7 +217,7 @@ static void init_cpus(MachineState *ms, const char *cpu_type,
/* Create the actual CPUs */
for (n = 0; n < smp_cpus; n++) {
- Object *cpuobj = object_new(cpu_type);
+ Object *cpuobj = object_new_dynamic(cpu_type, &error_abort);
if (!secure) {
object_property_set_bool(cpuobj, "has_el3", false, NULL);
@@ -2125,7 +2125,8 @@ static void machvirt_init(MachineState *machine)
* we are about to deal with. Once this is done, get rid of
* the object.
*/
- cpuobj = object_new(possible_cpus->cpus[0].type);
+ cpuobj = object_new_dynamic(possible_cpus->cpus[0].type,
+ &error_fatal);
armcpu = ARM_CPU(cpuobj);
pa_bits = arm_pamax(armcpu);
@@ -2231,7 +2232,8 @@ static void machvirt_init(MachineState *machine)
break;
}
- cpuobj = object_new(possible_cpus->cpus[n].type);
+ cpuobj = object_new_dynamic(possible_cpus->cpus[n].type,
+ &error_fatal);
object_property_set_int(cpuobj, "mp-affinity",
possible_cpus->cpus[n].arch_id, NULL);
@@ -218,7 +218,8 @@ static void zynq_init(MachineState *machine)
}
for (n = 0; n < smp_cpus; n++) {
- Object *cpuobj = object_new(machine->cpu_type);
+ Object *cpuobj = object_new_dynamic(machine->cpu_type,
+ &error_fatal);
object_property_set_int(cpuobj, "midr", ZYNQ_BOARD_MIDR,
&error_fatal);
@@ -163,7 +163,7 @@ BusState *qbus_new(const char *typename, DeviceState *parent, const char *name)
{
BusState *bus;
- bus = BUS(object_new(typename));
+ bus = BUS(object_new_dynamic(typename, &error_abort));
qbus_init_internal(bus, parent, name);
return bus;
@@ -57,7 +57,7 @@ bool cpu_exists(int64_t id)
CPUState *cpu_create(const char *typename)
{
Error *err = NULL;
- CPUState *cpu = CPU(object_new(typename));
+ CPUState *cpu = CPU(object_new_dynamic(typename, &error_abort));
if (!qdev_realize(DEVICE(cpu), NULL, &err)) {
error_report_err(err);
object_unref(OBJECT(cpu));
@@ -146,7 +146,7 @@ bool qdev_set_parent_bus(DeviceState *dev, BusState *bus, Error **errp)
DeviceState *qdev_new(const char *name)
{
- return DEVICE(object_new(name));
+ return DEVICE(object_new_dynamic(name, &error_abort));
}
static QTAILQ_HEAD(, DeviceListener) device_listeners
@@ -55,7 +55,10 @@ static size_t pvh_start_addr;
static void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp)
{
- Object *cpu = object_new(MACHINE(x86ms)->cpu_type);
+ Object *cpu = object_new_dynamic(MACHINE(x86ms)->cpu_type, errp);
+ if (!cpu) {
+ return;
+ }
if (!object_property_set_uint(cpu, "apic-id", apic_id, errp)) {
goto out;
@@ -28,7 +28,7 @@ struct XenPVHx86State {
static DeviceState *xen_pvh_cpu_new(MachineState *ms,
int64_t apic_id)
{
- Object *cpu = object_new(ms->cpu_type);
+ Object *cpu = object_new_dynamic(ms->cpu_type, &error_abort);
object_property_add_child(OBJECT(ms), "cpu[*]", cpu);
object_property_set_uint(cpu, "apic-id", apic_id, &error_fatal);
@@ -377,7 +377,10 @@ Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp)
{
Object *obj;
- obj = object_new(type);
+ obj = object_new_dynamic(type, errp);
+ if (!obj) {
+ return NULL;
+ }
object_property_add_child(cpu, type, obj);
object_unref(obj);
object_property_set_link(obj, ICP_PROP_XICS, OBJECT(xi), &error_abort);
@@ -74,7 +74,8 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
}
for (int i = 0; i < s->num_vp; i++) {
- MIPSCPU *cpu = MIPS_CPU(object_new(s->cpu_type));
+ MIPSCPU *cpu = MIPS_CPU(object_new_dynamic(s->cpu_type,
+ &error_abort));
CPUMIPSState *env = &cpu->env;
object_property_set_bool(OBJECT(cpu), "big-endian", s->cpu_is_bigendian,
@@ -131,7 +131,10 @@ static void pnv_phb_realize(DeviceState *dev, Error **errp)
g_assert_not_reached();
}
- phb->backend = object_new(phb_typename);
+ phb->backend = object_new_dynamic(phb_typename, errp);
+ if (!phb->backend) {
+ return;
+ }
object_property_add_child(OBJECT(dev), "phb-backend", phb->backend);
/* Passthrough child device properties to the proxy device */
@@ -939,7 +939,7 @@ void ppce500_init(MachineState *machine)
PowerPCCPU *cpu;
CPUState *cs;
- cpu = POWERPC_CPU(object_new(machine->cpu_type));
+ cpu = POWERPC_CPU(object_new_dynamic(machine->cpu_type, &error_fatal));
env = &cpu->env;
cs = CPU(cpu);
@@ -1459,7 +1459,7 @@ static void pnv_chip_power8_instance_init(Object *obj)
chip8->num_phbs = pcc->num_phbs;
for (i = 0; i < chip8->num_phbs; i++) {
- Object *phb = object_new(TYPE_PNV_PHB);
+ Object *phb = object_new_dynamic(TYPE_PNV_PHB, &error_fatal);
/*
* We need the chip to parent the PHB to allow the DT
@@ -2376,7 +2376,7 @@ static void pnv_chip_core_realize(PnvChip *chip, Error **errp)
continue;
}
- pnv_core = PNV_CORE(object_new(typename));
+ pnv_core = PNV_CORE(object_new_dynamic(typename, &error_fatal));
snprintf(core_name, sizeof(core_name), "core[%d]", core_hwid);
object_property_add_child(OBJECT(chip), core_name, OBJECT(pnv_core));
@@ -361,7 +361,10 @@ static void pnv_core_realize(DeviceState *dev, Error **errp)
PowerPCCPU *cpu;
PnvCPUState *pnv_cpu;
- obj = object_new(typename);
+ obj = object_new_dynamic(typename, &local_err);
+ if (!obj) {
+ goto err;
+ }
cpu = POWERPC_CPU(obj);
pc->threads[i] = POWERPC_CPU(obj);
@@ -2693,7 +2693,7 @@ static void spapr_init_cpus(SpaprMachineState *spapr)
}
if (i < boot_cores_nr) {
- Object *core = object_new(type);
+ Object *core = object_new_dynamic(type, &error_fatal);
int nr_threads = smp_threads;
/* Handle the partially filled core for older machine types */
@@ -298,7 +298,10 @@ static PowerPCCPU *spapr_create_vcpu(SpaprCpuCore *sc, int i, Error **errp)
PowerPCCPU *cpu;
CPUPPCState *env;
- obj = object_new(scc->cpu_type);
+ obj = object_new_dynamic(scc->cpu_type, errp);
+ if (!obj) {
+ return NULL;
+ }
cs = CPU(obj);
cpu = POWERPC_CPU(obj);
@@ -554,7 +554,7 @@ static void drc_unrealize(DeviceState *d)
SpaprDrc *spapr_dr_connector_new(Object *owner, const char *type,
uint32_t id)
{
- SpaprDrc *drc = SPAPR_DR_CONNECTOR(object_new(type));
+ SpaprDrc *drc = SPAPR_DR_CONNECTOR(object_new_dynamic(type, &error_fatal));
g_autofree char *prop_name = NULL;
drc->id = id;
@@ -55,9 +55,15 @@ static Error *pv_mig_blocker;
static S390CPU *s390x_new_cpu(const char *typename, uint32_t core_id,
Error **errp)
{
- S390CPU *cpu = S390_CPU(object_new(typename));
+ Object *cpuobj = object_new_dynamic(typename, errp);
+ S390CPU *cpu = NULL;
S390CPU *ret = NULL;
+ if (!cpuobj) {
+ return NULL;
+ }
+
+ cpu = S390_CPU(cpuobj);
if (!object_property_set_int(OBJECT(cpu), "core-id", core_id, errp)) {
goto out;
}
@@ -277,7 +277,7 @@ static void leon3_generic_hw_init(MachineState *machine)
for (i = 0; i < machine->smp.cpus; i++) {
/* Init CPU */
- cpu = SPARC_CPU(object_new(machine->cpu_type));
+ cpu = SPARC_CPU(object_new_dynamic(machine->cpu_type, &error_fatal));
qdev_init_gpio_in_named(DEVICE(cpu), leon3_start_cpu, "start_cpu", 1);
qdev_init_gpio_in_named(DEVICE(cpu), leon3_set_pil_in, "pil", 1);
qdev_realize(DEVICE(cpu), NULL, &error_fatal);
@@ -802,7 +802,7 @@ static void cpu_devinit(const char *cpu_type, unsigned int id,
SPARCCPU *cpu;
CPUSPARCState *env;
- cpu = SPARC_CPU(object_new(cpu_type));
+ cpu = SPARC_CPU(object_new_dynamic(cpu_type, &error_fatal));
env = &cpu->env;
qemu_register_reset(sun4m_cpu_reset, cpu);
@@ -272,7 +272,7 @@ SPARCCPU *sparc64_cpu_devinit(const char *cpu_type, uint64_t prom_addr)
uint32_t stick_frequency = 100 * 1000000;
uint32_t hstick_frequency = 100 * 1000000;
- cpu = SPARC_CPU(object_new(cpu_type));
+ cpu = SPARC_CPU(object_new_dynamic(cpu_type, &error_fatal));
qdev_init_gpio_in_named(DEVICE(cpu), sparc64_cpu_set_ivec_irq,
"ivec-irq", IVEC_MAX);
qdev_realize(DEVICE(cpu), NULL, &error_fatal);
@@ -1550,7 +1550,11 @@ bool vfio_attach_device(char *name, VFIODevice *vbasedev,
if (!vbasedev->mdev) {
- hiod = HOST_IOMMU_DEVICE(object_new(ops->hiod_typename));
+ Object *obj = object_new_dynamic(ops->hiod_typename, errp);
+ if (!obj) {
+ return false;
+ }
+ hiod = HOST_IOMMU_DEVICE(obj);
vbasedev->hiod = hiod;
}
@@ -419,6 +419,7 @@ static VFIOContainer *vfio_create_container(int fd, VFIOGroup *group,
{
int iommu_type;
const char *vioc_name;
+ Object *obj;
VFIOContainer *container;
iommu_type = vfio_get_iommu_type(fd, errp);
@@ -432,7 +433,11 @@ static VFIOContainer *vfio_create_container(int fd, VFIOGroup *group,
vioc_name = vfio_get_iommu_class_name(iommu_type);
- container = VFIO_IOMMU_LEGACY(object_new(vioc_name));
+ obj = object_new_dynamic(vioc_name, errp);
+ if (!obj) {
+ return NULL;
+ }
+ container = VFIO_IOMMU_LEGACY(obj);
container->fd = fd;
container->iommu_type = iommu_type;
return container;
@@ -203,7 +203,10 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename,
if (object_class_is_abstract(klass)) {
object_class_property_iter_init(&iter, klass);
} else {
- obj = object_new(typename);
+ obj = object_new_dynamic(typename, errp);
+ if (!obj) {
+ return NULL;
+ }
object_property_iter_init(&iter, obj);
}
while ((prop = object_property_iter_next(&iter))) {
@@ -150,7 +150,10 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
}
}
- obj = object_new(object_class_get_name(oc));
+ obj = object_new_dynamic(object_class_get_name(oc), errp);
+ if (!obj) {
+ return NULL;
+ }
if (model->props) {
Visitor *visitor;
@@ -83,7 +83,10 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
return NULL;
}
- obj = object_new(object_class_get_name(oc));
+ obj = object_new_dynamic(object_class_get_name(oc), errp);
+ if (!obj) {
+ return NULL;
+ }
expansion_info = g_new0(CpuModelExpansionInfo, 1);
expansion_info->model = g_malloc0(sizeof(*expansion_info->model));
@@ -648,7 +648,7 @@ MIPSCPU *mips_cpu_create_with_clock(const char *cpu_type, Clock *cpu_refclk,
{
DeviceState *cpu;
- cpu = DEVICE(object_new(cpu_type));
+ cpu = DEVICE(object_new_dynamic(cpu_type, &error_abort));
qdev_connect_clock_in(cpu, "clk-in", cpu_refclk);
object_property_set_bool(OBJECT(cpu), "big-endian", is_big_endian,
&error_abort);
@@ -188,7 +188,10 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
return NULL;
}
- obj = object_new(object_class_get_name(oc));
+ obj = object_new_dynamic(object_class_get_name(oc), errp);
+ if (!obj) {
+ return NULL;
+ }
riscv_check_if_cpu_available(RISCV_CPU(obj), &local_err);
if (local_err != NULL) {
@@ -204,7 +204,7 @@ XtensaCPU *xtensa_cpu_create_with_clock(const char *cpu_type, Clock *cpu_refclk)
{
DeviceState *cpu;
- cpu = DEVICE(object_new(cpu_type));
+ cpu = DEVICE(object_new_dynamic(cpu_type, &error_abort));
qdev_connect_clock_in(cpu, "clk-in", cpu_refclk);
qdev_realize(cpu, NULL, &error_abort);
@@ -13,6 +13,7 @@
#include "qom/object.h"
#include "qemu/module.h"
+#include "qapi/error.h"
#define TYPE_TEST_IF "test-interface"
@@ -67,7 +68,7 @@ static const TypeInfo intermediate_impl_info = {
static void test_interface_impl(const char *type)
{
- Object *obj = object_new(type);
+ Object *obj = object_new_dynamic(type, &error_abort);
TestIf *iobj = TEST_IF(obj);
TestIfClass *ioc = TEST_IF_GET_CLASS(iobj);
@@ -1008,7 +1008,7 @@ static void machine_full_topo_class_init(ObjectClass *oc, void *data)
static void test_generic_valid(const void *opaque)
{
const char *machine_type = opaque;
- Object *obj = object_new(machine_type);
+ Object *obj = object_new_dynamic(machine_type, &error_abort);
MachineState *ms = MACHINE(obj);
MachineClass *mc = MACHINE_GET_CLASS(obj);
SMPTestData data = {};
@@ -1027,7 +1027,7 @@ static void test_generic_valid(const void *opaque)
static void test_generic_invalid(const void *opaque)
{
const char *machine_type = opaque;
- Object *obj = object_new(machine_type);
+ Object *obj = object_new_dynamic(machine_type, &error_abort);
MachineState *ms = MACHINE(obj);
MachineClass *mc = MACHINE_GET_CLASS(obj);
SMPTestData data = {};
@@ -1046,7 +1046,7 @@ static void test_generic_invalid(const void *opaque)
static void test_with_modules(const void *opaque)
{
const char *machine_type = opaque;
- Object *obj = object_new(machine_type);
+ Object *obj = object_new_dynamic(machine_type, &error_abort);
MachineState *ms = MACHINE(obj);
MachineClass *mc = MACHINE_GET_CLASS(obj);
SMPTestData data = {};
@@ -1096,7 +1096,7 @@ static void test_with_modules(const void *opaque)
static void test_with_dies(const void *opaque)
{
const char *machine_type = opaque;
- Object *obj = object_new(machine_type);
+ Object *obj = object_new_dynamic(machine_type, &error_abort);
MachineState *ms = MACHINE(obj);
MachineClass *mc = MACHINE_GET_CLASS(obj);
SMPTestData data = {};
@@ -1146,7 +1146,7 @@ static void test_with_dies(const void *opaque)
static void test_with_modules_dies(const void *opaque)
{
const char *machine_type = opaque;
- Object *obj = object_new(machine_type);
+ Object *obj = object_new_dynamic(machine_type, &error_abort);
MachineState *ms = MACHINE(obj);
MachineClass *mc = MACHINE_GET_CLASS(obj);
SMPTestData data = {};
@@ -1207,7 +1207,7 @@ static void test_with_modules_dies(const void *opaque)
static void test_with_clusters(const void *opaque)
{
const char *machine_type = opaque;
- Object *obj = object_new(machine_type);
+ Object *obj = object_new_dynamic(machine_type, &error_abort);
MachineState *ms = MACHINE(obj);
MachineClass *mc = MACHINE_GET_CLASS(obj);
SMPTestData data = {};
@@ -1257,7 +1257,7 @@ static void test_with_clusters(const void *opaque)
static void test_with_books(const void *opaque)
{
const char *machine_type = opaque;
- Object *obj = object_new(machine_type);
+ Object *obj = object_new_dynamic(machine_type, &error_abort);
MachineState *ms = MACHINE(obj);
MachineClass *mc = MACHINE_GET_CLASS(obj);
SMPTestData data = {};
@@ -1307,7 +1307,7 @@ static void test_with_books(const void *opaque)
static void test_with_drawers(const void *opaque)
{
const char *machine_type = opaque;
- Object *obj = object_new(machine_type);
+ Object *obj = object_new_dynamic(machine_type, &error_abort);
MachineState *ms = MACHINE(obj);
MachineClass *mc = MACHINE_GET_CLASS(obj);
SMPTestData data = {};
@@ -1357,7 +1357,7 @@ static void test_with_drawers(const void *opaque)
static void test_with_drawers_books(const void *opaque)
{
const char *machine_type = opaque;
- Object *obj = object_new(machine_type);
+ Object *obj = object_new_dynamic(machine_type, &error_abort);
MachineState *ms = MACHINE(obj);
MachineClass *mc = MACHINE_GET_CLASS(obj);
SMPTestData data = {};
@@ -1418,7 +1418,7 @@ static void test_with_drawers_books(const void *opaque)
static void test_full_topo(const void *opaque)
{
const char *machine_type = opaque;
- Object *obj = object_new(machine_type);
+ Object *obj = object_new_dynamic(machine_type, &error_abort);
MachineState *ms = MACHINE(obj);
MachineClass *mc = MACHINE_GET_CLASS(obj);
SMPTestData data = {};