handle some errors properly so avoid exit() during initialization. this fixes issue #237
This commit is contained in:
@@ -17,10 +17,12 @@
|
||||
#include "exec/address-spaces.h"
|
||||
|
||||
|
||||
static void tosa_init(struct uc_struct *uc, MachineState *machine)
|
||||
static int tosa_init(struct uc_struct *uc, MachineState *machine)
|
||||
{
|
||||
//cpu_arm_init(uc, "pxa255");
|
||||
cpu_arm_init(uc, "cortex-a15"); // FIXME
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tosa_machine_init(struct uc_struct *uc)
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "exec/address-spaces.h"
|
||||
|
||||
|
||||
static void machvirt_init(struct uc_struct *uc, MachineState *machine)
|
||||
static int machvirt_init(struct uc_struct *uc, MachineState *machine)
|
||||
{
|
||||
const char *cpu_model = machine->cpu_model;
|
||||
int n;
|
||||
@@ -51,12 +51,14 @@ static void machvirt_init(struct uc_struct *uc, MachineState *machine)
|
||||
|
||||
if (!oc) {
|
||||
fprintf(stderr, "Unable to find CPU definition\n");
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cpuobj = object_new(uc, object_class_get_name(oc));
|
||||
object_property_set_bool(uc, cpuobj, true, "realized", NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void machvirt_machine_init(struct uc_struct *uc)
|
||||
|
||||
@@ -155,7 +155,7 @@ static bool device_get_realized(struct uc_struct *uc, Object *obj, Error **errp)
|
||||
return dev->realized;
|
||||
}
|
||||
|
||||
static void device_set_realized(struct uc_struct *uc, Object *obj, bool value, Error **errp)
|
||||
static int device_set_realized(struct uc_struct *uc, Object *obj, bool value, Error **errp)
|
||||
{
|
||||
DeviceState *dev = DEVICE(uc, obj);
|
||||
DeviceClass *dc = DEVICE_GET_CLASS(uc, dev);
|
||||
@@ -164,7 +164,7 @@ static void device_set_realized(struct uc_struct *uc, Object *obj, bool value, E
|
||||
|
||||
if (dev->hotplugged && !dc->hotpluggable) {
|
||||
error_set(errp, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj));
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (value && !dev->realized) {
|
||||
@@ -181,7 +181,8 @@ static void device_set_realized(struct uc_struct *uc, Object *obj, bool value, E
|
||||
#endif
|
||||
|
||||
if (dc->realize) {
|
||||
dc->realize(uc, dev, &local_err);
|
||||
if (dc->realize(uc, dev, &local_err))
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (local_err != NULL) {
|
||||
@@ -222,7 +223,7 @@ static void device_set_realized(struct uc_struct *uc, Object *obj, bool value, E
|
||||
}
|
||||
|
||||
dev->realized = value;
|
||||
return;
|
||||
return 0;
|
||||
|
||||
child_realize_fail:
|
||||
QLIST_FOREACH(bus, &dev->child_bus, sibling) {
|
||||
@@ -237,7 +238,7 @@ post_realize_fail:
|
||||
|
||||
fail:
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void device_initfn(struct uc_struct *uc, Object *obj, void *opaque)
|
||||
|
||||
@@ -104,7 +104,7 @@ static X86CPU *pc_new_cpu(struct uc_struct *uc, const char *cpu_model, int64_t a
|
||||
}
|
||||
|
||||
object_property_set_int(uc, OBJECT(cpu), apic_id, "apic-id", &local_err);
|
||||
object_property_set_bool(uc, OBJECT(cpu), true, "realized", &local_err);
|
||||
object_property_set_bool(uc, OBJECT(cpu), true, "realized", &local_err); // qq
|
||||
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
@@ -114,7 +114,7 @@ static X86CPU *pc_new_cpu(struct uc_struct *uc, const char *cpu_model, int64_t a
|
||||
return cpu;
|
||||
}
|
||||
|
||||
void pc_cpus_init(struct uc_struct *uc, const char *cpu_model)
|
||||
int pc_cpus_init(struct uc_struct *uc, const char *cpu_model)
|
||||
{
|
||||
int i;
|
||||
Error *error = NULL;
|
||||
@@ -129,13 +129,15 @@ void pc_cpus_init(struct uc_struct *uc, const char *cpu_model)
|
||||
}
|
||||
|
||||
for (i = 0; i < smp_cpus; i++) {
|
||||
uc->cpu = pc_new_cpu(uc, cpu_model, x86_cpu_apic_id_from_index(i), &error);
|
||||
uc->cpu = pc_new_cpu(uc, cpu_model, x86_cpu_apic_id_from_index(i), &error); // qq
|
||||
if (error) {
|
||||
//error_report("%s", error_get_pretty(error));
|
||||
error_free(error);
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pc_machine_initfn(struct uc_struct *uc, Object *obj, void *opaque)
|
||||
|
||||
@@ -36,14 +36,14 @@
|
||||
#define GIGABYTE_ALIGN true
|
||||
|
||||
/* PC hardware initialisation */
|
||||
static void pc_init1(struct uc_struct *uc, MachineState *machine)
|
||||
static int pc_init1(struct uc_struct *uc, MachineState *machine)
|
||||
{
|
||||
pc_cpus_init(uc, machine->cpu_model);
|
||||
return pc_cpus_init(uc, machine->cpu_model);
|
||||
}
|
||||
|
||||
static void pc_init_pci(struct uc_struct *uc, MachineState *machine)
|
||||
static int pc_init_pci(struct uc_struct *uc, MachineState *machine)
|
||||
{
|
||||
pc_init1(uc, machine);
|
||||
return pc_init1(uc, machine);
|
||||
}
|
||||
|
||||
#define PC_I440FX_MACHINE_OPTIONS \
|
||||
|
||||
@@ -186,8 +186,9 @@ static void apic_post_load(APICCommonState *s)
|
||||
}
|
||||
}
|
||||
|
||||
static void apic_realize(struct uc_struct *uc, DeviceState *dev, Error **errp)
|
||||
static int apic_realize(struct uc_struct *uc, DeviceState *dev, Error **errp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void apic_class_init(struct uc_struct *uc, ObjectClass *klass, void *data)
|
||||
|
||||
@@ -196,7 +196,7 @@ static void apic_reset_common(struct uc_struct *uc, DeviceState *dev)
|
||||
}
|
||||
}
|
||||
|
||||
static void apic_common_realize(struct uc_struct *uc, DeviceState *dev, Error **errp)
|
||||
static int apic_common_realize(struct uc_struct *uc, DeviceState *dev, Error **errp)
|
||||
{
|
||||
APICCommonState *s = APIC_COMMON(uc, dev);
|
||||
APICCommonClass *info;
|
||||
@@ -204,7 +204,7 @@ static void apic_common_realize(struct uc_struct *uc, DeviceState *dev, Error **
|
||||
if (uc->apic_no >= MAX_APICS) {
|
||||
error_setg(errp, "%s initialization failed.",
|
||||
object_get_typename(OBJECT(dev)));
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
s->idx = uc->apic_no++;
|
||||
|
||||
@@ -225,6 +225,8 @@ static void apic_common_realize(struct uc_struct *uc, DeviceState *dev, Error **
|
||||
if (uc->apic_report_tpr_access && info->enable_tpr_reporting) {
|
||||
info->enable_tpr_reporting(s, true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void apic_common_class_init(struct uc_struct *uc, ObjectClass *klass, void *data)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
|
||||
/* Board init. */
|
||||
static void dummy_m68k_init(struct uc_struct *uc, MachineState *machine)
|
||||
static int dummy_m68k_init(struct uc_struct *uc, MachineState *machine)
|
||||
{
|
||||
const char *cpu_model = machine->cpu_model;
|
||||
CPUM68KState *env;
|
||||
@@ -27,12 +27,14 @@ static void dummy_m68k_init(struct uc_struct *uc, MachineState *machine)
|
||||
env = cpu_init(uc, cpu_model);
|
||||
if (!env) {
|
||||
fprintf(stderr, "Unable to find m68k CPU definition\n");
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Initialize CPU registers. */
|
||||
env->vbr = 0;
|
||||
env->pc = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dummy_m68k_machine_init(struct uc_struct *uc)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "exec/address-spaces.h"
|
||||
|
||||
|
||||
static void mips_r4k_init(struct uc_struct *uc, MachineState *machine)
|
||||
static int mips_r4k_init(struct uc_struct *uc, MachineState *machine)
|
||||
{
|
||||
const char *cpu_model = machine->cpu_model;
|
||||
MIPSCPU *cpu;
|
||||
@@ -38,8 +38,10 @@ static void mips_r4k_init(struct uc_struct *uc, MachineState *machine)
|
||||
cpu = cpu_mips_init(uc, cpu_model);
|
||||
if (cpu == NULL) {
|
||||
fprintf(stderr, "Unable to find CPU definition\n");
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mips_machine_init(struct uc_struct *uc)
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "exec/address-spaces.h"
|
||||
|
||||
|
||||
static void leon3_generic_hw_init(struct uc_struct *uc, MachineState *machine)
|
||||
static int leon3_generic_hw_init(struct uc_struct *uc, MachineState *machine)
|
||||
{
|
||||
const char *cpu_model = machine->cpu_model;
|
||||
SPARCCPU *cpu;
|
||||
@@ -46,10 +46,12 @@ static void leon3_generic_hw_init(struct uc_struct *uc, MachineState *machine)
|
||||
cpu = cpu_sparc_init(uc, cpu_model);
|
||||
if (cpu == NULL) {
|
||||
fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cpu_sparc_set_id(&cpu->env, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void leon3_machine_init(struct uc_struct *uc)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
|
||||
/* Sun4u hardware initialisation */
|
||||
static void sun4u_init(struct uc_struct *uc, MachineState *machine)
|
||||
static int sun4u_init(struct uc_struct *uc, MachineState *machine)
|
||||
{
|
||||
const char *cpu_model = machine->cpu_model;
|
||||
SPARCCPU *cpu;
|
||||
@@ -41,8 +41,10 @@ static void sun4u_init(struct uc_struct *uc, MachineState *machine)
|
||||
cpu = cpu_sparc_init(uc, cpu_model);
|
||||
if (cpu == NULL) {
|
||||
fprintf(stderr, "Unable to find Sparc CPU definition\n");
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sun4u_machine_init(struct uc_struct *uc)
|
||||
|
||||
Reference in New Issue
Block a user