qemu-io: UI enhancements
PATCH v5 2/6 qemu-io: Make 'open' subcommand more like command line
In reply to Eric BlakeThe 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.
---
v5: was 5/6, move earlier, retitle, and add more options using similar -dMODE rather than new -u
--- qemu-io.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)
qemu-io.c +25 -4
@@ -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)) {
Signature · 1 line
2.5.5
v5 cover qemu-io: UI enhancements
While working on NBD, I found myself cursing the qemu-io UI for not letting me test various scenarios, particularly after fixing NBD to serve at byte granularity [1]. And in the process of writing these qemu-io enhancements, I also managed to flush out several other bugs in the block layer proper, with fixes posted separately, such as loss of BDRV_REQ_FUA during write_zeroes [2]
2.7 material, depends on Kevin's block-next:git://repo.or.cz/qemu/kevin.git block-next
and on my pending "block: kill sector-based blk_write/read" v7 or later
https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg00895.html
Previously posted as part of a larger v3 NBD series [3] and as a separate v4 [4], so this is v5.
[1] commit df7b97ff
[2] https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg00285.html
[3] https://lists.gnu.org/archive/html/qemu-devel/2016-04/msg03526.html
[4] https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg00619.html
Also available as a tag at this location:
git fetch git://repo.or.cz/qemu/ericb.git nbd-qemu-io-v5
Changes since then:
- patch 1: add more cleanups (R-b dropped)
- patch 2 (was 5/6) hoist earlier, retitle, use -dMODE instead of inventing -u [mreitz], add -k and -tMODE
- patch 4 (was 3/6) fix bool usage, drop spurious usage space [mreitz]
- patch 5 (was 4/6) fix bool usage [mreitz]
- patch 6 rebase to earlier changes (R-b kept)
001/6:[0011] [FC] 'qemu-io: Add missing option documentation' 002/6:[down] 'qemu-io: Make 'open' subcommand more like command line' 003/6:[----] [--] 'qemu-io: Use bool for command line flags' 004/6:[0022] [FC] 'qemu-io: Allow unaligned access by default' 005/6:[0014] [FC] 'qemu-io: Add 'write -f' to test FUA flag' 006/6:[0008] [FC] 'qemu-io: Add 'write -z -u' to test MAY_UNMAP flag'
Eric Blake (6):
qemu-io: Add missing option documentation
qemu-io: Make 'open' subcommand more like command line
qemu-io: Use bool for command line flags
qemu-io: Allow unaligned access by default
qemu-io: Add 'write -f' to test FUA flag
qemu-io: Add 'write -z -u' to test MAY_UNMAP flag
qemu-io-cmds.c | 228 ++--- qemu-io.c | 40 +- tests/qemu-iotests/023.out | 2160 +++++++++++++++++++++++++++++--------------- 3 files changed, 1587 insertions(+), 841 deletions(-)
Signature · 1 line
2.5.5
PATCH v5 3/6 qemu-io: Use bool for command line flags
We require a C99 compiler; let's use it to express what we really mean.
(Yes, we now have an instance of 'if (bool + bool + bool > 1)', which, although semantically valid C, looks ugly; it gets cleaned up later.)
---
v5: tweak commit message
--- qemu-io-cmds.c | 94 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 47 insertions(+), 47 deletions(-)
qemu-io-cmds.c +47 -47
@@ -345,7 +345,7 @@ static void dump_buffer(const void *buffer, int64_t offset, int64_t len) }static void print_report (const char *op,struct timeval *t,int64_t offset, -int64_t count,int64_t total,int cnt,int Cflag) +int64_t count,int64_t total,int cnt,bool Cflag) {char s1[64 ], s2[64 ], ts[64 ];
@@ -658,8 +658,8 @@ static const cmdinfo_t read_cmd = {static int read_f (BlockBackend *blk,int argc,char **argv) {struct timeval t1, t2; -int Cflag =0 , pflag =0 , qflag =0 , vflag =0 ; -int Pflag =0 , sflag =0 , lflag =0 , bflag =0 ; +bool Cflag = false, pflag = false, qflag = false, vflag = false; +bool Pflag = false, sflag = false, lflag = false, bflag = false;int c, cnt;char *buf;int64_t offset;
@@ -672,13 +672,13 @@ static int read_f(BlockBackend *blk, int argc, char **argv)while ((c =getopt (argc, argv,"bCl:pP:qs:v" )) !=-1 ) {switch (c) {case 'b' : - bflag =1 ; + bflag = true;break ;case 'C' : - Cflag =1 ; + Cflag = true;break ;case 'l' : - lflag =1 ; + lflag = true; pattern_count =cvtnum (optarg);if (pattern_count <0 ) {print_cvtnum_err (pattern_count, optarg);
@@ -686,20 +686,20 @@ static int read_f(BlockBackend *blk, int argc, char **argv) }break ;case 'p' : - pflag =1 ; + pflag = true;break ;case 'P' : - Pflag =1 ; + Pflag = true; pattern =parse_pattern (optarg);if (pattern <0 ) {return 0 ; }break ;case 'q' : - qflag =1 ; + qflag = true;break ;case 's' : - sflag =1 ; + sflag = true; pattern_offset =cvtnum (optarg);if (pattern_offset <0 ) {print_cvtnum_err (pattern_offset, optarg);
@@ -707,7 +707,7 @@ static int read_f(BlockBackend *blk, int argc, char **argv) }break ;case 'v' : - vflag =1 ; + vflag = true;break ;default :return qemuio_command_usage (&read_cmd);
@@ -844,7 +844,7 @@ static const cmdinfo_t readv_cmd = {static int readv_f (BlockBackend *blk,int argc,char **argv) {struct timeval t1, t2; -int Cflag =0 , qflag =0 , vflag =0 ; +bool Cflag = false, qflag = false, vflag = false;int c, cnt;char *buf;int64_t offset;
@@ -853,25 +853,25 @@ static int readv_f(BlockBackend *blk, int argc, char **argv)int nr_iov;QEMUIOVector qiov;int pattern =0 ; -int Pflag =0 ; +bool Pflag = false;while ((c =getopt (argc, argv,"CP:qv" )) !=-1 ) {switch (c) {case 'C' : - Cflag =1 ; + Cflag = true;break ;case 'P' : - Pflag =1 ; + Pflag = true; pattern =parse_pattern (optarg);if (pattern <0 ) {return 0 ; }break ;case 'q' : - qflag =1 ; + qflag = true;break ;case 'v' : - vflag =1 ; + vflag = true;break ;default :return qemuio_command_usage (&readv_cmd);
@@ -976,8 +976,8 @@ static const cmdinfo_t write_cmd = {static int write_f (BlockBackend *blk,int argc,char **argv) {struct timeval t1, t2; -int Cflag =0 , pflag =0 , qflag =0 , bflag =0 , Pflag =0 , zflag =0 ; -int cflag =0 ; +bool Cflag = false, pflag = false, qflag = false, bflag = false; +bool Pflag = false, zflag = false, cflag = false;int c, cnt;char *buf =NULL ;int64_t offset;
@@ -989,29 +989,29 @@ static int write_f(BlockBackend *blk, int argc, char **argv)while ((c =getopt (argc, argv,"bcCpP:qz" )) !=-1 ) {switch (c) {case 'b' : - bflag =1 ; + bflag = true;break ;case 'c' : - cflag =1 ; + cflag = true;break ;case 'C' : - Cflag =1 ; + Cflag = true;break ;case 'p' : - pflag =1 ; + pflag = true;break ;case 'P' : - Pflag =1 ; + Pflag = true; pattern =parse_pattern (optarg);if (pattern <0 ) {return 0 ; }break ;case 'q' : - qflag =1 ; + qflag = true;break ;case 'z' : - zflag =1 ; + zflag = true;break ;default :return qemuio_command_usage (&write_cmd);
@@ -1133,7 +1133,7 @@ static const cmdinfo_t writev_cmd = {static int writev_f (BlockBackend *blk,int argc,char **argv) {struct timeval t1, t2; -int Cflag =0 , qflag =0 ; +bool Cflag = false, qflag = false;int c, cnt;char *buf;int64_t offset;
@@ -1146,10 +1146,10 @@ static int writev_f(BlockBackend *blk, int argc, char **argv)while ((c =getopt (argc, argv,"CqP:" )) !=-1 ) {switch (c) {case 'C' : - Cflag =1 ; + Cflag = true;break ;case 'q' : - qflag =1 ; + qflag = true;break ;case 'P' : pattern =parse_pattern (optarg);
@@ -1242,7 +1242,7 @@ static const cmdinfo_t multiwrite_cmd = {static int multiwrite_f (BlockBackend *blk,int argc,char **argv) {struct timeval t1, t2; -int Cflag =0 , qflag =0 ; +bool Cflag = false, qflag = false;int c, cnt;char **buf;int64_t offset, first_offset =0 ;
@@ -1258,10 +1258,10 @@ static int multiwrite_f(BlockBackend *blk, int argc, char **argv)while ((c =getopt (argc, argv,"CqP:" )) !=-1 ) {switch (c) {case 'C' : - Cflag =1 ; + Cflag = true;break ;case 'q' : - qflag =1 ; + qflag = true;break ;case 'P' : pattern =parse_pattern (optarg);
@@ -1371,11 +1371,11 @@ struct aio_ctx {QEMUIOVector qiov;int64_t offset;char *buf; -int qflag; -int vflag; -int Cflag; -int Pflag; -int zflag; +bool qflag; +bool vflag; +bool Cflag; +bool Pflag; +bool zflag;BlockAcctCookie acct;int pattern;struct timeval t1;
@@ -1498,10 +1498,10 @@ static int aio_read_f(BlockBackend *blk, int argc, char **argv)while ((c =getopt (argc, argv,"CP:qv" )) !=-1 ) {switch (c) {case 'C' : - ctx->Cflag =1 ; + ctx->Cflag = true;break ;case 'P' : - ctx->Pflag =1 ; + ctx->Pflag = true; ctx->pattern =parse_pattern (optarg);if (ctx->pattern <0 ) {g_free (ctx);
@@ -1509,10 +1509,10 @@ static int aio_read_f(BlockBackend *blk, int argc, char **argv) }break ;case 'q' : - ctx->qflag =1 ; + ctx->qflag = true;break ;case 'v' : - ctx->vflag =1 ; + ctx->vflag = true;break ;default :g_free (ctx);
@@ -1599,10 +1599,10 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv)while ((c =getopt (argc, argv,"CqP:z" )) !=-1 ) {switch (c) {case 'C' : - ctx->Cflag =1 ; + ctx->Cflag = true;break ;case 'q' : - ctx->qflag =1 ; + ctx->qflag = true;break ;case 'P' : pattern =parse_pattern (optarg);
@@ -1612,7 +1612,7 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv) }break ;case 'z' : - ctx->zflag =1 ; + ctx->zflag = true;break ;default :g_free (ctx);
@@ -1840,17 +1840,17 @@ static const cmdinfo_t discard_cmd = {static int discard_f (BlockBackend *blk,int argc,char **argv) {struct timeval t1, t2; -int Cflag =0 , qflag =0 ; +bool Cflag = false, qflag = false;int c, ret;int64_t offset, count;while ((c =getopt (argc, argv,"Cq" )) !=-1 ) {switch (c) {case 'C' : - Cflag =1 ; + Cflag = true;break ;case 'q' : - qflag =1 ; + qflag = true;break ;default :return qemuio_command_usage (&discard_cmd);
Signature · 1 line
2.5.5
PATCH v5 5/6 qemu-io: Add 'write -f' to test FUA flag
In reply to Eric BlakeMake it easier to test block drivers with BDRV_REQ_FUA in .supported_write_flags, by adding the '-f' flag to qemu-io to conditionally pass the flag through to specific writes ('write', 'write -z', 'writev', 'aio_write', 'aio_write -z'). You'll want to use 'qemu-io -t none' to actually make -f useful (as otherwise, the default writethrough mode automatically sets the FUA bit on every write).
---
v5: use bool operator
--- qemu-io-cmds.c | 57 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 16 deletions(-)
qemu-io-cmds.c +41 -16
@@ -428,13 +428,13 @@ static int do_pread(BlockBackend *blk, char *buf, int64_t offset, }static int do_pwrite (BlockBackend *blk,char *buf,int64_t offset, -int64_t count,int64_t *total) +int64_t count,int flags,int64_t *total) {if (count >INT_MAX ) {return -ERANGE ; } - *total =blk_pwrite (blk, offset, (uint8_t *)buf, count,0 ); + *total =blk_pwrite (blk, offset, (uint8_t *)buf, count, flags);if (*total <0 ) {return *total; }
@@ -446,6 +446,7 @@ typedef struct {int64_t offset;int64_t count;int64_t *total; +int flags;int ret;bool done; } CoWriteZeroes;
@@ -454,7 +455,8 @@ static void coroutine_fn co_write_zeroes_entry(void *opaque) {CoWriteZeroes *data = opaque; - data->ret =blk_co_write_zeroes (data->blk, data->offset, data->count,0 ); + data->ret =blk_co_write_zeroes (data->blk, data->offset, data->count, + data->flags); data->done = true;if (data->ret <0 ) { *data->total = data->ret;
@@ -465,7 +467,7 @@ static void coroutine_fn co_write_zeroes_entry(void *opaque) }static int do_co_write_zeroes (BlockBackend *blk,int64_t offset,int64_t count, -int64_t *total) +int flags,int64_t *total) {Coroutine *co;CoWriteZeroes data = {
@@ -473,6 +475,7 @@ static int do_co_write_zeroes(BlockBackend *blk, int64_t offset, int64_t count, .offset = offset, .count = count, .total = total, + .flags = flags, .done = false, };
@@ -558,11 +561,11 @@ static int do_aio_readv(BlockBackend *blk, QEMUIOVector *qiov, }static int do_aio_writev (BlockBackend *blk,QEMUIOVector *qiov, -int64_t offset,int *total) +int64_t offset,int flags,int *total) {int async_ret =NOT_DONE ; -blk_aio_pwritev (blk, offset, qiov,0 , aio_rw_done, &async_ret); +blk_aio_pwritev (blk, offset, qiov, flags, aio_rw_done, &async_ret);while (async_ret ==NOT_DONE ) {main_loop_wait (false); }
@@ -935,6 +938,7 @@ static void write_help(void)" filled with a set pattern (0xcdcdcdcd).\n" " -b, -- write to the VM state rather than the virtual disk\n" " -c, -- write compressed data with blk_write_compressed\n" +" -f, -- use Force Unit Access semantics\n" " -p, -- ignored for backwards compatibility\n" " -P, -- use different pattern to fill file\n" " -C, -- report statistics in a machine parsable format\n"
@@ -951,7 +955,7 @@ static const cmdinfo_t write_cmd = { .cfunc = write_f, .argmin = 2, .argmax = -1, - .args = "[-bcCqz] [-P pattern] off len", + .args = "[-bcCfqz] [-P pattern] off len", .oneline = "writes a number of bytes at a specified offset", .help = write_help, };
@@ -961,6 +965,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv)struct timeval t1, t2;bool Cflag = false, qflag = false, bflag = false;bool Pflag = false, zflag = false, cflag = false; +int flags =0 ;int c, cnt;char *buf =NULL ;int64_t offset;
@@ -969,7 +974,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv)int64_t total =0 ;int pattern =0xcd ; -while ((c =getopt (argc, argv,"bcCpP:qz" )) !=-1 ) { +while ((c =getopt (argc, argv,"bcCfpP:qz" )) !=-1 ) {switch (c) {case 'b' : bflag = true;
@@ -980,6 +985,9 @@ static int write_f(BlockBackend *blk, int argc, char **argv)case 'C' : Cflag = true;break ; +case 'f' : + flags |=BDRV_REQ_FUA ; +break ;case 'p' :/* Ignored for backwards compatibility */ break ;
@@ -1010,6 +1018,11 @@ static int write_f(BlockBackend *blk, int argc, char **argv)return 0 ; } +if ((flags &BDRV_REQ_FUA ) && (bflag || cflag)) { +printf ("-f and -b or -c cannot be specified at the same time\n" ); +return 0 ; + } +if (zflag && Pflag) {printf ("-z and -P cannot be specified at the same time\n" );return 0 ;
@@ -1054,11 +1067,11 @@ static int write_f(BlockBackend *blk, int argc, char **argv)if (bflag) { cnt =do_save_vmstate (blk, buf, offset, count, &total); }else if (zflag) { - cnt =do_co_write_zeroes (blk, offset, count, &total); + cnt =do_co_write_zeroes (blk, offset, count, flags, &total); }else if (cflag) { cnt =do_write_compressed (blk, buf, offset, count, &total); }else { - cnt =do_pwrite (blk, buf, offset, count, &total); + cnt =do_pwrite (blk, buf, offset, count, flags, &total); }gettimeofday (&t2,NULL );
@@ -1097,6 +1110,7 @@ writev_help(void)" filled with a set pattern (0xcdcdcdcd).\n" " -P, -- use different pattern to fill file\n" " -C, -- report statistics in a machine parsable format\n" +" -f, -- use Force Unit Access semantics\n" " -q, -- quiet mode, do not show I/O statistics\n" "\n"); }
@@ -1108,7 +1122,7 @@ static const cmdinfo_t writev_cmd = { .cfunc = writev_f, .argmin = 2, .argmax = -1, - .args = "[-Cq] [-P pattern] off len [len..]", + .args = "[-Cfq] [-P pattern] off len [len..]", .oneline = "writes a number of bytes at a specified offset", .help = writev_help, };
@@ -1117,6 +1131,7 @@ static int writev_f(BlockBackend *blk, int argc, char **argv) {struct timeval t1, t2;bool Cflag = false, qflag = false; +int flags =0 ;int c, cnt;char *buf;int64_t offset;
@@ -1131,6 +1146,9 @@ static int writev_f(BlockBackend *blk, int argc, char **argv)case 'C' : Cflag = true;break ; +case 'f' : + flags |=BDRV_REQ_FUA ; +break ;case 'q' : qflag = true;break ;
@@ -1163,7 +1181,7 @@ static int writev_f(BlockBackend *blk, int argc, char **argv) }gettimeofday (&t1,NULL ); - cnt =do_aio_writev (blk, &qiov, offset, &total); + cnt =do_aio_writev (blk, &qiov, offset, flags, &total);gettimeofday (&t2,NULL );if (cnt <0 ) {
@@ -1541,6 +1559,7 @@ static void aio_write_help(void)" used to ensure all outstanding aio requests have been completed.\n" " -P, -- use different pattern to fill file\n" " -C, -- report statistics in a machine parsable format\n" +" -f, -- use Force Unit Access semantics\n" " -q, -- quiet mode, do not show I/O statistics\n" " -z, -- write zeroes using blk_aio_write_zeroes\n" "\n");
@@ -1553,7 +1572,7 @@ static const cmdinfo_t aio_write_cmd = { .cfunc = aio_write_f, .argmin = 2, .argmax = -1, - .args = "[-Cqz] [-P pattern] off len [len..]", + .args = "[-Cfqz] [-P pattern] off len [len..]", .oneline = "asynchronously writes a number of bytes", .help = aio_write_help, };
@@ -1563,13 +1582,17 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv)int nr_iov, c;int pattern =0xcd ; struct aio_ctx *ctx = g_new0(struct aio_ctx, 1); +int flags =0 ; ctx->blk = blk; -while ((c =getopt (argc, argv,"CqP:z" )) !=-1 ) { +while ((c =getopt (argc, argv,"CfqP:z" )) !=-1 ) {switch (c) {case 'C' : ctx->Cflag = true;break ; +case 'f' : + flags |=BDRV_REQ_FUA ; +break ;case 'q' : ctx->qflag = true;break ;
@@ -1622,7 +1645,8 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv) } ctx->qiov.size = count; -blk_aio_write_zeroes (blk, ctx->offset, count,0 , aio_write_done, ctx); +blk_aio_write_zeroes (blk, ctx->offset, count, flags, aio_write_done, + ctx); }else { nr_iov = argc - optind; ctx->buf = create_iovec(blk, &ctx->qiov, &argv[optind], nr_iov,
@@ -1637,7 +1661,8 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv)block_acct_start (blk_get_stats (blk), &ctx->acct, ctx->qiov.size,BLOCK_ACCT_WRITE ); -blk_aio_pwritev (blk, ctx->offset, &ctx->qiov,0 , aio_write_done, ctx); +blk_aio_pwritev (blk, ctx->offset, &ctx->qiov, flags, aio_write_done, + ctx); }return 0 ; }
Signature · 1 line
2.5.5
PATCH v5 6/6 qemu-io: Add 'write -z -u' to test MAY_UNMAP flag
In reply to Eric BlakeMake it easier to control whether the BDRV_REQ_MAY_UNMAP flag can be passed through a write_zeroes command, by adding the '-u' flag to qemu-io 'write -z' and 'aio_write -z'. To be useful, the device has to be opened with BDRV_O_UNMAP (done by default in qemu-io, but can be made explicit with '-d unmap').
---
v5: tweak commit message for rebase conflict resolution
--- qemu-io-cmds.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
qemu-io-cmds.c +21 -3
@@ -943,6 +943,7 @@ static void write_help(void)" -P, -- use different pattern to fill file\n" " -C, -- report statistics in a machine parsable format\n" " -q, -- quiet mode, do not show I/O statistics\n" +" -u, -- with -z, allow unmapping\n" " -z, -- write zeroes using blk_co_write_zeroes\n" "\n"); }
@@ -955,7 +956,7 @@ static const cmdinfo_t write_cmd = { .cfunc = write_f, .argmin = 2, .argmax = -1, - .args = "[-bcCfqz] [-P pattern] off len", + .args = "[-bcCfquz] [-P pattern] off len", .oneline = "writes a number of bytes at a specified offset", .help = write_help, };
@@ -974,7 +975,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv)int64_t total =0 ;int pattern =0xcd ; -while ((c =getopt (argc, argv,"bcCfpP:qz" )) !=-1 ) { +while ((c =getopt (argc, argv,"bcCfpP:quz" )) !=-1 ) {switch (c) {case 'b' : bflag = true;
@@ -1001,6 +1002,9 @@ static int write_f(BlockBackend *blk, int argc, char **argv)case 'q' : qflag = true;break ; +case 'u' : + flags |=BDRV_REQ_MAY_UNMAP ; +break ;case 'z' : zflag = true;break ;
@@ -1023,6 +1027,11 @@ static int write_f(BlockBackend *blk, int argc, char **argv)return 0 ; } +if ((flags &BDRV_REQ_MAY_UNMAP ) && !zflag) { +printf ("-u requires -z to be specified\n" ); +return 0 ; + } +if (zflag && Pflag) {printf ("-z and -P cannot be specified at the same time\n" );return 0 ;
@@ -1561,6 +1570,7 @@ static void aio_write_help(void)" -C, -- report statistics in a machine parsable format\n" " -f, -- use Force Unit Access semantics\n" " -q, -- quiet mode, do not show I/O statistics\n" +" -u, -- with -z, allow unmapping\n" " -z, -- write zeroes using blk_aio_write_zeroes\n" "\n"); }
@@ -1572,7 +1582,7 @@ static const cmdinfo_t aio_write_cmd = { .cfunc = aio_write_f, .argmin = 2, .argmax = -1, - .args = "[-Cfqz] [-P pattern] off len [len..]", + .args = "[-Cfquz] [-P pattern] off len [len..]", .oneline = "asynchronously writes a number of bytes", .help = aio_write_help, };
@@ -1596,6 +1606,9 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv)case 'q' : ctx->qflag = true;break ; +case 'u' : + flags |=BDRV_REQ_MAY_UNMAP ; +break ;case 'P' : pattern =parse_pattern (optarg);if (pattern <0 ) {
@@ -1623,6 +1636,11 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv)return 0 ; } +if ((flags &BDRV_REQ_MAY_UNMAP ) && !ctx->zflag) { +printf ("-u requires -z to be specified\n" ); +return 0 ; + } +if (ctx->zflag && ctx->Pflag) {printf ("-z and -P cannot be specified at the same time\n" );g_free (ctx);
Signature · 1 line
2.5.5
PATCH v5 4/6 qemu-io: Allow unaligned access by default
In reply to Eric BlakeThere's no reason to require the user to specify a flag just so they can pass in unaligned numbers. Keep 'read -p' and 'write -p' as no-ops so that I don't have to hunt down and update all users of qemu-io, but otherwise make their behavior default as 'read' and 'write'. Also fix 'write -z', 'readv', 'writev', 'writev', 'aio_read', 'aio_write', and 'aio_write -z'. For now, 'read -b', 'write -b', and 'write -c' still require alignment (and 'multiwrite', but that's slated to die soon).
qemu-iotest 23 is updated to match, as the only test that was previously explicitly expecting an error on an unaligned request.
---
v5: use bool operator, drop spurious spaces in .args
--- qemu-io-cmds.c | 73 +- tests/qemu-iotests/023.out | 2160 +++++++++++++++++++++++++++++--------------- 2 files changed, 1457 insertions(+), 776 deletions(-)
qemu-io-cmds.c +17 -56
@@ -1,7 +1,7 @@/* * Command line utility to exercise the QEMU I/O path. * -* Copyright (C) 2009 Red Hat, Inc. +* Copyright (C) 2009-2016 Red Hat, Inc. * Copyright (c) 2003-2005 Silicon Graphics, Inc. * * This work is licensed under the terms of the GNU GPL, version 2 or later.
@@ -395,12 +395,6 @@ create_iovec(BlockBackend *blk, QEMUIOVector *qiov, char **argv, int nr_iov, goto fail; } -if (len &0x1ff ) { -printf ("length argument %" PRId64 -" is not sector aligned\n" , len); - goto fail; - } - sizes[i] = len; count += len; }
@@ -634,7 +628,7 @@ static void read_help(void)" -b, -- read from the VM state rather than the virtual disk\n" " -C, -- report statistics in a machine parsable format\n" " -l, -- length for pattern verification (only with -P)\n" -" -p, -- allow unaligned access\n" +" -p, -- ignored for backwards compatibility\n" " -P, -- use a pattern to verify read data\n" " -q, -- quiet mode, do not show I/O statistics\n" " -s, -- start offset for pattern verification (only with -P)\n"
@@ -650,7 +644,7 @@ static const cmdinfo_t read_cmd = { .cfunc = read_f, .argmin = 2, .argmax = -1, - .args = "[-abCpqv] [-P pattern [-s off] [-l len]] off len", + .args = "[-abCqv] [-P pattern [-s off] [-l len]] off len", .oneline = "reads a number of bytes at a specified offset", .help = read_help, };
@@ -658,7 +652,7 @@ static const cmdinfo_t read_cmd = {static int read_f (BlockBackend *blk,int argc,char **argv) {struct timeval t1, t2; -bool Cflag = false, pflag = false, qflag = false, vflag = false; +bool Cflag = false, qflag = false, vflag = false;bool Pflag = false, sflag = false, lflag = false, bflag = false;int c, cnt;char *buf;
@@ -686,7 +680,7 @@ static int read_f(BlockBackend *blk, int argc, char **argv) }break ;case 'p' : - pflag = true; +/* Ignored for backwards compatibility */ break ;case 'P' : Pflag = true;
@@ -718,11 +712,6 @@ static int read_f(BlockBackend *blk, int argc, char **argv)return qemuio_command_usage (&read_cmd); } -if (bflag && pflag) { -printf ("-b and -p cannot be specified at the same time\n" ); -return 0 ; - } - offset =cvtnum (argv[optind]);if (offset <0 ) {print_cvtnum_err (offset, argv[optind]);
@@ -753,7 +742,7 @@ static int read_f(BlockBackend *blk, int argc, char **argv)return 0 ; } -if (!pflag) { +if (bflag) {if (offset &0x1ff ) {printf ("offset %" PRId64" is not sector aligned\n" , offset);
@@ -836,7 +825,7 @@ static const cmdinfo_t readv_cmd = { .cfunc = readv_f, .argmin = 2, .argmax = -1, - .args = "[-Cqv] [-P pattern ] off len [len..]", + .args = "[-Cqv] [-P pattern] off len [len..]", .oneline = "reads a number of bytes at a specified offset", .help = readv_help, };
@@ -890,12 +879,6 @@ static int readv_f(BlockBackend *blk, int argc, char **argv) } optind++; -if (offset &0x1ff ) { -printf ("offset %" PRId64" is not sector aligned\n" , - offset); -return 0 ; - } - nr_iov = argc - optind; buf =create_iovec (blk, &qiov, &argv[optind], nr_iov,0xab );if (buf ==NULL ) {
@@ -952,7 +935,7 @@ static void write_help(void)" filled with a set pattern (0xcdcdcdcd).\n" " -b, -- write to the VM state rather than the virtual disk\n" " -c, -- write compressed data with blk_write_compressed\n" -" -p, -- allow unaligned access\n" +" -p, -- ignored for backwards compatibility\n" " -P, -- use different pattern to fill file\n" " -C, -- report statistics in a machine parsable format\n" " -q, -- quiet mode, do not show I/O statistics\n"
@@ -968,7 +951,7 @@ static const cmdinfo_t write_cmd = { .cfunc = write_f, .argmin = 2, .argmax = -1, - .args = "[-bcCpqz] [-P pattern ] off len", + .args = "[-bcCqz] [-P pattern] off len", .oneline = "writes a number of bytes at a specified offset", .help = write_help, };
@@ -976,7 +959,7 @@ static const cmdinfo_t write_cmd = {static int write_f (BlockBackend *blk,int argc,char **argv) {struct timeval t1, t2; -bool Cflag = false, pflag = false, qflag = false, bflag = false; +bool Cflag = false, qflag = false, bflag = false;bool Pflag = false, zflag = false, cflag = false;int c, cnt;char *buf =NULL ;
@@ -998,7 +981,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv) Cflag = true;break ;case 'p' : - pflag = true; +/* Ignored for backwards compatibility */ break ;case 'P' : Pflag = true;
@@ -1022,8 +1005,8 @@ static int write_f(BlockBackend *blk, int argc, char **argv)return qemuio_command_usage (&write_cmd); } -if (bflag + pflag + zflag >1 ) { -printf ("-b, -p, or -z cannot be specified at the same time\n" ); +if (bflag && zflag) { +printf ("-b and -z cannot be specified at the same time\n" );return 0 ; }
@@ -1049,7 +1032,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv)return 0 ; } -if (!pflag) { +if (bflag || cflag) {if (offset &0x1ff ) {printf ("offset %" PRId64" is not sector aligned\n" , offset);
@@ -1125,7 +1108,7 @@ static const cmdinfo_t writev_cmd = { .cfunc = writev_f, .argmin = 2, .argmax = -1, - .args = "[-Cq] [-P pattern ] off len [len..]", + .args = "[-Cq] [-P pattern] off len [len..]", .oneline = "writes a number of bytes at a specified offset", .help = writev_help, };
@@ -1173,12 +1156,6 @@ static int writev_f(BlockBackend *blk, int argc, char **argv) } optind++; -if (offset &0x1ff ) { -printf ("offset %" PRId64" is not sector aligned\n" , - offset); -return 0 ; - } - nr_iov = argc - optind; buf =create_iovec (blk, &qiov, &argv[optind], nr_iov, pattern);if (buf ==NULL ) {
@@ -1484,7 +1461,7 @@ static const cmdinfo_t aio_read_cmd = { .cfunc = aio_read_f, .argmin = 2, .argmax = -1, - .args = "[-Cqv] [-P pattern ] off len [len..]", + .args = "[-Cqv] [-P pattern] off len [len..]", .oneline = "asynchronously reads a number of bytes", .help = aio_read_help, };
@@ -1533,14 +1510,6 @@ static int aio_read_f(BlockBackend *blk, int argc, char **argv) } optind++; -if (ctx->offset &0x1ff ) { -printf ("offset %" PRId64" is not sector aligned\n" , - ctx->offset); -block_acct_invalid (blk_get_stats (blk),BLOCK_ACCT_READ ); -g_free (ctx); -return 0 ; - } - nr_iov = argc - optind; ctx->buf =create_iovec (blk, &ctx->qiov, &argv[optind], nr_iov,0xab );if (ctx->buf ==NULL ) {
@@ -1584,7 +1553,7 @@ static const cmdinfo_t aio_write_cmd = { .cfunc = aio_write_f, .argmin = 2, .argmax = -1, - .args = "[-Cqz] [-P pattern ] off len [len..]", + .args = "[-Cqz] [-P pattern] off len [len..]", .oneline = "asynchronously writes a number of bytes", .help = aio_write_help, };
@@ -1645,14 +1614,6 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv) } optind++; -if (ctx->offset &0x1ff ) { -printf ("offset %" PRId64" is not sector aligned\n" , - ctx->offset); -block_acct_invalid (blk_get_stats (blk),BLOCK_ACCT_WRITE ); -g_free (ctx); -return 0 ; - } -if (ctx->zflag) {int64_t count =cvtnum (argv[optind]);if (count <0 ) {
tests/qemu-iotests/023.out +1440 -720
2,280 lines not on this page · raw message
Signature · 1 line
2.5.5
Quoted 6 lines · Eric Blake
While working on NBD, I found myself cursing the qemu-io UI for not letting me test various scenarios, particularly after fixing NBD to serve at byte granularity [1]. And in the process of writing these qemu-io enhancements, I also managed to flush out several other bugs in the block layer proper, with fixes posted separately, such as loss of
BDRV_REQ_FUAduringwrite_zeroes[2]
Apologies to reviewers for botching Kevin's email address in my 'git send-email' invocation; you may want to double check your To/CC lines before hitting send.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v5 1/6 qemu-io: Add missing option documentation
In reply to Eric BlakeThe Usage: summary is missing several options, but rather than having to maintain it, it's simpler to just state [OPTIONS], since the options are spelled out below.
Commit 499afa2 added --image-opts, but forgot to document it in --help. Likewise for commit 9e8f183 and -d/--discard.
Commit e3aff4f6 put "-o/--offset" in the long opts, but it has never been honored.
Add a note that '-n' is short for '-t none'.
Commit 9a2d77ad killed the -C option, but forgot to undocument it for the 'open' subcommand.
Finally, commit 10d9d75 removed -g/--growable, but forgot to cull it from the valid short options.
---
v5: more improvements
--- qemu-io.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
qemu-io.c +8 -7
@@ -101,7 +101,7 @@ static void open_help(void)" opens a new file in the requested mode\n" "\n" " Example:\n" -" 'open -Cn /tmp/data' - creates/opens data file read-write and uncached\n" +" 'open -n -o driver=raw /tmp/data' - opens raw data file read-write, uncached\n" "\n" " Opens a file for subsequent use by all of the other qemu-io commands.\n" " -r, -- open file read-only\n"
@@ -120,7 +120,7 @@ static const cmdinfo_t open_cmd = { .argmin = 1, .argmax = -1, .flags = CMD_NOFILE_OK, - .args = "[-Crsn] [-o options] [path]", + .args = "[-rsn] [-o options] [path]", .oneline = "open the file specified by path", .help = open_help, };
@@ -144,7 +144,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,"snro:" )) !=-1 ) {switch (c) {case 's' : flags |=BDRV_O_SNAPSHOT ;
@@ -216,20 +216,22 @@ static const cmdinfo_t quit_cmd = {static void usage (const char *name) {printf ( -"Usage: %s [-h] [-V] [-rsnm] [-f FMT] [-c STRING] ... [file]\n" +"Usage: %s [OPTIONS]... [-c STRING]... [file]\n" "QEMU Disk exerciser\n" "\n" " --object OBJECTDEF define an object such as 'secret' for\n" " passwords and/or encryption keys\n" +" --image-opts treat file as option string\n" " -c, --cmd STRING execute command with its arguments\n" " from the given string\n" " -f, --format FMT specifies the block driver to use\n" " -r, --read-only export read-only\n" " -s, --snapshot use snapshot file\n" -" -n, --nocache disable host cache\n" +" -n, --nocache disable host cache, short for -t none\n" " -m, --misalign misalign allocations for O_DIRECT\n" " -k, --native-aio use kernel AIO implementation (on Linux only)\n" " -t, --cache=MODE use the given cache mode for the image\n" +" -d, --discard=MODE use the given discard mode for the image\n" " -T, --trace FILE enable trace events listed in the given file\n" " -h, --help display this help and exit\n" " -V, --version output version information and exit\n"
@@ -410,11 +412,10 @@ static QemuOptsList file_opts = {int main (int argc,char **argv) {int readonly =0 ; -const char *sopt ="hVc:d:f:rsnmgkt:T:" ; +const char *sopt ="hVc:d:f:rsnmkt:T:" ;const struct option lopt[] = { {"help" , no_argument,NULL ,'h' }, {"version" , no_argument,NULL ,'V' }, - {"offset" , required_argument,NULL ,'o' }, {"cmd" , required_argument,NULL ,'c' }, {"format" , required_argument,NULL ,'f' }, {"read-only" , no_argument,NULL ,'r' },
Signature · 1 line
2.5.5
Re: [Qemu-devel] [PATCH v5 1/6] qemu-io: Add missing option documentation
Quoted 18 lines · Eric Blake
The Usage: summary is missing several options, but rather than having to maintain it, it's simpler to just state [OPTIONS], since the options are spelled out below.
Commit 499afa2 added --image-opts, but forgot to document it in --help. Likewise for commit 9e8f183 and -d/--discard.
Commit
e3aff4f6put "-o/--offset" in the long opts, but it has never been honored.Add a note that '-n' is short for '-t none'.
Commit
9a2d77adkilled the -C option, but forgot to undocument it for the 'open' subcommand.Finally, commit 10d9d75 removed -g/--growable, but forgot to cull it from the valid short options.
Quoted 7 lines
Signed-off-by Eric Blake <[email protected]>---
v5: more improvements--- qemu-io.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
Re: [Qemu-devel] [PATCH v5 2/6] qemu-io: Make 'open' subcommand more like command line
In reply to Eric BlakeQuoted 13 lines · Eric Blake
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.
Quoted 8 lines
Signed-off-by Eric Blake <[email protected]>---
v5: was 5/6, move earlier, retitle, and add more options using similar -dMODE rather than new -u--- qemu-io.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)
Quoted 27 lines
qemu-io.c +5
-2@@ -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, };
qemu-io.c static QemuOptsList empty_opts = { · line 143
Quoted 5 lines
qemu-io.c +1
-1@@ -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 ;
I don't think I would have changed the default here, but considering that qemu-io is a debugging tool, it's fine as long as all tests still pass.
(And they do as far as I can tell.)
Quoted 26 lines
qemu-io.c +12
-1int 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' :
qemu-io.c static int open_f(BlockBackend *blk, int argc, char **argv) · line 182
Quoted 10 lines
qemu-io.c +7
-0+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);
Silent fix? :-)
Quoted 4 lines
qemu-io.c +0
-0return 0 ; }if (!qemu_opts_parse_noisily (&empty_opts, optarg, false)) {
Re: [Qemu-devel] [PATCH v5 4/6] qemu-io: Allow unaligned access by default
In reply to Eric BlakeQuoted 9 lines · Eric Blake
There's no reason to require the user to specify a flag just so they can pass in unaligned numbers. Keep 'read -p' and 'write -p' as no-ops so that I don't have to hunt down and update all users of qemu-io, but otherwise make their behavior default as 'read' and 'write'. Also fix 'write -z', 'readv', 'writev', 'writev', '
aio_read', 'aio_write', and 'aio_write-z'. For now, 'read -b', 'write -b', and 'write -c' still require alignment (and 'multiwrite', but that's slated to die soon).
Quoted 7 lines
qemu-iotest 23 is updated to match, as the only test that was previously explicitly expecting an error on an unaligned request.
Signed-off-by Eric Blake <[email protected]>---
v5: use bool operator, drop spurious spaces in .args
If I had realized how many of these spaces there are, I probably wouldn't have asked for it. :-)
Quoted 4 lines
--- qemu-io-cmds.c | 73 +- tests/qemu-iotests/023.out | 2160 +++++++++++++++++++++++++++++--------------- 2 files changed, 1457 insertions(+), 776 deletions(-)
Re: [Qemu-devel] [PATCH v5 5/6] qemu-io: Add 'write -f' to test FUA flag
In reply to Eric BlakeQuoted 8 lines · Eric Blake
Make it easier to test block drivers with
BDRV_REQ_FUAin .supported_write_flags, by adding the '-f' flag to qemu-io to conditionally pass the flag through to specific writes ('write', 'write -z', 'writev', 'aio_write', 'aio_write-z'). You'll want to use 'qemu-io -t none' to actually make -f useful (as otherwise, the default writethrough mode automatically sets the FUA bit on every write).
Quoted 7 lines
Signed-off-by Eric Blake <[email protected]>---
v5: use bool operator--- qemu-io-cmds.c | 57 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 16 deletions(-)
Quoted 11 lines · Eric Blake
Quoted 6 lines · Eric Blake
While working on NBD, I found myself cursing the qemu-io UI for not letting me test various scenarios, particularly after fixing NBD to serve at byte granularity [1]. And in the process of writing these qemu-io enhancements, I also managed to flush out several other bugs in the block layer proper, with fixes posted separately, such as loss of
BDRV_REQ_FUAduringwrite_zeroes[2]Apologies to reviewers for botching Kevin's email address in my 'git send-email' invocation; you may want to double check your To/CC lines before hitting send.
Well, I had even read this heads-up but of course I forgot it by the time I got to reviewing...
So let's at least get a
Series: Reviewed-by: Max Reitz <[email protected]>
here with the correct CC.
Max
Am 09.05.2016 um 20:23 hat Max Reitz geschrieben:
Quoted 13 lines · Eric Blake
Quoted 11 lines · Eric Blake
Quoted 6 lines
While working on NBD, I found myself cursing the qemu-io UI for not letting me test various scenarios, particularly after fixing NBD to serve at byte granularity [1]. And in the process of writing these qemu-io enhancements, I also managed to flush out several other bugs in the block layer proper, with fixes posted separately, such as loss of
BDRV_REQ_FUAduringwrite_zeroes[2]Apologies to reviewers for botching Kevin's email address in my 'git send-email' invocation; you may want to double check your To/CC lines before hitting send.
Quoted 8 lines
Well, I had even read this heads-up but of course I forgot it by the time I got to reviewing...
So let's at least get a
Series: Reviewed-by: Max Reitz <[email protected]>
here with the correct CC.
The only practical problem is that you get some bounced emails. As long as qemu-block is CCed, I'm fine.
Kevin
Max Reitz
AppliedQuoted 46 lines · Eric Blake
While working on NBD, I found myself cursing the qemu-io UI for not letting me test various scenarios, particularly after fixing NBD to serve at byte granularity [1]. And in the process of writing these qemu-io enhancements, I also managed to flush out several other bugs in the block layer proper, with fixes posted separately, such as loss of
BDRV_REQ_FUAduringwrite_zeroes[2]2.7 material, depends on Kevin's block-next:
git://repo.or.cz/qemu/kevin.gitblock-next
and on my pending "block: kill sector-based blk_write/read" v7 or later
https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg00895.htmlPreviously posted as part of a larger v3 NBD series [3] and as a separate v4 [4], so this is v5.
[1] commit
df7b97ff
[2] https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg00285.html
[3] https://lists.gnu.org/archive/html/qemu-devel/2016-04/msg03526.html
[4] https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg00619.htmlAlso available as a tag at this location:
git fetchgit://repo.or.cz/qemu/ericb.gitnbd-qemu-io-v5Changes since then:
- patch 1: add more cleanups (R-b dropped)
- patch 2 (was 5/6) hoist earlier, retitle, use -dMODE instead of inventing -u [mreitz], add -k and -tMODE
- patch 4 (was 3/6) fix bool usage, drop spurious usage space [mreitz]
- patch 5 (was 4/6) fix bool usage [mreitz]
- patch 6 rebase to earlier changes (R-b kept)001/6:[0011] [FC] 'qemu-io: Add missing option documentation' 002/6:[down] 'qemu-io: Make 'open' subcommand more like command line' 003/6:[----] [--] 'qemu-io: Use bool for command line flags' 004/6:[0022] [FC] 'qemu-io: Allow unaligned access by default' 005/6:[0014] [FC] 'qemu-io: Add 'write -f' to test FUA flag' 006/6:[0008] [FC] 'qemu-io: Add 'write -z -u' to test
MAY_UNMAPflag'Eric Blake (6):
qemu-io: Add missing option documentation
qemu-io: Make 'open' subcommand more like command line
qemu-io: Use bool for command line flags
qemu-io: Allow unaligned access by default
qemu-io: Add 'write -f' to test FUA flag
qemu-io: Add 'write -z -u' to testMAY_UNMAPflag
Quoted 4 lines
qemu-io-cmds.c | 228 ++--- qemu-io.c | 40 +- tests/qemu-iotests/023.out | 2160 +++++++++++++++++++++++++++++--------------- 3 files changed, 1587 insertions(+), 841 deletions(-)
Thank you, applied to my block-next branch:
https://github.com/XanClic/qemu/commits/block-next
Max
Re: [Qemu-devel] [PATCH v5 4/6] qemu-io: Allow unaligned access by default
In reply to Eric BlakeAm 08.05.2016 um 05:16 hat Eric Blake geschrieben:
Quoted 9 lines
There's no reason to require the user to specify a flag just so they can pass in unaligned numbers. Keep 'read -p' and 'write -p' as no-ops so that I don't have to hunt down and update all users of qemu-io, but otherwise make their behavior default as 'read' and 'write'. Also fix 'write -z', 'readv', 'writev', 'writev', '
aio_read', 'aio_write', and 'aio_write-z'. For now, 'read -b', 'write -b', and 'write -c' still require alignment (and 'multiwrite', but that's slated to die soon).
Quoted 4 lines
qemu-iotest 23 is updated to match, as the only test that was previously explicitly expecting an error on an unaligned request.
Signed-off-by Eric Blake <[email protected]>
This breaks qemu-iotests 136 for raw. It's pretty obvious that this is a test case problem (uses unaligned requests to test error accounting), so I'm not dropping the patch, but please do send a follow-up.
Maybe negative length and offset work as a replacement.
Kevin
Re: [Qemu-devel] [PATCH v5 4/6] qemu-io: Allow unaligned access by default
Quoted 12 lines · Kevin Wolf
Am 08.05.2016 um 05:16 hat Eric Blake geschrieben:
Quoted 11 lines
There's no reason to require the user to specify a flag just so they can pass in unaligned numbers. Keep 'read -p' and 'write -p' as no-ops so that I don't have to hunt down and update all users of qemu-io, but otherwise make their behavior default as 'read' and 'write'. Also fix 'write -z', 'readv', 'writev', 'writev', '
aio_read', 'aio_write', and 'aio_write-z'. For now, 'read -b', 'write -b', and 'write -c' still require alignment (and 'multiwrite', but that's slated to die soon).qemu-iotest 23 is updated to match, as the only test that was previously explicitly expecting an error on an unaligned request.
I found that one by 'git grep "sector aligned"', and tested with ./check -qcow2...
Quoted 6 lines
Quoted 2 lines
Signed-off-by Eric Blake <[email protected]>This breaks qemu-iotests 136 for raw. It's pretty obvious that this is a test case problem (uses unaligned requests to test error accounting), so I'm not dropping the patch, but please do send a follow-up.
...which explains why I missed this failure with ./check -raw. Will fix, and maybe I should have grepped a bit harder, since it is fairly obvious:
tests/qemu-iotests/136: # Two types of invalid operations:
unaligned length and unaligned offset
I will also check if this needs updating:
tests/qemu-iotests/109: # qemu-img compare can't handle unaligned
file sizes
as both of those tests run under -raw but not -qcow2
Quoted 2 lines
Maybe negative length and offset work as a replacement.
Indeed, since unaligned length and unaligned offset are now explicitly handled by the block layer.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v5 4/6] qemu-io: Allow unaligned access by default
Quoted 8 lines · Eric Blake
Quoted 3 lines
This breaks qemu-iotests 136 for raw. It's pretty obvious that this is a test case problem (uses unaligned requests to test error accounting), so I'm not dropping the patch, but please do send a follow-up.
...which explains why I missed this failure with ./check -raw. Will fix, and maybe I should have grepped a bit harder, since it is fairly obvious:
Quoted 7 lines
tests/qemu-iotests/136: # Two types of invalid operations:
unaligned length and unaligned offsetI will also check if this needs updating:
tests/qemu-iotests/109: # qemu-img compare can't handle unaligned
file sizes
Turns out the comment was stale, even before my recent patches, but I didn't bother bisecting to find when qemu-img learned to handle unaligned raw images. But see my comments in my other mail on the patch for this file: 'qemu-img compare' doesn't necessarily give the nicest of error messages for unaligned files
Quoted 5 lines
as both of those tests run under -raw but not -qcow2
Quoted 2 lines
Maybe negative length and offset work as a replacement.
Sadly, no, because cvtnum() doesn't like things larger than INT64_MAX, so you can't pass in a negative number. I added a new '-i' flag instead; series now available for review.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org