accel: pass object to accel_init_machine
We will have to set QOM properties before accel_init_machine, based on the options provided to -accel. Construct the object outside it so that it will be possible to iterate on properties between object_new_with_class and accel_init_machine. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
3c75e12ea6
commit
fc5cf82621
@ -46,9 +46,9 @@ AccelClass *accel_find(const char *opt_name)
|
||||
return ac;
|
||||
}
|
||||
|
||||
int accel_init_machine(AccelClass *acc, MachineState *ms)
|
||||
int accel_init_machine(AccelState *accel, MachineState *ms)
|
||||
{
|
||||
AccelState *accel = ACCEL(object_new_with_class(OBJECT_CLASS(acc)));
|
||||
AccelClass *acc = ACCEL_GET_CLASS(accel);
|
||||
int ret;
|
||||
ms->accelerator = accel;
|
||||
*(acc->allowed) = true;
|
||||
|
@ -67,7 +67,7 @@ typedef struct AccelClass {
|
||||
extern unsigned long tcg_tb_size;
|
||||
|
||||
AccelClass *accel_find(const char *opt_name);
|
||||
int accel_init_machine(AccelClass *acc, MachineState *ms);
|
||||
int accel_init_machine(AccelState *accel, MachineState *ms);
|
||||
|
||||
/* Called just before os_setup_post (ie just before drop OS privs) */
|
||||
void accel_setup_post(MachineState *ms);
|
||||
|
4
vl.c
4
vl.c
@ -2716,6 +2716,7 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
|
||||
bool *p_init_failed = opaque;
|
||||
const char *acc = qemu_opt_get(opts, "accel");
|
||||
AccelClass *ac = accel_find(acc);
|
||||
AccelState *accel;
|
||||
int ret;
|
||||
|
||||
if (!ac) {
|
||||
@ -2723,7 +2724,8 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
|
||||
error_report("invalid accelerator %s", acc);
|
||||
return 0;
|
||||
}
|
||||
ret = accel_init_machine(ac, current_machine);
|
||||
accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac)));
|
||||
ret = accel_init_machine(accel, current_machine);
|
||||
if (ret < 0) {
|
||||
*p_init_failed = true;
|
||||
error_report("failed to initialize %s: %s",
|
||||
|
Loading…
Reference in New Issue
Block a user