From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvVrA-00065a-J1 for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:28:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvVr7-0007cN-VS for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:28:52 -0500 Received: from nodalink.pck.nerim.net ([62.212.105.220]:43401 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvVr7-0007cE-OP for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:28:49 -0500 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Wed, 16 Jan 2013 17:25:10 +0100 Message-Id: <1358353518-5421-5-git-send-email-benoit@irqsave.net> In-Reply-To: <1358353518-5421-1-git-send-email-benoit@irqsave.net> References: <1358353518-5421-1-git-send-email-benoit@irqsave.net> Subject: [Qemu-devel] [RFC V1 04/12] block: Add bdrv_is_dedup_running. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com --- block.c | 19 +++++++++++++++++++ include/block/block.h | 1 + 2 files changed, 20 insertions(+) diff --git a/block.c b/block.c index aee33e0..e83666a 100644 --- a/block.c +++ b/block.c @@ -4342,6 +4342,25 @@ bool bdrv_has_dedup(BlockDriverState *bs) return bdi.has_dedup; } +/* Return true if the device has deduplication and it's running */ +bool bdrv_is_dedup_running(BlockDriverState *bs) +{ + BlockDriverInfo bdi; + int ret = 0; + + ret = bdrv_get_info((BlockDriverState *) bs, &bdi); + + if (ret < 0) { + return false; + } + + if (!bdi.has_dedup) { + return false; + } + + return bdi.dedup_running; +} + /* needed for generic scsi interface */ int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf) diff --git a/include/block/block.h b/include/block/block.h index e6f86ac..f4e1d2a 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -307,6 +307,7 @@ int bdrv_is_inserted(BlockDriverState *bs); int bdrv_media_changed(BlockDriverState *bs); void bdrv_lock_medium(BlockDriverState *bs, bool locked); bool bdrv_has_dedup(BlockDriverState *bs); +bool bdrv_is_dedup_running(BlockDriverState *bs); void bdrv_eject(BlockDriverState *bs, bool eject_flag); const char *bdrv_get_format_name(BlockDriverState *bs); BlockDriverState *bdrv_find(const char *name); -- 1.7.10.4