From patchwork Wed Jan 16 16:25:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [RFC,V1,03/12] block: Add bdrv_has_dedup. Date: Wed, 16 Jan 2013 06:25:09 -0000 From: =?utf-8?q?Beno=C3=AEt_Canet_=3Cbenoit=40irqsave=2Enet=3E?= X-Patchwork-Id: 212973 Message-Id: <1358353518-5421-4-git-send-email-benoit@irqsave.net> To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com --- block.c | 15 +++++++++++++++ include/block/block.h | 1 + 2 files changed, 16 insertions(+) diff --git a/block.c b/block.c index a245653..aee33e0 100644 --- a/block.c +++ b/block.c @@ -4327,6 +4327,21 @@ void bdrv_lock_medium(BlockDriverState *bs, bool locked) } } +/* Return true if the device has deduplication */ +bool bdrv_has_dedup(BlockDriverState *bs) +{ + BlockDriverInfo bdi; + int ret = 0; + + ret = bdrv_get_info((BlockDriverState *) bs, &bdi); + + if (ret < 0) { + return false; + } + + return bdi.has_dedup; +} + /* 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 2043560..e6f86ac 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -306,6 +306,7 @@ void bdrv_set_enable_write_cache(BlockDriverState *bs, bool wce); 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); void bdrv_eject(BlockDriverState *bs, bool eject_flag); const char *bdrv_get_format_name(BlockDriverState *bs); BlockDriverState *bdrv_find(const char *name);