From patchwork Thu Sep 12 09:15:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 274479 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5B8DE2C039D for ; Thu, 12 Sep 2013 19:19:33 +1000 (EST) Received: from localhost ([::1]:40470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK33j-0004p8-9Z for incoming@patchwork.ozlabs.org; Thu, 12 Sep 2013 05:19:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK30B-0007Mr-Jm for qemu-devel@nongnu.org; Thu, 12 Sep 2013 05:16:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VK301-0003m7-22 for qemu-devel@nongnu.org; Thu, 12 Sep 2013 05:15:51 -0400 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:49291) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK300-0003lc-7Q for qemu-devel@nongnu.org; Thu, 12 Sep 2013 05:15:40 -0400 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Sep 2013 14:36:56 +0530 Received: from d28dlp03.in.ibm.com (9.184.220.128) by e28smtp04.in.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 12 Sep 2013 14:36:54 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id A7B861258059 for ; Thu, 12 Sep 2013 14:45:34 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8C9HM3b31523038 for ; Thu, 12 Sep 2013 14:47:23 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r8C9FMss008081 for ; Thu, 12 Sep 2013 14:45:22 +0530 Received: from RH64wenchao ([9.181.129.59]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r8C9FDVj007408; Thu, 12 Sep 2013 14:45:21 +0530 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Thu, 12 Sep 2013 17:15:09 +0800 Message-Id: <1378977312-17696-6-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1378977312-17696-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1378977312-17696-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13091209-5564-0000-0000-000009AF1458 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.4 Cc: kwolf@redhat.com, pbonzini@redhat.com, anthony@codemonkey.ws, stefanha@redhat.com, Wenchao Xia Subject: [Qemu-devel] [RFC PATCH 5/8] block: add a callback layer for common functions 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 This structure can hold some call back functions, such as event emit, error printf. By using call back, block layer can be decoupled with other components. Signed-off-by: Wenchao Xia --- block.c | 7 +++++++ include/block/block.h | 11 +++++++++++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 07385bf..576b86e 100644 --- a/block.c +++ b/block.c @@ -55,6 +55,13 @@ typedef enum { BDRV_REQ_ZERO_WRITE = 0x2, } BdrvRequestFlags; +BDRVCommonHooks bdrv_common_hooks; + +void bdrv_set_common_hooks(BDRVCommonHooks *hooks) +{ + bdrv_common_hooks = *hooks; +} + static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load); static BlockDriverAIOCB *bdrv_aio_readv_em(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, diff --git a/include/block/block.h b/include/block/block.h index 728ec1a..7913f48 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -119,6 +119,17 @@ typedef struct BDRVReopenState { void *opaque; } BDRVReopenState; +/* + * Now all block layer use same hooks, If needed it can be changed as per + * bds. + */ +typedef struct BDRVCommonHooks { + void (*hooks)(void *); +} BDRVCommonHooks; + +extern BDRVCommonHooks bdrv_common_hooks; + +void bdrv_set_common_hooks(BDRVCommonHooks *hooks); void bdrv_iostatus_enable(BlockDriverState *bs); void bdrv_iostatus_reset(BlockDriverState *bs);