accel: Move accel init/allowed code to separate function

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Eduardo Habkost 2014-09-26 17:45:28 -03:00 committed by Paolo Bonzini
parent 32592e112f
commit d95c8527e9

15
accel.c
View File

@ -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;
@ -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;
}