From patchwork Fri May 29 11:07:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 477808 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9E520140E63 for ; Fri, 29 May 2015 21:09:54 +1000 (AEST) Received: from localhost ([::1]:35112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyIAi-0005qH-Lb for incoming@patchwork.ozlabs.org; Fri, 29 May 2015 07:09:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyI86-0001rd-Tj for qemu-devel@nongnu.org; Fri, 29 May 2015 07:07:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YyI82-0003iF-EX for qemu-devel@nongnu.org; Fri, 29 May 2015 07:07:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52656) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyI82-0003hw-5w for qemu-devel@nongnu.org; Fri, 29 May 2015 07:07:06 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id E78251BE357 for ; Fri, 29 May 2015 11:07:05 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4TB73iS027376 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 29 May 2015 07:07:04 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EFBDB30408A8; Fri, 29 May 2015 13:07:02 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 29 May 2015 13:07:02 +0200 Message-Id: <1432897622-26650-2-git-send-email-armbru@redhat.com> In-Reply-To: <1432897622-26650-1-git-send-email-armbru@redhat.com> References: <1432897622-26650-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: John Snow Subject: [Qemu-devel] [PULL 1/1] qapi: add dirty bitmap status 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 From: John Snow Bitmaps can be in a handful of different states with potentially more to come as we tool around with migration and persistence patches. Management applications may need to know why certain bitmaps are unavailable for various commands, e.g. busy in another operation, busy being migrated, etc. Right now, all we offer is BlockDirtyInfo's boolean member 'frozen'. Instead of adding more booleans, replace it by an enumeration member 'status' with values 'active' and 'frozen'. Then add new value 'disabled'. Incompatible change. Fine because the changed part hasn't been released so far. Suggested-by: Eric Blake Signed-off-by: John Snow Reviewed-by: Eric Blake [Commit message tweaked] Signed-off-by: Markus Armbruster --- block.c | 13 ++++++++++++- include/block/block.h | 1 + qapi/block-core.json | 23 +++++++++++++++++++++-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index f42d70e..2b9ceae 100644 --- a/block.c +++ b/block.c @@ -3116,6 +3116,17 @@ bool bdrv_dirty_bitmap_enabled(BdrvDirtyBitmap *bitmap) return !(bitmap->disabled || bitmap->successor); } +DirtyBitmapStatus bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap) +{ + if (bdrv_dirty_bitmap_frozen(bitmap)) { + return DIRTY_BITMAP_STATUS_FROZEN; + } else if (!bdrv_dirty_bitmap_enabled(bitmap)) { + return DIRTY_BITMAP_STATUS_DISABLED; + } else { + return DIRTY_BITMAP_STATUS_ACTIVE; + } +} + /** * Create a successor bitmap destined to replace this bitmap after an operation. * Requires that the bitmap is not frozen and has no successor. @@ -3256,7 +3267,7 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs) info->granularity = bdrv_dirty_bitmap_granularity(bm); info->has_name = !!bm->name; info->name = g_strdup(bm->name); - info->frozen = bdrv_dirty_bitmap_frozen(bm); + info->status = bdrv_dirty_bitmap_status(bm); entry->value = info; *plist = entry; plist = &entry->next; diff --git a/include/block/block.h b/include/block/block.h index c1c963e..f7680b6 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -476,6 +476,7 @@ uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs); uint32_t bdrv_dirty_bitmap_granularity(BdrvDirtyBitmap *bitmap); bool bdrv_dirty_bitmap_enabled(BdrvDirtyBitmap *bitmap); bool bdrv_dirty_bitmap_frozen(BdrvDirtyBitmap *bitmap); +DirtyBitmapStatus bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap); int bdrv_get_dirty(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, int64_t sector); void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap, int64_t cur_sector, int nr_sectors); diff --git a/qapi/block-core.json b/qapi/block-core.json index 863ffea..8411d4f 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -326,6 +326,25 @@ 'data': 'bool', '*offset': 'int' } } ## +# @DirtyBitmapStatus: +# +# An enumeration of possible states that a dirty bitmap can report to the user. +# +# @frozen: The bitmap is currently in-use by a backup operation or block job, +# and is immutable. +# +# @disabled: The bitmap is currently in-use by an internal operation and is +# read-only. It can still be deleted. +# +# @active: The bitmap is actively monitoring for new writes, and can be cleared, +# deleted, or used for backup operations. +# +# Since: 2.4 +## +{ 'enum': 'DirtyBitmapStatus', + 'data': ['active', 'disabled', 'frozen'] } + +## # @BlockDirtyInfo: # # Block dirty bitmap information. @@ -336,13 +355,13 @@ # # @granularity: granularity of the dirty bitmap in bytes (since 1.4) # -# @frozen: whether the dirty bitmap is frozen (Since 2.4) +# @status: current status of the dirty bitmap (since 2.4) # # Since: 1.3 ## { 'struct': 'BlockDirtyInfo', 'data': {'*name': 'str', 'count': 'int', 'granularity': 'uint32', - 'frozen': 'bool'} } + 'status': 'DirtyBitmapStatus'} } ## # @BlockInfo: