Bug 1523458

Summary: [disk format] The error info is not accurate when resizing image but not specifying size
Product: Red Hat Enterprise Linux 7 Reporter: yilzhang
Component: qemu-kvm-rhevAssignee: Hanna Czenczek <hreitz>
Status: CLOSED ERRATA QA Contact: Tingting Mao <timao>
Severity: low Docs Contact:
Priority: medium    
Version: 7.5CC: chayang, coli, hreitz, juzhang, knoel, michen, mrezanin, ngu, pingl, qzhang, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: qemu-kvm-rhev-2.12.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-11-01 11:04:00 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:
Embargoed:

Description yilzhang 2017-12-08 03:32:19 UTC
Description of problem:
When use "qemu-img resize" to resize one image but not specify size, the error prompted is a bit confusing.

Version-Release number of selected component (if applicable):
qemu-kvm-rhev-2.10.0-11.el7

How reproducible: 100%

Steps to Reproduce:
# qemu-img resize -f raw  test.img 
qemu-img: Expecting one image file name
Try 'qemu-img --help' for more information


Actual results:

Expected results:
The error info should be like "qemu-img: Expecting one image size"


Additional info:

Comment 5 Ping Li 2018-05-09 05:15:06 UTC
Packages tested:
qemu-kvm-rhev-2.12.0-1.el7

Test steps:
1. Check how to use 'qemu-img resize'
# qemu-img --help | grep resize --> According to the result, seems the option "-f fmt" is not a must.
  resize [--object objectdef] [--image-opts] [-q] [--shrink] filename [+ | -]size

2. Create a raw image
# qemu-img create -f raw test.img 1G

3. Test the subcommand resize
Scenario 1 - Don't specify the image file
# qemu-img resize ---> Should report "missing image file"
qemu-img: Not enough arguments 
Try 'qemu-img --help' for more information

# qemu-img resize -f raw ---> Error message is misleading.
                              Should report "missing image file"
qemu-img: missing argument for option '-f' 
Try 'qemu-img --help' for more information

Scenario 2 - Specify the image file, but don't specify the expected image size
# qemu-img resize test.img ---> Error message is different from specifying                                     
                                '-f fmt'
qemu-img: Not enough arguments 
Try 'qemu-img --help' for more information

# qemu-img resize -f raw test.img ---> image file is specified, should report                        
                                       "missing image size"
qemu-img: Expecting image file name and size
Try 'qemu-img --help' for more information

Comment 7 Hanna Czenczek 2018-05-09 14:14:47 UTC
Hi,

1. I thought it would be sufficient to tell the user that both are required and the user can figure out what’s missing.  Figuring out whether the sole argument the user supplied is a valid size and then act on that would not be trivial, so I deemed it not really worth it.
(Also, you could imagine the user wanting to create an image just called “42”.  Now, if we were to differentiate between filename and size, when they invoke “qemu-img create 42”, we would report the filename to be missing, whereas it’s actually the size that is missing.)

2. From a technical perspective, that is because the code path is different.  I interpreted this BZ to be about the fact that the old error message was plainly misleading.  “Not enough arguments” is not misleading.  It’s true and when you do what the error message tells you (use --help), you will know what to do exactly.

3. Or it should just report that you need more arguments.  If it told you to give a filename, then you’d do it, but then it would tell you that not even that is enough, you now need to specify a size as well.
If a user uses qemu-img resize without any arguments, I’d argue they don’t know what they’re doing at all, so we should tell them to try --help (which we do).

4. Probably yes.


All in all, I think it’s better to tell the user to use --help to see exactly how to use qemu-img resize instead of trying to figure out what they may have wanted and then give them small hints that may be wrong.


Max

Comment 8 Hanna Czenczek 2018-05-09 18:09:19 UTC
By the way, John Snow has sent an upstream patch to add -f fmt documentation for resize in the man page: http://lists.nongnu.org/archive/html/qemu-block/2018-05/msg00108.html

Comment 9 Ping Li 2018-05-10 02:25:54 UTC
Thanks Max for the detailed explanation.
According to the comment 5 and comment 7, the bug could be set as verified.
Also, the bug 1576636 was created to track the missed option '-f fmt' for resize.

Comment 11 errata-xmlrpc 2018-11-01 11:04:00 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