Red Hat Bugzilla – Bug 1383012
qemu-img command should return non-zero error value on fail
Last modified: 2018-03-22 01:13:48 EDT
Description of problem: When rebase an image without backing file to the other image, the operation failed with zero error value returned. Version-Release number of selected component (if applicable): # rpm -qa | grep qemu-kvm-rhev qemu-kvm-rhev-2.6.0-27.el7.x86_64 # uname -r 3.10.0-512.el7.x86_64 How reproducible: 100% Steps to Reproduce: 1. Create image1 and image2 # qemu-img create -f qcow2 image1.qcow2 1G Formatting 'image1.qcow2', fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 # qemu-img create -f qcow2 image2.qcow2 1G Formatting 'image2.qcow2', fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 2. Change the backing file of image2 to image1 and check return code. # qemu-img rebase -f qcow2 -b image1.qcow2 -F qcow2 image2.qcow2 qemu-img: Could not open old backing file '': Could not open image: No such file or directory # echo $? 0 3. Change the backing file of non-existent image3 to image1 and check return code. # qemu-img rebase -f qcow2 -b image1.qcow2 -F qcow2 image3.qcow2 qemu-img: Could not open 'image3.qcow2': Could not open 'image3.qcow2': No such file or directory # echo $? 1 Actual results: zero error value is returned Expected results: non-zero error value is returned Additional info:
Created attachment 1208509 [details] patch to fix unsuccessful qemu-img rebase command return zero exit code root cause is that var 'ret' not be assign non-zero value before go out. attache a patch to fix this defeat. thanks, Xu
kernel and qemu version: # uname -r 3.10.0-541.el7.x86_64 # /usr/libexec/qemu-kvm -version qemu-kvm-rhev-2.8.0-1.el7 verify the issue with below steps: # qemu-img create -f qcow2 image1.qcow2 1G Formatting 'image1.qcow2', fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 # qemu-img create -f qcow2 image2.qcow2 1G Formatting 'image2.qcow2', fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16 # qemu-img rebase -f qcow2 -b image1.qcow2 -F qcow2 image2.qcow2 qemu-img: Could not open old backing file '': Could not open '': No such file or directory # echo $? 1 [root@amd-6168-8-1 verify_bug]# qemu-img rebase -f qcow2 -b image1.qcow2 -F qcow2 image3.qcow2 qemu-img: Could not open 'image3.qcow2': Could not open 'image3.qcow2': No such file or directory [root@amd-6168-8-1 verify_bug]# echo $? 1
According to the comment 4, set the bug as verified.
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/RHSA-2017:2392