From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:33306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rguu2-0006Gy-4W for qemu-devel@nongnu.org; Sat, 31 Dec 2011 04:06:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rguu0-0005JQ-GD for qemu-devel@nongnu.org; Sat, 31 Dec 2011 04:06:58 -0500 Received: from e28smtp02.in.ibm.com ([122.248.162.2]:55285) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rgutz-0005JH-Sr for qemu-devel@nongnu.org; Sat, 31 Dec 2011 04:06:56 -0500 Received: from /spool/local by e28smtp02.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 31 Dec 2011 14:36:48 +0530 Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pBV96i884444278 for ; Sat, 31 Dec 2011 14:36:44 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pBV96hll020455 for ; Sat, 31 Dec 2011 14:36:43 +0530 From: Dong Xu Wang Date: Sat, 31 Dec 2011 17:06:27 +0800 Message-Id: <1325322388-4825-1-git-send-email-wdongxu@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 1/2] block: add dirty flag status to qemu-img List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Dong Xu Wang , Stefan Hajnoczi From: Dong Xu Wang Some block drivers can verify their image files are clean or not. So we can show it while using "qemu-img info" CC: Kevin Wolf CC: Stefan Hajnoczi Signed-off-by: Dong Xu Wang --- Previous discussion can be found at: http://patchwork.ozlabs.org/patch/128730/ block.c | 14 ++++++++++++++ block.h | 2 ++ block_int.h | 1 + qemu-img.c | 3 +++ 4 files changed, 20 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 3f072f6..24fd774 100644 --- a/block.c +++ b/block.c @@ -186,6 +186,20 @@ static void bdrv_io_limits_intercept(BlockDriverState *bs, qemu_co_queue_next(&bs->throttled_reqs); } +/* check if the image is dirty */ +int bdrv_is_dirty(BlockDriverState *bs) +{ + BlockDriver *drv = bs->drv; + + if (!drv) { + return 0; + } + if (!drv->bdrv_is_dirty) { + return 0; + } + return drv->bdrv_is_dirty(bs); +} + /* check if the path starts with ":" */ static int path_has_protocol(const char *path) { diff --git a/block.h b/block.h index 3bd4398..e3f3b55 100644 --- a/block.h +++ b/block.h @@ -104,6 +104,8 @@ void bdrv_io_limits_enable(BlockDriverState *bs); void bdrv_io_limits_disable(BlockDriverState *bs); bool bdrv_io_limits_enabled(BlockDriverState *bs); +int bdrv_is_dirty(BlockDriverState *bs); + void bdrv_init(void); void bdrv_init_with_whitelist(void); BlockDriver *bdrv_find_protocol(const char *filename); diff --git a/block_int.h b/block_int.h index 311bd2a..46afffb 100644 --- a/block_int.h +++ b/block_int.h @@ -84,6 +84,7 @@ struct BlockDriver { int (*bdrv_create)(const char *filename, QEMUOptionParameter *options); int (*bdrv_set_key)(BlockDriverState *bs, const char *key); int (*bdrv_make_empty)(BlockDriverState *bs); + int (*bdrv_is_dirty)(BlockDriverState *bs); /* aio */ BlockDriverAIOCB *(*bdrv_aio_readv)(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, diff --git a/qemu-img.c b/qemu-img.c index 01cc0d3..a79c274 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1153,6 +1153,9 @@ static int img_info(int argc, char **argv) if (bdrv_is_encrypted(bs)) { printf("encrypted: yes\n"); } + if (bdrv_is_dirty(bs)) { + printf("dirty,need check: yes\n"); + } if (bdrv_get_info(bs, &bdi) >= 0) { if (bdi.cluster_size != 0) { printf("cluster_size: %d\n", bdi.cluster_size); -- 1.7.5.4