summaryrefslogtreecommitdiff
path: root/accel.c
diff options
context:
space:
mode:
authorEduardo Habkost <ehabkost@redhat.com>2014-09-26 17:45:28 -0300
committerPaolo Bonzini <pbonzini@redhat.com>2014-10-04 08:59:16 +0200
commitd95c8527e9662a54a8f98c2ced35736604b1b253 (patch)
tree4708925069bc90da42a2fd0f4e300c4d26cb43f6 /accel.c
parent32592e112fc9da1e4f6b48896e6473c49043d5dd (diff)
downloadqemu-d95c8527e9662a54a8f98c2ced35736604b1b253.tar.gz
qemu-d95c8527e9662a54a8f98c2ced35736604b1b253.tar.bz2
qemu-d95c8527e9662a54a8f98c2ced35736604b1b253.zip
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>
Diffstat (limited to 'accel.c')
-rw-r--r--accel.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/accel.c b/accel.c
index 0f3fceeb7c..9241967cad 100644
--- a/accel.c
+++ b/accel.c
@@ -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;
}