Skip to content

Commit

Permalink
accel: Move accel init/allowed code to separate function
Browse files Browse the repository at this point in the history
Reviewed-by: Paolo Bonzini <[email protected]>
Signed-off-by: Eduardo Habkost <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
ehabkost authored and bonzini committed Oct 4, 2014
1 parent 32592e1 commit d95c852
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions accel.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ static AccelClass *accel_find(const char *opt_name)
return ac;
}

static int accel_init(AccelClass *acc, MachineClass *mc)
{
int ret;
*(acc->allowed) = true;
ret = acc->init(mc);
if (ret < 0) {
*(acc->allowed) = false;
}
return ret;
}

int configure_accelerator(MachineClass *mc)
{
const char *p;
Expand Down Expand Up @@ -87,14 +98,12 @@ int configure_accelerator(MachineClass *mc)
acc->name);
continue;
}
*(acc->allowed) = true;
ret = acc->init(mc);
ret = accel_init(acc, mc);
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;
}
Expand Down

0 comments on commit d95c852

Please sign in to comment.