From: John Snow <jsnow@redhat.com>
To: qemu-block@nongnu.org, qemu-devel@nongnu.org
Cc: Max Reitz <mreitz@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Kevin Wolf <kwolf@redhat.com>, Eric Blake <eblake@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
John Snow <jsnow@redhat.com>
Subject: [Qemu-devel] [RFC PATCH 12/12] qemu-img: add bitmap clear
Date: Fri, 11 May 2018 21:25:37 -0400 [thread overview]
Message-ID: <20180512012537.22478-13-jsnow@redhat.com> (raw)
In-Reply-To: <20180512012537.22478-1-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
---
qemu-img-cmds.hx | 4 ++--
qemu-img.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
index d25f359f5a..7b6ec73488 100644
--- a/qemu-img-cmds.hx
+++ b/qemu-img-cmds.hx
@@ -23,9 +23,9 @@ STEXI
ETEXI
DEF("bitmap", img_bitmap,
- "bitmap dump [--object objectdef] [--image-opts] [-f fmt] [--output=ofmt] [-U] filename [bitmap]")
+ "bitmap <dump|clear> [--object objectdef] [--image-opts] [-f fmt] [--output=ofmt] [-U] filename [bitmap]")
STEXI
-@item bitmap dump [--object @var{objectdef}] [--image-opts] [-f @var{fmt}] [--output=@var{ofmt}] [-U] @var{filename} [@var{bitmap}]
+@item bitmap <dump|clear> [--object @var{objectdef}] [--image-opts] [-f @var{fmt}] [--output=@var{ofmt}] [-U] @var{filename} [@var{bitmap}]
ETEXI
DEF("check", img_check,
diff --git a/qemu-img.c b/qemu-img.c
index 1141216617..b5ab8a3837 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2967,7 +2967,22 @@ static void dump_bitmap_mapping(BitmapMapping *bm, OutputFormat output_format,
}
}
-/* img_bitmap subcommands: dump */
+static int do_bitmap_clear(BlockDriverState *bs, BdrvDirtyBitmap *bitmap)
+{
+ bool enabled = bdrv_dirty_bitmap_enabled(bitmap);
+
+ if (!enabled) {
+ bdrv_enable_dirty_bitmap(bitmap);
+ }
+ bdrv_clear_dirty_bitmap(bitmap, NULL);
+ if (!enabled) {
+ bdrv_disable_dirty_bitmap(bitmap);
+ }
+
+ return 0;
+}
+
+/* img_bitmap subcommands: dump, clear */
typedef struct BitmapOpts {
CommonOpts base;
@@ -3017,6 +3032,30 @@ static int bitmap_cmd_dump(BlockDriverState *bs, BitmapOpts *opts)
return 0;
}
+static int bitmap_cmd_clear(BlockDriverState *bs, BitmapOpts *opts)
+{
+ BdrvDirtyBitmap *bitmap = NULL;
+
+ if (opts->name) {
+ bitmap = bdrv_find_dirty_bitmap(bs, opts->name);
+ if (!bitmap) {
+ error_report("No bitmap named '%s' found", opts->name);
+ return -1;
+ }
+ if (do_bitmap_clear(bs, bitmap)) {
+ return -1;
+ }
+ } else {
+ while ((bitmap = bdrv_dirty_bitmap_next(bs, bitmap))) {
+ if (do_bitmap_clear(bs, bitmap)) {
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
+
static int img_bitmap(int argc, char **argv)
{
const char *cmd;
@@ -3029,12 +3068,15 @@ static int img_bitmap(int argc, char **argv)
int (* handler)(BlockDriverState *b, BitmapOpts *opts);
if (argc < 2) {
- error_report("Expected a bitmap subcommand: <dump>");
+ error_report("Expected a bitmap subcommand: <dump | clear>");
return EXIT_FAILURE;
}
cmd = argv[1];
if (strcmp(cmd, "dump") == 0) {
handler = bitmap_cmd_dump;
+ } else if (strcmp(cmd, "clear") == 0) {
+ flags |= BDRV_O_RDWR;
+ handler = bitmap_cmd_clear;
} else {
error_report("Unrecognized bitmap subcommand '%s'", cmd);
return EXIT_FAILURE;
--
2.14.3
next prev parent reply other threads:[~2018-05-12 1:25 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-12 1:25 [Qemu-devel] [RFC PATCH 00/12] qemu-img: add bitmap queries John Snow
2018-05-12 1:25 ` [Qemu-devel] [RFC PATCH 01/12] qcow2-bitmap: cache bm_list John Snow
2018-05-14 11:55 ` Vladimir Sementsov-Ogievskiy
2018-05-14 12:15 ` Vladimir Sementsov-Ogievskiy
2018-05-15 20:38 ` John Snow
2018-05-15 20:27 ` John Snow
2018-05-12 1:25 ` [Qemu-devel] [RFC PATCH 02/12] qcow2/dirty-bitmap: cache loaded bitmaps John Snow
2018-05-14 12:33 ` Vladimir Sementsov-Ogievskiy
2018-05-12 1:25 ` [Qemu-devel] [RFC PATCH 03/12] block/qcow2-bitmap: avoid adjusting bm->flags for RO bitmaps John Snow
2018-05-14 12:44 ` Vladimir Sementsov-Ogievskiy
2018-05-15 20:59 ` John Snow
2018-05-12 1:25 ` [Qemu-devel] [RFC PATCH 04/12] qcow2/dirty-bitmaps: load IN_USE bitmaps if disk is RO John Snow
2018-05-14 12:55 ` Vladimir Sementsov-Ogievskiy
2018-05-15 20:52 ` John Snow
2018-05-12 1:25 ` [Qemu-devel] [RFC PATCH 05/12] qcow2-bitmap: track bitmap type John Snow
2018-05-12 1:25 ` [Qemu-devel] [RFC PATCH 06/12] qapi: add bitmap info John Snow
2018-05-14 14:30 ` Vladimir Sementsov-Ogievskiy
2018-05-15 20:56 ` John Snow
2018-05-16 21:15 ` John Snow
2018-05-17 10:01 ` Vladimir Sementsov-Ogievskiy
2018-05-17 16:43 ` John Snow
2018-05-12 1:25 ` [Qemu-devel] [RFC PATCH 07/12] qcow2-bitmap: add basic bitmaps info John Snow
2018-05-14 15:12 ` Vladimir Sementsov-Ogievskiy
2018-05-15 21:03 ` John Snow
2018-05-16 21:17 ` John Snow
2018-05-17 10:03 ` Vladimir Sementsov-Ogievskiy
2018-05-12 1:25 ` [Qemu-devel] [RFC PATCH 08/12] qjson: allow caller to ask for arbitrary indent John Snow
2018-05-16 21:34 ` Eric Blake
2018-05-16 21:49 ` John Snow
2018-05-12 1:25 ` [Qemu-devel] [RFC PATCH 09/12] qapi/block-core: add BitmapMapping and BitmapEntry structs John Snow
2018-05-16 21:37 ` Eric Blake
2018-05-16 21:55 ` John Snow
2018-05-12 1:25 ` [Qemu-devel] [RFC PATCH 10/12] qemu-img: split off common chunk of map command John Snow
2018-05-12 1:25 ` [Qemu-devel] [RFC PATCH 11/12] qemu-img: add bitmap dump John Snow
2018-05-12 1:25 ` John Snow [this message]
2018-05-12 1:38 ` [Qemu-devel] [RFC PATCH 00/12] qemu-img: add bitmap queries no-reply
2018-05-14 11:32 ` Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180512012537.22478-13-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).