Message ID | 1462419759-14694-6-git-send-email-eblake@redhat.com |
---|---|
State | New |
Headers | show |
On 05.05.2016 05:42, Eric Blake wrote: > When opening a file from the command line, qemu-io defaults > to BDRV_O_UNMAP but allows -d to give full control to disable > unmaps. But when opening via the 'open' command, qemu-io did > not set BDRV_O_UNMAP, and had no way to allow it. > > Make it at least possible to symmetrically test things: > 'qemu-io -d ignore' at the CLI now matches 'qemu-io> open' > in batch mode, and 'qemu-io' or 'qemu-io -d unmap' at > the CLI matches 'qemu-io> open -u'. > > Signed-off-by: Eric Blake <eblake@redhat.com> > --- > qemu-io.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) Not sure why you didn't just reuse the -d option for qemu-io itself, but: Reviewed-by: Max Reitz <mreitz@redhat.com>
On 05/06/2016 10:08 AM, Max Reitz wrote: > On 05.05.2016 05:42, Eric Blake wrote: >> When opening a file from the command line, qemu-io defaults >> to BDRV_O_UNMAP but allows -d to give full control to disable >> unmaps. But when opening via the 'open' command, qemu-io did >> not set BDRV_O_UNMAP, and had no way to allow it. >> >> Make it at least possible to symmetrically test things: >> 'qemu-io -d ignore' at the CLI now matches 'qemu-io> open' >> in batch mode, and 'qemu-io' or 'qemu-io -d unmap' at >> the CLI matches 'qemu-io> open -u'. >> >> Signed-off-by: Eric Blake <eblake@redhat.com> >> --- >> qemu-io.c | 8 ++++++-- >> 1 file changed, 6 insertions(+), 2 deletions(-) > > Not sure why you didn't just reuse the -d option for qemu-io itself, but: -d=string is different than -u (as a binary flag). But you have a point, that being able to fully-specify ALL modes, rather than just turning on a single mode, is more flexible. I'll see how tough it is to fix for v5.
On 05/06/2016 10:21 AM, Eric Blake wrote: > On 05/06/2016 10:08 AM, Max Reitz wrote: >> On 05.05.2016 05:42, Eric Blake wrote: >>> When opening a file from the command line, qemu-io defaults >>> to BDRV_O_UNMAP but allows -d to give full control to disable >>> unmaps. But when opening via the 'open' command, qemu-io did >>> not set BDRV_O_UNMAP, and had no way to allow it. >>> >>> Make it at least possible to symmetrically test things: >>> 'qemu-io -d ignore' at the CLI now matches 'qemu-io> open' >>> in batch mode, and 'qemu-io' or 'qemu-io -d unmap' at >>> the CLI matches 'qemu-io> open -u'. >>> >>> Signed-off-by: Eric Blake <eblake@redhat.com> >>> --- >>> qemu-io.c | 8 ++++++-- >>> 1 file changed, 6 insertions(+), 2 deletions(-) >> >> Not sure why you didn't just reuse the -d option for qemu-io itself, but: > > -d=string is different than -u (as a binary flag). But you have a > point, that being able to fully-specify ALL modes, rather than just > turning on a single mode, is more flexible. I'll see how tough it is to > fix for v5. And it looks like supporting it in 'reopen' would also make sense.
diff --git a/qemu-io.c b/qemu-io.c index 4aba7e0..2196159 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -107,6 +107,7 @@ static void open_help(void) " -r, -- open file read-only\n" " -s, -- use snapshot file\n" " -n, -- disable host cache\n" +" -u, -- allow discard and zero operations to unmap\n" " -o, -- options to be given to the block driver" "\n"); } @@ -120,7 +121,7 @@ static const cmdinfo_t open_cmd = { .argmin = 1, .argmax = -1, .flags = CMD_NOFILE_OK, - .args = "[-Crsn] [-o options] [path]", + .args = "[-Crsnu] [-o options] [path]", .oneline = "open the file specified by path", .help = open_help, }; @@ -144,7 +145,7 @@ static int open_f(BlockBackend *blk, int argc, char **argv) QemuOpts *qopts; QDict *opts; - while ((c = getopt(argc, argv, "snrgo:")) != -1) { + while ((c = getopt(argc, argv, "snrguo:")) != -1) { switch (c) { case 's': flags |= BDRV_O_SNAPSHOT; @@ -156,6 +157,9 @@ static int open_f(BlockBackend *blk, int argc, char **argv) case 'r': readonly = 1; break; + case 'u': + flags |= BDRV_O_UNMAP; + break; case 'o': if (imageOpts) { printf("--image-opts and 'open -o' are mutually exclusive\n");
When opening a file from the command line, qemu-io defaults to BDRV_O_UNMAP but allows -d to give full control to disable unmaps. But when opening via the 'open' command, qemu-io did not set BDRV_O_UNMAP, and had no way to allow it. Make it at least possible to symmetrically test things: 'qemu-io -d ignore' at the CLI now matches 'qemu-io> open' in batch mode, and 'qemu-io' or 'qemu-io -d unmap' at the CLI matches 'qemu-io> open -u'. Signed-off-by: Eric Blake <eblake@redhat.com> --- qemu-io.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)