From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4zzF-0007nX-4y for qemu-devel@nongnu.org; Wed, 09 Jul 2014 18:05:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4zz9-00005Q-0r for qemu-devel@nongnu.org; Wed, 09 Jul 2014 18:05:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56554) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4zz8-0008V9-Mz for qemu-devel@nongnu.org; Wed, 09 Jul 2014 18:05:06 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s69M55CY007268 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 9 Jul 2014 18:05:05 -0400 From: Eduardo Habkost Date: Wed, 9 Jul 2014 19:04:09 -0300 Message-Id: <1404943462-711-13-git-send-email-ehabkost@redhat.com> In-Reply-To: <1404943462-711-1-git-send-email-ehabkost@redhat.com> References: <1404943462-711-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [RFC 12/25] accel: Move accel init/allowed code to separate function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Eduardo Habkost --- hw/core/accel.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/core/accel.c b/hw/core/accel.c index 9aa853f..85e60eb 100644 --- a/hw/core/accel.c +++ b/hw/core/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; } -- 1.9.3