mbox series

[v2,0/2] storage-daemon: include current command line option in the errors

Message ID 20210301152844.291799-1-pbonzini@redhat.com (mailing list archive)
Headers show
Series storage-daemon: include current command line option in the errors | expand

Message

Paolo Bonzini March 1, 2021, 3:28 p.m. UTC
Use the location management facilities that the emulator uses, so that
the current command line option appears in the error message.

Before:

  $ storage-daemon/qemu-storage-daemon --nbd key..=
  qemu-storage-daemon: Invalid parameter 'key..'

After:

  $ storage-daemon/qemu-storage-daemon --nbd key..=
  qemu-storage-daemon: --nbd key..=: Invalid parameter 'key..'

The first patch tweaks the command line parsing so that argv is
not reordered by getopt_long and optind is only advanced by one
option+argument on every call to getopt_long.  This is required
by loc_set_cmdline.

Paolo Bonzini (2):
  storage-daemon: report unexpected arguments on the fly
  storage-daemon: include current command line option in the errors

 storage-daemon/qemu-storage-daemon.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

Comments

Kevin Wolf March 1, 2021, 6:24 p.m. UTC | #1
Am 01.03.2021 um 16:28 hat Paolo Bonzini geschrieben:
> Use the location management facilities that the emulator uses, so that
> the current command line option appears in the error message.
> 
> Before:
> 
>   $ storage-daemon/qemu-storage-daemon --nbd key..=
>   qemu-storage-daemon: Invalid parameter 'key..'
> 
> After:
> 
>   $ storage-daemon/qemu-storage-daemon --nbd key..=
>   qemu-storage-daemon: --nbd key..=: Invalid parameter 'key..'
> 
> The first patch tweaks the command line parsing so that argv is
> not reordered by getopt_long and optind is only advanced by one
> option+argument on every call to getopt_long.  This is required
> by loc_set_cmdline.

Thanks, very useful to know about the "-" switch in getopts.

Applied to the block branch.

Kevin