Bug 1656694

Summary: [fast train]'qemu-img resize' should give error info when specifying '--shrink' and '+${size}' simultaneously
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Tingting Mao <timao>
Component: qemu-kvmAssignee: Max Reitz <mreitz>
qemu-kvm sub component: General QA Contact: Tingting Mao <timao>
Status: CLOSED WONTFIX Docs Contact:
Severity: low    
Priority: low CC: chayang, coli, jen, juzhang, knoel, michen, rbalakri, ribarry, timao, virt-maint
Version: 8.0   
Target Milestone: rc   
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-04-15 18:30:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Tingting Mao 2018-12-06 05:54:25 UTC
Description of problem:
'qemu-img resize' should give error info when specifying '--shrink' and '+${size}' simultaneously.


Version-Release number of selected component (if applicable):
qemu-kvm-3.1.0-0.module+el8+2266+616cf026.next.candidate
kernel-4.18.0-45.el8


How reproducible:
100%


Steps to Reproduce:
1. Create a test image file
# qemu-img create -f qcow2 test.qcow2 1G

2. Resize it.
# qemu-img resize --shrink test.qcow2 +2G
Image resized.

3. Check info of the test image.
# qemu-img info test.qcow2 
image: test.qcow2
file format: qcow2
virtual size: 3.0G (3221225472 bytes)
disk size: 768K
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false


Actual results:
As above.


Expected results:
After step2, qemu-img should give error info like 'could not specifying '--shrink' and '+${size}' simultaneously'.


Additional info:

Comment 3 Max Reitz 2019-04-15 18:30:20 UTC
Hi,

Sorry for the late reply.  I don’t think this is worth fixing.

First, if we make +$size an error, we should make all cases of growing an image together with --shrink an error.
But I don’t think it is useful to do so.  There are valid cases where users might want to specify --shrink when growing an image: Say you have a script and you want to bring an image to a fixed size, regardless of whether it needs to be shrunk or grown.  Then it would be cumbersome to have to query the current image size to know whether to pass --shrink or not.

On the other hand, I don’t think an error message would help the user.  Either they know what they’re doing (i.e. --shink has no effect), or they accidentally grow the image when they meant to shrink it.  In the latter case, nothing bad happens, they can easily shrink the image again.

Max