diff mbox

[1/1] qemu-img: fix failed autotests

Message ID 1467638208-26198-1-git-send-email-den@openvz.org
State New
Headers show

Commit Message

Denis V. Lunev July 4, 2016, 1:16 p.m. UTC
There are 9 iotests failed on Ubuntu 15.10 at the moment.
The problem is that options parsing in qemu-img is broken by the
following commit:
    commit 10985131e337a0c52c5bd1e191fd7867a6ff8d02
    Author: Denis V. Lunev <den@openvz.org>
    Date:   Fri Jun 17 17:44:13 2016 +0300
    qemu-img: move common options parsing before commands processing

This strange command line reports error
  ./qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- 1024
  qemu-img: Invalid image size specified!
while original code parses it successfully.

The problem is that getopt_long state should be reset. This could be done
using this assignment according to the manual:
    optind = 0

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Eric Blake <eblake@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
---
 qemu-img.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kevin Wolf July 5, 2016, 2:52 p.m. UTC | #1
Am 04.07.2016 um 15:16 hat Denis V. Lunev geschrieben:
> There are 9 iotests failed on Ubuntu 15.10 at the moment.
> The problem is that options parsing in qemu-img is broken by the
> following commit:
>     commit 10985131e337a0c52c5bd1e191fd7867a6ff8d02
>     Author: Denis V. Lunev <den@openvz.org>
>     Date:   Fri Jun 17 17:44:13 2016 +0300
>     qemu-img: move common options parsing before commands processing
> 
> This strange command line reports error
>   ./qemu-img create -f qcow2 TEST_DIR/t.qcow2 -- 1024
>   qemu-img: Invalid image size specified!
> while original code parses it successfully.
> 
> The problem is that getopt_long state should be reset. This could be done
> using this assignment according to the manual:
>     optind = 0
> 
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Eric Blake <eblake@redhat.com>
> CC: Kevin Wolf <kwolf@redhat.com>
> CC: Max Reitz <mreitz@redhat.com>

Thanks, applied to the block branch.

Stefan, don't you run qemu-iotests any more before sending pull
requests?

Kevin
diff mbox

Patch

diff --git a/qemu-img.c b/qemu-img.c
index 3322a1e..2351686 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3866,7 +3866,7 @@  int main(int argc, char **argv)
         return 0;
     }
     argv += optind;
-    optind = 1;
+    optind = 0;
 
     if (!trace_init_backends()) {
         exit(1);