diff options
author | Eduardo Habkost <ehabkost@redhat.com> | 2014-09-26 17:45:28 -0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-10-04 08:59:16 +0200 |
commit | d95c8527e9662a54a8f98c2ced35736604b1b253 (patch) | |
tree | 4708925069bc90da42a2fd0f4e300c4d26cb43f6 | |
parent | 32592e112fc9da1e4f6b48896e6473c49043d5dd (diff) |
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>
-rw-r--r-- | accel.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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; } |