* THE SOFTWARE.
*/
+#include "qemu/osdep.h"
#include "sysemu/accel.h"
+#include "hw/boards.h"
#include "qemu-common.h"
#include "sysemu/arch_init.h"
#include "sysemu/sysemu.h"
#include "sysemu/qtest.h"
#include "hw/xen/xen.h"
#include "qom/object.h"
+#include "hw/boards.h"
int tcg_tb_size;
static bool tcg_allowed = true;
-static int tcg_init(MachineClass *mc)
+static int tcg_init(MachineState *ms)
{
tcg_exec_init(tcg_tb_size * 1024 * 1024);
return 0;
return ac;
}
-int configure_accelerator(MachineClass *mc)
+static int accel_init_machine(AccelClass *acc, MachineState *ms)
+{
+ ObjectClass *oc = OBJECT_CLASS(acc);
+ const char *cname = object_class_get_name(oc);
+ AccelState *accel = ACCEL(object_new(cname));
+ int ret;
+ ms->accelerator = accel;
+ *(acc->allowed) = true;
+ ret = acc->init_machine(ms);
+ if (ret < 0) {
+ ms->accelerator = NULL;
+ *(acc->allowed) = false;
+ object_unref(OBJECT(accel));
+ }
+ return ret;
+}
+
+int configure_accelerator(MachineState *ms)
{
const char *p;
char buf[10];
acc->name);
continue;
}
- *(acc->allowed) = true;
- ret = acc->init(mc);
+ ret = accel_init_machine(acc, ms);
if (ret < 0) {
init_failed = true;
fprintf(stderr, "failed to initialize %s: %s\n",
acc->name,
strerror(-ret));
- *(acc->allowed) = false;
} else {
accel_initialised = true;
}
{
AccelClass *ac = ACCEL_CLASS(oc);
ac->name = "tcg";
- ac->available = tcg_available;
- ac->init = tcg_init;
+ ac->init_machine = tcg_init;
ac->allowed = &tcg_allowed;
}