summaryrefslogtreecommitdiffstats
path: root/qemu-nbd.c
diff options
context:
space:
mode:
authorEric Blake2019-01-11 20:47:20 +0100
committerEric Blake2019-01-14 17:09:46 +0100
commit636192c4b6052820ea126a5287c58a8f53f3c84f (patch)
treea84e1b6b8c3f06fd5db8e36aebcb8a0bb9e0bd86 /qemu-nbd.c
parentnbd: Merge nbd_export_bitmap into nbd_export_new (diff)
downloadqemu-636192c4b6052820ea126a5287c58a8f53f3c84f.tar.gz
qemu-636192c4b6052820ea126a5287c58a8f53f3c84f.tar.xz
qemu-636192c4b6052820ea126a5287c58a8f53f3c84f.zip
qemu-nbd: Add --bitmap=NAME option
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). Of course, any good feature also needs unit testing, so expand iotest 223 to cover it. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <20190111194720.15671-9-eblake@redhat.com>
Diffstat (limited to 'qemu-nbd.c')
-rw-r--r--qemu-nbd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 1552274c18..51b55f2e06 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] != '/') {
@@ -1016,7 +1022,7 @@ int main(int argc, char **argv)
}
export = nbd_export_new(bs, dev_offset, fd_size, export_name,
- export_description, NULL, nbdflags,
+ export_description, bitmap, nbdflags,
nbd_export_closed, writethrough, NULL,
&error_fatal);