handle some errors properly so avoid exit() during initialization. this fixes issue #237

This commit is contained in:
Nguyen Anh Quynh
2015-11-12 01:43:41 +08:00
parent 116d96692d
commit 2f297bdd3a
38 changed files with 203 additions and 125 deletions

View File

@ -9,7 +9,7 @@
#include "qom/object.h"
#include "uc_priv.h"
typedef void QEMUMachineInitFunc(struct uc_struct *uc, MachineState *ms);
typedef int QEMUMachineInitFunc(struct uc_struct *uc, MachineState *ms);
typedef void QEMUMachineResetFunc(void);
@ -54,7 +54,7 @@ struct MachineClass {
const char *family; /* NULL iff @name identifies a standalone machtype */
const char *name;
void (*init)(struct uc_struct *uc, MachineState *state);
int (*init)(struct uc_struct *uc, MachineState *state);
void (*reset)(void);
int max_cpus;

View File

@ -34,7 +34,7 @@ typedef struct PCMachineClass PCMachineClass;
#define PC_MACHINE_CLASS(klass) \
OBJECT_CLASS_CHECK(PCMachineClass, (klass), TYPE_PC_MACHINE)
void pc_cpus_init(struct uc_struct *uc, const char *cpu_model);
int pc_cpus_init(struct uc_struct *uc, const char *cpu_model);
FWCfgState *pc_memory_init(MachineState *machine,
MemoryRegion *system_memory,

View File

@ -32,7 +32,7 @@ typedef enum DeviceCategory {
typedef int (*qdev_initfn)(DeviceState *dev);
typedef int (*qdev_event)(DeviceState *dev);
typedef void (*qdev_resetfn)(DeviceState *dev);
typedef void (*DeviceRealize)(struct uc_struct *uc, DeviceState *dev, Error **errp);
typedef int (*DeviceRealize)(struct uc_struct *uc, DeviceState *dev, Error **errp);
typedef void (*DeviceUnrealize)(DeviceState *dev, Error **errp);
typedef void (*BusRealize)(BusState *bus, Error **errp);
typedef void (*BusUnrealize)(BusState *bus, Error **errp);

View File

@ -53,7 +53,8 @@ void qemu_event_wait(QemuEvent *ev);
void qemu_event_destroy(QemuEvent *ev);
struct uc_struct;
void qemu_thread_create(struct uc_struct *uc, QemuThread *thread, const char *name,
// return -1 on error, 0 on success
int qemu_thread_create(struct uc_struct *uc, QemuThread *thread, const char *name,
void *(*start_routine)(void *),
void *arg, int mode);
void *qemu_thread_join(QemuThread *thread);

View File

@ -582,7 +582,7 @@ void cpu_resume(CPUState *cpu);
*
* Initializes a vCPU.
*/
void qemu_init_vcpu(CPUState *cpu);
int qemu_init_vcpu(CPUState *cpu);
#define SSTEP_ENABLE 0x1 /* Enable simulated HW single stepping */
#define SSTEP_NOIRQ 0x2 /* Do not use IRQ while single stepping */

View File

@ -304,6 +304,11 @@ typedef void (ObjectPropertyAccessor)(struct uc_struct *uc, Object *obj,
void *opaque,
const char *name,
Error **errp);
typedef int (ObjectPropertySetAccessor)(struct uc_struct *uc, Object *obj,
struct Visitor *v,
void *opaque,
const char *name,
Error **errp);
/**
* ObjectPropertyResolve:
@ -342,7 +347,7 @@ typedef struct ObjectProperty
gchar *type;
gchar *description;
ObjectPropertyAccessor *get;
ObjectPropertyAccessor *set;
ObjectPropertySetAccessor *set;
ObjectPropertyResolve *resolve;
ObjectPropertyRelease *release;
void *opaque;
@ -799,7 +804,7 @@ void object_unref(struct uc_struct *uc, Object *obj);
ObjectProperty *object_property_add(Object *obj, const char *name,
const char *type,
ObjectPropertyAccessor *get,
ObjectPropertyAccessor *set,
ObjectPropertySetAccessor *set,
ObjectPropertyRelease *release,
void *opaque, Error **errp);
@ -1168,7 +1173,7 @@ void object_property_add_link(Object *obj, const char *name,
*/
void object_property_add_str(Object *obj, const char *name,
char *(*get)(struct uc_struct *uc, Object *, Error **),
void (*set)(struct uc_struct *uc, Object *, const char *, Error **),
int (*set)(struct uc_struct *uc, Object *, const char *, Error **),
Error **errp);
/**
@ -1184,7 +1189,7 @@ void object_property_add_str(Object *obj, const char *name,
*/
void object_property_add_bool(struct uc_struct *uc, Object *obj, const char *name,
bool (*get)(struct uc_struct *uc, Object *, Error **),
void (*set)(struct uc_struct *uc, Object *, bool, Error **),
int (*set)(struct uc_struct *uc, Object *, bool, Error **),
Error **errp);
/**

View File

@ -5,7 +5,7 @@ struct uc_struct;
/* cpus.c */
void qemu_init_cpu_loop(struct uc_struct*);
void resume_all_vcpus(struct uc_struct*);
int resume_all_vcpus(struct uc_struct*);
void pause_all_vcpus(struct uc_struct*);
void cpu_stop_current(struct uc_struct*);

View File

@ -17,7 +17,7 @@ typedef struct vm_change_state_entry VMChangeStateEntry;
#define VMRESET_SILENT false
#define VMRESET_REPORT true
void vm_start(struct uc_struct*);
int vm_start(struct uc_struct*);
void qemu_system_reset_request(struct uc_struct*);
void qemu_system_shutdown_request(void);