[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4] qemu-io: Add generic function for reinitiali
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v4] qemu-io: Add generic function for reinitializing optind. |
Date: |
Fri, 18 Jan 2019 09:28:19 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 |
On 1/18/19 4:11 AM, Richard W.M. Jones wrote:
> On FreeBSD 11.2:
>
> $ nbdkit memory size=1M --run './qemu-io -f raw -c "aio_write 0 512" $nbd'
> Parsing error: non-numeric argument, or extraneous/unrecognized suffix --
> aio_write
>
> After main option parsing, we reinitialize optind so we can parse each
> command. However reinitializing optind to 0 does not work on FreeBSD.
> What happens when you do this is optind remains 0 after the option
> This commit introduces an OS-portability function called
> qemu_reset_optind which provides a way of resetting optind that works
> on FreeBSD and platforms that use optreset, while keeping it the same
> as now on other platforms.
>
> Note that the qemu codebase sets optind in many other places, but in
> those other places it's setting a local variable and not using getopt.
> This change is only needed in places where we are using getopt and the
> associated global variable optind.
>
> Signed-off-by: Richard W.M. Jones <address@hidden>
> ---
> configure | 14 ++++++++++++++
> include/qemu/osdep.h | 16 ++++++++++++++++
> qemu-img.c | 2 +-
> qemu-io-cmds.c | 2 +-
> 4 files changed, 32 insertions(+), 2 deletions(-)
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature