From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOMH3-0007LM-MW for qemu-devel@nongnu.org; Mon, 01 Sep 2014 03:43:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XOMGx-0003XF-Gh for qemu-devel@nongnu.org; Mon, 01 Sep 2014 03:43:37 -0400 Received: from mail-pd0-x231.google.com ([2607:f8b0:400e:c02::231]:46299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOMGx-0003X1-9B for qemu-devel@nongnu.org; Mon, 01 Sep 2014 03:43:31 -0400 Received: by mail-pd0-f177.google.com with SMTP id r10so5482826pdi.8 for ; Mon, 01 Sep 2014 00:43:30 -0700 (PDT) From: Liu Yuan Date: Mon, 1 Sep 2014 15:43:08 +0800 Message-Id: <1409557394-11853-3-git-send-email-namei.unix@gmail.com> In-Reply-To: <1409557394-11853-1-git-send-email-namei.unix@gmail.com> References: <1409557394-11853-1-git-send-email-namei.unix@gmail.com> Subject: [Qemu-devel] [PATCH 2/8] block: add driver operation callbacks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Benoit Canet , Stefan Hajnoczi Driver operations are defined as callbacks passed from block upper drivers to lower drivers and are supposed to be called by lower drivers. Requests handling(queuing, submitting, etc.) are done in protocol tier in the block layer and connection states are also maintained down there. Driver operations are supposed to notify the upper tier (such as quorum) of the states changes. For now only two operation are added: driver_disconnect: called when connection is off driver_reconnect: called when connection is on after disconnection Which are used to notify upper tier of the connection state. Cc: Eric Blake Cc: Benoit Canet Cc: Kevin Wolf Cc: Stefan Hajnoczi Signed-off-by: Liu Yuan --- block.c | 7 +++++++ include/block/block.h | 7 +++++++ include/block/block_int.h | 3 +++ 3 files changed, 17 insertions(+) diff --git a/block.c b/block.c index c12b8de..22eb3e4 100644 --- a/block.c +++ b/block.c @@ -2152,6 +2152,13 @@ void bdrv_set_dev_ops(BlockDriverState *bs, const BlockDevOps *ops, bs->dev_opaque = opaque; } +void bdrv_set_drv_ops(BlockDriverState *bs, const BlockDrvOps *ops, + void *opaque) +{ + bs->drv_ops = ops; + bs->drv_opaque = opaque; +} + static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load) { if (bs->dev_ops && bs->dev_ops->change_media_cb) { diff --git a/include/block/block.h b/include/block/block.h index 8f4ad16..a61eaf0 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -82,6 +82,11 @@ typedef struct BlockDevOps { void (*resize_cb)(void *opaque); } BlockDevOps; +typedef struct BlockDrvOps { + void (*driver_reconnect)(BlockDriverState *bs); + void (*driver_disconnect)(BlockDriverState *bs); +} BlockDrvOps; + typedef enum { BDRV_REQ_COPY_ON_READ = 0x1, BDRV_REQ_ZERO_WRITE = 0x2, @@ -234,6 +239,8 @@ void bdrv_detach_dev(BlockDriverState *bs, void *dev); void *bdrv_get_attached_dev(BlockDriverState *bs); void bdrv_set_dev_ops(BlockDriverState *bs, const BlockDevOps *ops, void *opaque); +void bdrv_set_drv_ops(BlockDriverState *bs, const BlockDrvOps *ops, + void *opaque); void bdrv_dev_eject_request(BlockDriverState *bs, bool force); bool bdrv_dev_has_removable_media(BlockDriverState *bs); bool bdrv_dev_is_tray_open(BlockDriverState *bs); diff --git a/include/block/block_int.h b/include/block/block_int.h index 2334895..9fdec7f 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -319,6 +319,9 @@ struct BlockDriverState { const BlockDevOps *dev_ops; void *dev_opaque; + const BlockDrvOps *drv_ops; + void *drv_opaque; + AioContext *aio_context; /* event loop used for fd handlers, timers, etc */ char filename[1024]; -- 1.9.1