From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 From: Wenchao Xia Date: Thu, 12 Sep 2013 17:15:09 +0800 Message-Id: <1378977312-17696-6-git-send-email-xiawenc@linux.vnet.ibm.com> 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> Subject: [Qemu-devel] [RFC PATCH 5/8] block: add a callback layer for common functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, anthony@codemonkey.ws, stefanha@redhat.com, Wenchao Xia 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); -- 1.7.1