Bug 1519617 - The exit code should be non-zero when qemu-io reports an error
Summary: The exit code should be non-zero when qemu-io reports an error
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev
Version: 7.5
Hardware: All
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Max Reitz
QA Contact: Tingting Mao
URL:
Whiteboard:
Depends On: 1518738
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-12-01 03:03 UTC by yilzhang
Modified: 2018-11-01 11:01 UTC (History)
10 users (show)

Fixed In Version: qemu-kvm-rhev-2.12.0-5.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-11-01 11:01:10 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description yilzhang 2017-12-01 03:03:08 UTC
Description of problem:
When qemu-io reports an error, its exit code should be non-zero.

Version-Release number of selected component (if applicable):
Host kernel:   3.10.0-797.el7.ppc64le
qemu-kvm-rhev: qemu-kvm-rhev-2.10.0-8.el7

How reproducible: 100%


Steps to Reproduce:
1. Create a qcow2 image and specify 100M size
# qemu-img create -f qcow2 image.100M  100M

2. Write 1G data to the image, which will fail with error
# qemu-io -c 'write 0 1G'      image.100M
tcmalloc: large alloc 1073741824 bytes == 0x1417a0000 @  0x7fffa7a95fa0 0x7fffa7a99404 0x7fffa7ac8af0 0x115ad4110 0x115ad4198 0x115a34d38 0x115a21de0 0x1159dbd10 0x1159de5b4 0x1159dfe70 0x1159cb318 0x7fffa71c4980 0x7fffa71c4b74
write failed: Input/output error

3. Query the return code of "qemu-io"
# echo $?


Actual results:
# echo $?
0

Expected results:
The exit status of "qemu-io" should be non-zero


Additional info:
PPC and x86 both have this issue
1. PPC:
Host kernel:   3.10.0-797.el7.ppc64le
qemu-kvm-rhev: qemu-kvm-rhev-2.10.0-8.el7

2. x86:
Host kernel:   3.10.0-799.el7.x86_64
qemu-kvm-rhev: qemu-kvm-rhev-2.10.0-9.el7

Comment 2 yilzhang 2017-12-01 03:05:56 UTC
Another reproducer using iSCSI backend image:
1. # qemu-img create -f qcow2    iscsi://10.0.0.7/iqn.2017-08.com.yilzhang:t2/0     500M
2. # qemu-io -c 'write 0 1G'    iscsi://10.0.0.7/iqn.2017-08.com.yilzhang:t2/0 
tcmalloc: large alloc 1073741824 bytes == 0x1419d0000 @  0x7fff99bb5fa0 0x7fff99bb9404 0x7fff99be8af0 0x1041f4110 0x1041f4198 0x104154d38 0x104141de0 0x1040fbd10 0x1040fe5b4 0x1040ffe70 0x1040eb318 0x7fff992e4980 0x7fff992e4b74
iSCSI Failure: SENSE KEY:ILLEGAL_REQUEST(5) ASCQ:LBA_OUT_OF_RANGE(0x2100)
write failed: No space left on device
3. Query the return code of "qemu-io"

Actual result:
# echo $?
0

Comment 3 Gu Nini 2017-12-01 04:36:16 UTC
Yilin,

Please help to append polarion case number into External Trackers part if available.

Thanks,
Nini

Comment 4 yilzhang 2017-12-01 07:52:53 UTC
(In reply to Gu Nini from comment #3)
> Yilin,
> 
> Please help to append polarion case number into External Trackers part if
> available.
> 
> Thanks,
> Nini

Hi Nini,
I checked and I think the test scenario in Polarion is not the same as this BZ, so I removed the keyword "Polarion" from "QA Whiteboard"

Comment 6 Max Reitz 2018-04-28 14:53:01 UTC
Sent an upstream series: http://lists.nongnu.org/archive/html/qemu-block/2018-04/msg00664.html

Comment 8 Miroslav Rezanina 2018-06-25 14:05:38 UTC
Fix included in qemu-kvm-rhev-2.12.0-5.el7

Comment 10 Ping Li 2018-06-27 03:25:09 UTC
Packages tested:
kernel-3.10.0-915.el7
qemu-kvm-rhev-2.12.0-5.el7

Test steps:
1. Create qcow2 image
# qemu-img create -f qcow2 base.qcow2  100M
Formatting 'base.qcow2', fmt=qcow2 size=104857600 cluster_size=65536 lazy_refcounts=off refcount_bits=16

2. Write data into the image and make the size exceed the image size
# qemu-io -c 'write 0 1G' base.qcow2 
tcmalloc: large alloc 1073741824 bytes == 0x5624eb9f2000 @  0x7f4f4bfc935f 0x7f4f4bfe9e90 0x5624ea4e7476 0x5624ea4e74b9 0x5624ea432ae5 0x5624ea435050 0x5624ea435e52 0x5624ea4266ba 0x7f4f49cad3d5 0x5624ea42712c
write failed: Input/output error
# echo $?
1

3. Run case 216 in qemu-iotests
# rpm -ivhf qemu-kvm-rhev-2.12.0-5.el7.src.rpm
# rpmbuild -bp /root/rpmbuild/SPECS/qemu-kvm.spec --nodeps
# cd /root/rpmbuild/BUILD/qemu-2.12.0/
# ./configure
# export QEMU_PROG=/usr/libexec/qemu-kvm
# export QEMU_IMG_PROG=/usr/bin/qemu-img
# export QEMU_IO_PROG=/usr/bin/qemu-io
# export QEMU_NBD_PROG=/usr/bin/qemu-nbd
# cd tests/qemu-iotests
# ./check -qcow2 216
QEMU          -- "/usr/libexec/qemu-kvm" -nodefaults -machine accel=qtest
QEMU_IMG      -- "/usr/bin/qemu-img" 
QEMU_IO       -- "/usr/bin/qemu-io"  --cache writeback -f qcow2
QEMU_NBD      -- "/usr/bin/qemu-nbd" 
IMGFMT        -- qcow2 (compat=1.1)
IMGPROTO      -- file
PLATFORM      -- Linux/x86_64 hp-dl385g7-09 3.10.0-915.el7.x86_64
TEST_DIR      -- /root/rpmbuild/BUILD/qemu-2.12.0/tests/qemu-iotests/scratch
SOCKET_SCM_HELPER -- 

216         [failed, exit status 1] - output mismatch (see 216.out.bad)
--- /root/rpmbuild/BUILD/qemu-2.12.0/tests/qemu-iotests/216.out	2018-06-26 23:02:41.004156997 -0400
+++ /root/rpmbuild/BUILD/qemu-2.12.0/tests/qemu-iotests/216.out.bad	2018-06-26 23:06:29.804383640 -0400
@@ -7,9 +7,12 @@
 
 --- Doing COR ---
 
-{u'return': {}}
-{u'return': u''}
+{u'error': {u'class': u'GenericError', u'desc': u"Driver 'copy-on-read' is not whitelisted"}}
+{u'return': u'Cannot find device= nor node_name=node0\r\n'}
 
 --- Checking COR result ---
 
-Done
+Traceback (most recent call last):
+  File "216", line 113, in <module>
+    assert qemu_io_silent(top_img_path,  '-c', 'read -P 1 0M 1M') == 0
+AssertionError
Failures: 216
Failed 1 of 1 tests

Comment 11 Ping Li 2018-06-27 03:26:05 UTC
(In reply to Ping Li from comment #10)
> Packages tested:
> kernel-3.10.0-915.el7
> qemu-kvm-rhev-2.12.0-5.el7
> 
> Test steps:
> 1. Create qcow2 image
> # qemu-img create -f qcow2 base.qcow2  100M
> Formatting 'base.qcow2', fmt=qcow2 size=104857600 cluster_size=65536
> lazy_refcounts=off refcount_bits=16
> 
> 2. Write data into the image and make the size exceed the image size
> # qemu-io -c 'write 0 1G' base.qcow2 
> tcmalloc: large alloc 1073741824 bytes == 0x5624eb9f2000 @  0x7f4f4bfc935f
> 0x7f4f4bfe9e90 0x5624ea4e7476 0x5624ea4e74b9 0x5624ea432ae5 0x5624ea435050
> 0x5624ea435e52 0x5624ea4266ba 0x7f4f49cad3d5 0x5624ea42712c
> write failed: Input/output error
> # echo $?
> 1
> 
> 3. Run case 216 in qemu-iotests
> # rpm -ivhf qemu-kvm-rhev-2.12.0-5.el7.src.rpm
> # rpmbuild -bp /root/rpmbuild/SPECS/qemu-kvm.spec --nodeps
> # cd /root/rpmbuild/BUILD/qemu-2.12.0/
> # ./configure
> # export QEMU_PROG=/usr/libexec/qemu-kvm
> # export QEMU_IMG_PROG=/usr/bin/qemu-img
> # export QEMU_IO_PROG=/usr/bin/qemu-io
> # export QEMU_NBD_PROG=/usr/bin/qemu-nbd
> # cd tests/qemu-iotests
> # ./check -qcow2 216
> QEMU          -- "/usr/libexec/qemu-kvm" -nodefaults -machine accel=qtest
> QEMU_IMG      -- "/usr/bin/qemu-img" 
> QEMU_IO       -- "/usr/bin/qemu-io"  --cache writeback -f qcow2
> QEMU_NBD      -- "/usr/bin/qemu-nbd" 
> IMGFMT        -- qcow2 (compat=1.1)
> IMGPROTO      -- file
> PLATFORM      -- Linux/x86_64 hp-dl385g7-09 3.10.0-915.el7.x86_64
> TEST_DIR      -- /root/rpmbuild/BUILD/qemu-2.12.0/tests/qemu-iotests/scratch
> SOCKET_SCM_HELPER -- 
> 
> 216         [failed, exit status 1] - output mismatch (see 216.out.bad)
> --- /root/rpmbuild/BUILD/qemu-2.12.0/tests/qemu-iotests/216.out	2018-06-26
> 23:02:41.004156997 -0400
> +++ /root/rpmbuild/BUILD/qemu-2.12.0/tests/qemu-iotests/216.out.bad
> 2018-06-26 23:06:29.804383640 -0400
> @@ -7,9 +7,12 @@
>  
>  --- Doing COR ---
>  
> -{u'return': {}}
> -{u'return': u''}
> +{u'error': {u'class': u'GenericError', u'desc': u"Driver 'copy-on-read' is
> not whitelisted"}}
> +{u'return': u'Cannot find device= nor node_name=node0\r\n'}
>  
>  --- Checking COR result ---
>  
> -Done
> +Traceback (most recent call last):
> +  File "216", line 113, in <module>
> +    assert qemu_io_silent(top_img_path,  '-c', 'read -P 1 0M 1M') == 0
> +AssertionError
> Failures: 216
> Failed 1 of 1 tests

Hi Max,

Could you help to check why case 216 is failed? Thanks

Comment 12 Max Reitz 2018-06-28 00:24:40 UTC
Hi,

That test failed because I forgot to whitelist the copy-on-read driver, which is an issue for BZ 1518738.  (Sorry.)

I think that's pretty much irrelevant for this BZ here for now.  As long as you can see that qemu-io returns an exit code of 1 when an error occurred, that should be enough.

Max

Comment 13 Ping Li 2018-06-28 01:13:50 UTC
(In reply to Max Reitz from comment #12)
> Hi,
> 
> That test failed because I forgot to whitelist the copy-on-read driver,
> which is an issue for BZ 1518738.  (Sorry.)
> 
> I think that's pretty much irrelevant for this BZ here for now.  As long as
> you can see that qemu-io returns an exit code of 1 when an error occurred,
Yes, I do agree that this bug itself has been already fixed.
However, iotest 216 was created by the patch series for this bug. IMO, the prerequisite for verifying this bug is that both the issue itself has been solved and no new issues were introduced by the fix.
> that should be enough.
> 
> Max

Comment 14 Ping Li 2018-06-28 01:16:59 UTC
Thanks Max.

Based on the comment 10 and comment 12, the bug itself has been solved. Set the bug as verified.
Also, bug 1518738 and bug 1594747 will be used to track the issue for iotest 216.

Comment 16 errata-xmlrpc 2018-11-01 11:01:10 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3443


Note You need to log in before you can comment on or make changes to this bug.