[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 61/69] qemu-io: Make 'open' subcommand more like comm
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 61/69] qemu-io: Make 'open' subcommand more like command line |
Date: |
Thu, 12 May 2016 16:35:41 +0200 |
From: Eric Blake <address@hidden>
The command line defaults to BDRV_O_UNMAP, but can use
-d to reset it. Meanwhile, the 'open' subcommand was
defaulting to no discards, with no way to set it.
The command line has both -n and -tMODE to set a variety
of cache modes, but the 'open' subcommand had only -n.
The 'open' subcommand had no way to set BDRV_O_NATIVE_AIO.
Note that the 'reopen' subcommand uses '-c' where the
command line and 'open' use -t. Making that consistent
would be a separate patch.
Signed-off-by: Eric Blake <address@hidden>
Message-id: address@hidden
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
qemu-io.c | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/qemu-io.c b/qemu-io.c
index 0a1a3df..5ef3ef7 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -106,7 +106,10 @@ static void open_help(void)
" Opens a file for subsequent use by all of the other qemu-io commands.\n"
" -r, -- open file read-only\n"
" -s, -- use snapshot file\n"
-" -n, -- disable host cache\n"
+" -n, -- disable host cache, short for -t none\n"
+" -k, -- use kernel AIO implementation (on Linux only)\n"
+" -t, -- use the given cache mode for the image\n"
+" -d, -- use the given discard mode for the image\n"
" -o, -- options to be given to the block driver"
"\n");
}
@@ -120,7 +123,7 @@ static const cmdinfo_t open_cmd = {
.argmin = 1,
.argmax = -1,
.flags = CMD_NOFILE_OK,
- .args = "[-rsn] [-o options] [path]",
+ .args = "[-rsnk] [-t cache] [-d discard] [-o options] [path]",
.oneline = "open the file specified by path",
.help = open_help,
};
@@ -137,14 +140,14 @@ static QemuOptsList empty_opts = {
static int open_f(BlockBackend *blk, int argc, char **argv)
{
- int flags = 0;
+ int flags = BDRV_O_UNMAP;
int readonly = 0;
bool writethrough = true;
int c;
QemuOpts *qopts;
QDict *opts;
- while ((c = getopt(argc, argv, "snro:")) != -1) {
+ while ((c = getopt(argc, argv, "snro:kt:d:")) != -1) {
switch (c) {
case 's':
flags |= BDRV_O_SNAPSHOT;
@@ -156,9 +159,27 @@ static int open_f(BlockBackend *blk, int argc, char **argv)
case 'r':
readonly = 1;
break;
+ case 'k':
+ flags |= BDRV_O_NATIVE_AIO;
+ break;
+ case 't':
+ if (bdrv_parse_cache_mode(optarg, &flags, &writethrough) < 0) {
+ error_report("Invalid cache option: %s", optarg);
+ qemu_opts_reset(&empty_opts);
+ return 0;
+ }
+ break;
+ case 'd':
+ if (bdrv_parse_discard_flags(optarg, &flags) < 0) {
+ error_report("Invalid discard option: %s", optarg);
+ qemu_opts_reset(&empty_opts);
+ return 0;
+ }
+ break;
case 'o':
if (imageOpts) {
printf("--image-opts and 'open -o' are mutually exclusive\n");
+ qemu_opts_reset(&empty_opts);
return 0;
}
if (!qemu_opts_parse_noisily(&empty_opts, optarg, false)) {
--
1.8.3.1
- [Qemu-devel] [PULL 66/69] block: add support for --image-opts in block I/O tests, (continued)
- [Qemu-devel] [PULL 66/69] block: add support for --image-opts in block I/O tests, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 67/69] block: add support for encryption secrets in block I/O tests, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 41/69] sd: Switch to byte-based block access, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 56/69] qemu-img: check block status of backing file when converting., Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 53/69] block: Drop superfluous invalidating bs->file from drivers, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 57/69] Add new block driver interface to add/delete a BDS's child, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 54/69] block: Inactivate all children, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 65/69] qemu-io: Add 'write -z -u' to test MAY_UNMAP flag, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 62/69] qemu-io: Use bool for command line flags, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 58/69] quorum: implement bdrv_add_child() and bdrv_del_child(), Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 61/69] qemu-io: Make 'open' subcommand more like command line,
Kevin Wolf <=
- [Qemu-devel] [PULL 60/69] qemu-io: Add missing option documentation, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 68/69] block: enable testing of LUKS driver with block I/O tests, Kevin Wolf, 2016/05/12
- [Qemu-devel] [PULL 63/69] qemu-io: Allow unaligned access by default, Kevin Wolf, 2016/05/12
- Re: [Qemu-devel] [PULL 00/69] Block layer patches, Peter Maydell, 2016/05/12