qemu-iotests: fix pattern for write test
PATCH 1/1 qemu-iotests: fix pattern for write test
The write pattern value 0axb is invalid and evaluates to 0, so the read check (which uses a correct value of 0xab) will fail.
This failure will only be detected with a separate patch for qemu-io. Without it, qemu-io cannot interpret hex values and always uses a pattern value of 0.
--- 002 | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
002 +1 -1
@@ -61,7 +61,7 @@ $QEMU_IO -c "read -pP 0xa 0 $size" $TEST_IMG | _filter_qemu_io echo echo "unaligned pwrite" -$QEMU_IO -c 'write -pP 0axb 66 42' $TEST_IMG | _filter_qemu_io +$QEMU_IO -c 'write -pP 0xab 66 42' $TEST_IMG | _filter_qemu_io echo echo "verify pattern"
Signature · 1 line
1.5.6.5
PATCH 1/1 qemu-io: Fix parsing of pattern arguments
atoi won't parse sedecimal pattern values (it always returns 0). The qemu-iotests use such pattern values, to strtol is needed to get correct results.
--- qemu-io.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
qemu-io.c +6 -6
@@ -286,7 +286,7 @@ read_f(int argc, char **argv)break ;case 'P' : Pflag =1 ; - pattern =atoi (optarg); + pattern =strtol (optarg,NULL ,0 );break ;case 'q' : qflag =1 ;
@@ -444,7 +444,7 @@ readv_f(int argc, char **argv)break ;case 'P' : Pflag =1 ; - pattern =atoi (optarg); + pattern =strtol (optarg,NULL ,0 );break ;case 'q' : qflag =1 ;
@@ -565,7 +565,7 @@ write_f(int argc, char **argv) pflag =1 ;break ;case 'P' : - pattern =atoi (optarg); + pattern =strtol (optarg,NULL ,0 );break ;case 'q' : qflag =1 ;
@@ -685,7 +685,7 @@ writev_f(int argc, char **argv) qflag =1 ;break ;case 'P' : - pattern =atoi (optarg); + pattern =strtol (optarg,NULL ,0 );break ;default :return command_usage (&writev_cmd);
@@ -859,7 +859,7 @@ aio_read_f(int argc, char **argv)break ;case 'P' : ctx->Pflag =1 ; - ctx->pattern =atoi (optarg); + ctx->pattern =strtol (optarg,NULL ,0 );break ;case 'q' : ctx->qflag =1 ;
@@ -959,7 +959,7 @@ aio_write_f(int argc, char **argv) ctx->qflag =1 ;break ;case 'P' : - pattern =atoi (optarg); + pattern =strtol (optarg,NULL ,0 );break ;default :free (ctx);
Signature · 1 line
1.5.6.5
Re: [Qemu-devel] [PATCH] qemu-io: Fix parsing of pattern arguments
Quoted 3 lines · Stefan Weil
atoi won't parse sedecimal pattern values (it always returns 0). The qemu-iotests use such pattern values, to strtol is needed to get correct results.
Indeed. But now that we're using strtol which can return useful errors I think we should also handle those errors. Can you respin the patch with that error handling added?
Re: [Qemu-devel] [PATCH] qemu-io: Fix parsing of pattern arguments
Quoted 10 lines · Christoph Hellwig
Quoted 4 lines · Stefan Weil
atoi won't parse sedecimal pattern values (it always returns 0). The qemu-iotests use such pattern values, to strtol is needed to get correct results.
Indeed. But now that we're using strtol which can return useful errors I think we should also handle those errors. Can you respin the patch with that error handling added?
Yes, but I'll finish the vdi driver first, so an improved patch will have to wait a little.
I'd prefer to see the current version of the patch applied as first step.
Regards,
Stefan
Quoted 6 lines · Stefan Weil
The write pattern value 0axb is invalid and evaluates to 0, so the read check (which uses a correct value of
0xab) will fail.This failure will only be detected with a separate patch for qemu-io. Without it, qemu-io cannot interpret hex values and always uses a pattern value of 0.
Thanks a lot, I've put this patch in.