From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtGT5-0007K8-V7 for qemu-devel@nongnu.org; Mon, 02 Nov 2015 09:52:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtGT0-0005Oc-Vb for qemu-devel@nongnu.org; Mon, 02 Nov 2015 09:52:19 -0500 From: Alberto Garcia Date: Mon, 2 Nov 2015 16:51:54 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: Subject: [Qemu-devel] [PATCH v4 2/4] block: Add blk_get_refcnt() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Stefan Hajnoczi This function returns the reference count of a given BlockBackend. For convenience, it returns 0 if the BlockBackend pointer is NULL. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz --- block/block-backend.c | 5 +++++ include/sysemu/block-backend.h | 1 + 2 files changed, 6 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index 1ac6982..6f9309f 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -189,6 +189,11 @@ static void drive_info_del(DriveInfo *dinfo) g_free(dinfo); } +int blk_get_refcnt(BlockBackend *blk) +{ + return blk ? blk->refcnt : 0; +} + /* * Increment @blk's reference count. * @blk must not be null. diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 40e315b..f4a68e2 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -65,6 +65,7 @@ BlockBackend *blk_new_with_bs(const char *name, Error **errp); BlockBackend *blk_new_open(const char *name, const char *filename, const char *reference, QDict *options, int flags, Error **errp); +int blk_get_refcnt(BlockBackend *blk); void blk_ref(BlockBackend *blk); void blk_unref(BlockBackend *blk); const char *blk_name(BlockBackend *blk); -- 2.6.1