From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: jsnow@redhat.com, qemu-block@nongnu.org, vsementsov@virtuozzo.com
Subject: [Qemu-devel] [PATCH 5/5] qemu-nbd: Add --bitmap=NAME option
Date: Tue, 8 Jan 2019 22:14:52 -0600 [thread overview]
Message-ID: <20190109041452.31240-6-eblake@redhat.com> (raw)
In-Reply-To: <20190109041452.31240-1-eblake@redhat.com>
Having to fire up qemu, then use QMP commands for nbd-server-start
and nbd-server-add, just to expose a persistent dirty bitmap, is
rather tedious. Make it possible to expose a dirty bitmap using
just qemu-nbd (of course, for now this only works when qemu-nbd is
visiting a BDS formatted as qcow2).
For now, I play it safe and only allow a bitmap to be exposed on
a read-only image. We may relax it in the future.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
qemu-nbd.texi | 5 +++++
qemu-nbd.c | 16 ++++++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/qemu-nbd.texi b/qemu-nbd.texi
index 9a84e81eed9..1bf9d2bd8bf 100644
--- a/qemu-nbd.texi
+++ b/qemu-nbd.texi
@@ -45,6 +45,11 @@ auto-detecting
Export the disk as read-only
@item -P, --partition=@var{num}
Only expose partition @var{num}
+@item -B, --bitmap=@var{name}
+If @var{filename} has a qcow2 persistent bitmap @var{name}, expose
+that bitmap via the ``qemu:dirty-bitmap:@var{name}'' context
+accessible through NBD_OPT_SET_META_CONTEXT. Requires the use of
+@option{-r}.
@item -s, --snapshot
Use @var{filename} as an external snapshot, create a temporary
file with backing_file=@var{filename}, redirect the write to
diff --git a/qemu-nbd.c b/qemu-nbd.c
index a6cc0f2553e..9781efe7a25 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -95,6 +95,7 @@ static void usage(const char *name)
"Exposing part of the image:\n"
" -o, --offset=OFFSET offset into the image\n"
" -P, --partition=NUM only expose partition NUM\n"
+" -B, --bitmap=NAME expose a persistent dirty bitmap\n"
"\n"
"General purpose options:\n"
" --object type,id=ID,... define an object such as 'secret' for providing\n"
@@ -509,7 +510,7 @@ int main(int argc, char **argv)
off_t fd_size;
QemuOpts *sn_opts = NULL;
const char *sn_id_or_name = NULL;
- const char *sopt = "hVb:o:p:rsnP:c:dvk:e:f:tl:x:T:D:";
+ const char *sopt = "hVb:o:p:rsnP:c:dvk:e:f:tl:x:T:D:B:";
struct option lopt[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
@@ -519,6 +520,7 @@ int main(int argc, char **argv)
{ "offset", required_argument, NULL, 'o' },
{ "read-only", no_argument, NULL, 'r' },
{ "partition", required_argument, NULL, 'P' },
+ { "bitmap", required_argument, NULL, 'B' },
{ "connect", required_argument, NULL, 'c' },
{ "disconnect", no_argument, NULL, 'd' },
{ "snapshot", no_argument, NULL, 's' },
@@ -558,6 +560,7 @@ int main(int argc, char **argv)
QDict *options = NULL;
const char *export_name = ""; /* Default export name */
const char *export_description = NULL;
+ const char *bitmap = NULL;
const char *tlscredsid = NULL;
bool imageOpts = false;
bool writethrough = true;
@@ -695,6 +698,9 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
break;
+ case 'B':
+ bitmap = optarg;
+ break;
case 'k':
sockpath = optarg;
if (sockpath[0] != '/') {
@@ -822,6 +828,12 @@ int main(int argc, char **argv)
}
}
+ if (bitmap && !(nbdflags & NBD_FLAG_READ_ONLY)) {
+ error_report("Exporting bitmap '%s' requires a readonly export",
+ bitmap);
+ exit(EXIT_FAILURE);
+ }
+
#if !HAVE_NBD_DEVICE
if (disconnect || device) {
error_report("Kernel /dev/nbdN support not available");
@@ -1015,7 +1027,7 @@ int main(int argc, char **argv)
}
}
- exp = nbd_export_new(bs, dev_offset, fd_size, export_name, NULL, NULL,
+ exp = nbd_export_new(bs, dev_offset, fd_size, export_name, bitmap, NULL,
export_description, nbdflags, nbd_export_closed,
writethrough, NULL, &error_fatal);
--
2.20.1
next prev parent reply other threads:[~2019-01-09 4:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-09 4:14 [Qemu-devel] [PATCH 0/5] Promote x-nbd-server-add-bitmap to stable Eric Blake
2019-01-09 4:14 ` [Qemu-devel] [PATCH 1/5] nbd: Merge nbd_export_set_name into nbd_export_new Eric Blake
2019-01-09 4:14 ` [Qemu-devel] [PATCH 2/5] nbd: Allow bitmap export during QMP nbd-server-add Eric Blake
2019-01-10 3:34 ` Eric Blake
2019-01-09 4:14 ` [Qemu-devel] [PATCH 3/5] nbd: Remove x-nbd-server-add-bitmap Eric Blake
2019-01-09 4:14 ` [Qemu-devel] [PATCH 4/5] nbd: Merge nbd_export_bitmap into nbd_export_new Eric Blake
2019-01-09 4:14 ` Eric Blake [this message]
2019-01-09 18:27 ` [Qemu-devel] [PATCH 5/5] qemu-nbd: Add --bitmap=NAME option Eric Blake
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=20190109041452.31240-6-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=jsnow@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).