qemu-io: UI enhancements
v4 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"
https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg00557.html
Previously posted as part of a larger NBD series [3] at v3, hence this series starts life at v4.
[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
Also available as a tag at this location:
git fetch git://repo.or.cz/qemu/ericb.git nbd-qemu-io-v4
Changes since then:
More cleanups
Include readv/writev and aio_read/aio_write.
Update qemu-iotests 23 to match new 'write' semantics [kwolf]
001/6:[----] [--] 'qemu-io: Add missing option documentation' 002/6:[down] 'qemu-io: Use bool for command line flags' 003/6:[down] 'qemu-io: Allow unaligned access by default' 004/6:[0056] [FC] 'qemu-io: Add 'write -f' to test FUA flag' 005/6:[----] [--] 'qemu-io: Add 'open -u' to set BDRV_O_UNMAP after the fact' 006/6:[0026] [FC] 'qemu-io: Add 'write -z -u' to test MAY_UNMAP flag'
Eric Blake (6):
qemu-io: Add missing option documentation
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 'open -u' to set BDRV_O_UNMAP after the fact
qemu-io: Add 'write -z -u' to test MAY_UNMAP flag
qemu-io-cmds.c | 222 ++--- qemu-io.c | 12 +- tests/qemu-iotests/023.out | 2160 +++++++++++++++++++++++++++++--------------- 3 files changed, 1562 insertions(+), 832 deletions(-)
Signature · 1 line
2.5.5
PATCH v4 4/6 qemu-io: Add 'write -f' to test FUA flag
Make 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).
--- 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 back-compat\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 back-compat */ 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 v4 2/6 qemu-io: Use bool for command line flags
In reply to Eric BlakeWe require a C99 compiler; let's use it to express what we really mean.
--- 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 v4 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 'qemu-io -d unmap' (or the just-added 'open -u' subcommand).
--- 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 v4 3/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', 'multiwrite', 'write -b', and 'write -c' still require alignment.
qemu-iotest 23 is updated to match, as the only test that was previously explicitly expecting an error on an unaligned request.
--- qemu-io-cmds.c | 63 +- tests/qemu-iotests/023.out | 2160 +++++++++++++++++++++++++++++--------------- 2 files changed, 1452 insertions(+), 771 deletions(-)
qemu-io-cmds.c +12 -51
@@ -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 back-compat\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 back-compat */ 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);
@@ -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 back-compat\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 back-compat */ 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 >1 ) { +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);
@@ -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 ) {
@@ -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 ) {
@@ -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
PATCH v4 1/6 qemu-io: Add missing option documentation
In reply to Eric BlakeCommit 499afa2 added --image-opts, but forgot to document it in --help. Likewise for commit 9e8f183 and -d/--discard.
Finally, commit 10d9d75 removed -g/--growable, but forgot to cull it from the valid short options.
--- qemu-io.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
qemu-io.c +3 -1
@@ -221,6 +221,7 @@ static void usage(const char *name)"\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"
@@ -230,6 +231,7 @@ static void usage(const char *name)" -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,7 +412,7 @@ 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' },
Signature · 1 line
2.5.5
PATCH v4 5/6 qemu-io: Add 'open -u' to set BDRV_O_UNMAP after the fact
In reply to Eric BlakeWhen 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'.
--- qemu-io.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
qemu-io.c +6 -2
@@ -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" );
Signature · 1 line
2.5.5
Re: [Qemu-devel] [PATCH v4 1/6] qemu-io: Add missing option documentation
In reply to Eric BlakeQuoted 10 lines · Eric Blake
Commit 499afa2 added --image-opts, but forgot to document it in --help. Likewise for commit 9e8f183 and -d/--discard.
Finally, commit 10d9d75 removed -g/--growable, but forgot to cull it from the valid short options.
Signed-off-by Eric Blake <[email protected]>--- qemu-io.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Re: [Qemu-devel] [PATCH v4 2/6] qemu-io: Use bool for command line flags
In reply to Eric BlakeQuoted 7 lines · Eric Blake
We require a C99 compiler; let's use it to express what we really mean.
Signed-off-by Eric Blake <[email protected]>--- qemu-io-cmds.c | 94 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 47 insertions(+), 47 deletions(-)
Re: [Qemu-devel] [PATCH v4 3/6] qemu-io: Allow unaligned access by default
In reply to Eric BlakeQuoted 35 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', 'multiwrite', 'write -b', and 'write -c' still require alignment.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]>--- qemu-io-cmds.c | 63 +- tests/qemu-iotests/023.out | 2160 +++++++++++++++++++++++++++++--------------- 2 files changed, 1452 insertions(+), 771 deletions(-)qemu-io-cmds.c +0
-6@@ -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; }
qemu-io-cmds.c static void read_help(void) · line 631
Quoted 5 lines
qemu-io-cmds.c +1
-1@@ -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 back-compat\n"
We're not so close to the 80 character limit here to justify shortening this as much. ;-)
I really wouldn't mind a full "backwards compatibility".
Quoted 74 lines
qemu-io-cmds.c +5
-16" -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 back-compat */ 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);@@ -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 back-compat\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"
qemu-io-cmds.c static const cmdinfo_t write_cmd = { · line 954
Quoted 5 lines
qemu-io-cmds.c +1
-1@@ -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",
Would you mind removing the space after "pattern" along with this change?
Quoted 22 lines
qemu-io-cmds.c +2
-2.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 back-compat */ break ;case 'P' : Pflag = true;
qemu-io-cmds.c static int write_f(BlockBackend *blk, int argc, char **argv) · line 1008
Quoted 6 lines
qemu-io-cmds.c +1
-2@@ -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 >1 ) {
Could you make that "bflag && zflag" instead?
Adding booleans was fine for the meantime between patch 2 and this one, but I'd rather not keep it in the long run.
Max
Quoted 4 lines
qemu-io-cmds.c +1
-0+printf ("-b and -z cannot be specified at the same time\n" );return 0 ; }
Re: [Qemu-devel] [PATCH v4 4/6] qemu-io: Add 'write -f' to test FUA flag
In reply to Eric BlakeQuoted 17 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).Signed-off-by Eric Blake <[email protected]>--- qemu-io-cmds.c | 57 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 16 deletions(-)qemu-io-cmds.c +0
-0
[...]
qemu-io-cmds.c static int write_f(BlockBackend *blk, int argc, char **argv) · line 1021
Quoted 5 lines
qemu-io-cmds.c +1
-0@@ -1010,6 +1018,11 @@ static int write_f(BlockBackend *blk, int argc, char **argv)return 0 ; } +if ((flags &BDRV_REQ_FUA ) && (bflag + cflag)) {
|| would do the same job as +, except it looks nicer.
Although technically correct, I'm very hesitant to give an R-b for boolean arithmetics.
Max
Quoted 7 lines
qemu-io-cmds.c +4
-0+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 ;
Re: [Qemu-devel] [PATCH v4 5/6] qemu-io: Add 'open -u' to set BDRV_O_UNMAP after the fact
In reply to Eric BlakeQuoted 10 lines · Eric Blake
When opening a file from the command line, qemu-io defaults to
BDRV_O_UNMAPbut allows -d to give full control to disable unmaps. But when opening via the 'open' command, qemu-io did not setBDRV_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'.
Quoted 4 lines
Signed-off-by Eric Blake <[email protected]>--- 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:
Re: [Qemu-devel] [PATCH v4 6/6] qemu-io: Add 'write -z -u' to test MAY_UNMAP flag
In reply to Eric BlakeQuoted 10 lines · Eric Blake
Make it easier to control whether the
BDRV_REQ_MAY_UNMAPflag can be passed through awrite_zeroescommand, by adding the '-u' flag to qemu-io 'write -z' and 'aio_write-z'. To be useful, the device has to be opened with 'qemu-io -d unmap' (or the just-added 'open -u' subcommand).Signed-off-by Eric Blake <[email protected]>--- qemu-io-cmds.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
Re: [Qemu-devel] [PATCH v4 3/6] qemu-io: Allow unaligned access by default
In reply to Max ReitzQuoted 13 lines · Max Reitz
Quoted 11 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', 'multiwrite', 'write -b', and 'write -c' still require alignment.qemu-iotest 23 is updated to match, as the only test that was previously explicitly expecting an error on an unaligned request.
Quoted 7 lines
Quoted 2 lines
-" -p, -- allow unaligned access\n"
+" -p, -- ignored for back-compat\n"We're not so close to the 80 character limit here to justify shortening this as much. ;-)
I really wouldn't mind a full "backwards compatibility".
sure, in all affected spots.
Quoted 8 lines
qemu-io-cmds.c static const cmdinfo_t write_cmd = { · line 954
Quoted 6 lines
qemu-io-cmds.c +1
-1@@ -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",Would you mind removing the space after "pattern" along with this change?
Done
Quoted 8 lines
qemu-io-cmds.c static int write_f(BlockBackend *blk, int argc, char **argv) · line 1008
Quoted 3 lines
qemu-io-cmds.c +1
-2-if (bflag + pflag + zflag >1 ) { -printf ("-b, -p, or -z cannot be specified at the same time\n" ); +if (bflag + zflag >1 ) {Could you make that "bflag && zflag" instead?
Adding booleans was fine for the meantime between patch 2 and this one, but I'd rather not keep it in the long run.
Testing that at most one of three booleans is set really needs addition (the same expression using && and || is ugly and long); but you are correct that for just two booleans, && is so much more legible. Will fix.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v4 4/6] qemu-io: Add 'write -f' to test FUA flag
In reply to Max ReitzQuoted 21 lines · Max Reitz
Quoted 17 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).Signed-off-by Eric Blake <[email protected]>--- qemu-io-cmds.c | 57 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 16 deletions(-)qemu-io-cmds.c +0
-0[...]
Quoted 7 lines
qemu-io-cmds.c static int write_f(BlockBackend *blk, int argc, char **argv) · line 1021
Quoted 5 lines
qemu-io-cmds.c +1
-0@@ -1010,6 +1018,11 @@ static int write_f(BlockBackend *blk, int argc, char **argv)return 0 ; } +if ((flags &BDRV_REQ_FUA ) && (bflag + cflag)) {|| would do the same job as +, except it looks nicer.
Holdover from rebasing the s/int/bool/ change earlier in the series. Will fix.
Quoted 3 lines
Although technically correct, I'm very hesitant to give an R-b for boolean arithmetics.
Well-defined by C doesn't mean well-understood :) I'm also more comfortable with boolean operators for boolean variables; and I even know of a recent patch to GNU coreutils due to gcc 7 starting to warn about constructs on bool that look fishy because of promotion-to-int when using non-bool operators.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v4 5/6] qemu-io: Add 'open -u' to set BDRV_O_UNMAP after the fact
In reply to Max ReitzQuoted 11 lines · Max Reitz
Quoted 10 lines · Eric Blake
When opening a file from the command line, qemu-io defaults to
BDRV_O_UNMAPbut allows -d to give full control to disable unmaps. But when opening via the 'open' command, qemu-io did not setBDRV_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'.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Eric Blake <[email protected]>--- 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.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v4 5/6] qemu-io: Add 'open -u' to set BDRV_O_UNMAP after the fact
Quoted 17 lines · Eric Blake
Quoted 16 lines · Max Reitz
Quoted 14 lines · Eric Blake
When opening a file from the command line, qemu-io defaults to
BDRV_O_UNMAPbut allows -d to give full control to disable unmaps. But when opening via the 'open' command, qemu-io did not setBDRV_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 <[email protected]>--- qemu-io.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Quoted 6 lines
Quoted 1 line
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.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org