From patchwork Wed Jul 9 22:04:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 368355 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D1AF8140114 for ; Thu, 10 Jul 2014 08:14:05 +1000 (EST) Received: from localhost ([::1]:34115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X507n-0003bS-VX for incoming@patchwork.ozlabs.org; Wed, 09 Jul 2014 18:14:03 -0400 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 Received: from localhost (ovpn-113-143.phx2.redhat.com [10.3.113.143]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s69M54UX014371; Wed, 9 Jul 2014 18:05:04 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 12/25] accel: Move accel init/allowed code to separate function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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; }