From patchwork Wed Jan 16 16:25:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Canet?= X-Patchwork-Id: 212973 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BB9BE2C0087 for ; Thu, 17 Jan 2013 05:53:32 +1100 (EST) Received: from localhost ([::1]:40283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvY78-0004jS-TL for incoming@patchwork.ozlabs.org; Wed, 16 Jan 2013 13:53:30 -0500 Received: from eggs.gnu.org ([208.118.235.92]:42080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvVr8-00060y-UQ for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:28:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvVr6-0007c1-4t for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:28:50 -0500 Received: from nodalink.pck.nerim.net ([62.212.105.220]:43400 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvVr5-0007bu-Tt for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:28:48 -0500 Received: by paradis.irqsave.net (Postfix, from userid 1002) id 7C85587432B; Wed, 16 Jan 2013 18:00:24 +0100 (CET) Received: from localhost.localdomain (unknown [192.168.77.1]) by paradis.irqsave.net (Postfix) with ESMTP id 01C0A874352; Wed, 16 Jan 2013 17:56:24 +0100 (CET) From: =?UTF-8?q?Beno=C3=AEt=20Canet?= To: qemu-devel@nongnu.org Date: Wed, 16 Jan 2013 17:25:09 +0100 Message-Id: <1358353518-5421-4-git-send-email-benoit@irqsave.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1358353518-5421-1-git-send-email-benoit@irqsave.net> References: <1358353518-5421-1-git-send-email-benoit@irqsave.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 62.212.105.220 Cc: kwolf@redhat.com, pbonzini@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com Subject: [Qemu-devel] [RFC V1 03/12] block: Add bdrv_has_dedup. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org --- 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);