Bug 1656694 - [fast train]'qemu-img resize' should give error info when specifying '--shrink' and '+${size}' simultaneously
Summary: [fast train]'qemu-img resize' should give error info when specifying '--shrin...
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: qemu-kvm
Version: 8.0
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: 8.0
Assignee: Max Reitz
QA Contact: Tingting Mao
Depends On:
TreeView+ depends on / blocked
Reported: 2018-12-06 05:54 UTC by Tingting Mao
Modified: 2020-03-04 16:03 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2019-04-15 18:30:20 UTC
Type: Bug
Target Upstream Version:

Attachments (Terms of Use)

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):

How reproducible:

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

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.


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