From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atkhi-000428-Oo for qemu-devel@nongnu.org; Fri, 22 Apr 2016 19:41:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1atkhh-0005TH-9o for qemu-devel@nongnu.org; Fri, 22 Apr 2016 19:41:42 -0400 From: Eric Blake Date: Fri, 22 Apr 2016 17:40:33 -0600 Message-Id: <1461368452-10389-26-git-send-email-eblake@redhat.com> In-Reply-To: <1461368452-10389-1-git-send-email-eblake@redhat.com> References: <1461368452-10389-1-git-send-email-eblake@redhat.com> Subject: [Qemu-devel] [PATCH v3 25/44] qemu-io: Add 'open -u' to set BDRV_O_UNMAP after the fact List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, alex@alex.org.uk, Kevin Wolf , Max Reitz 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 --- qemu-io.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index cdc9497..dc8d124 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"); -- 2.5.5