qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: QEMU <qemu-devel@nongnu.org>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"Markus Armbruster" <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 10/10] vl: list user creatable propeties if '?' as argument
Date: Thu, 6 Sep 2018 12:05:19 -0500	[thread overview]
Message-ID: <b7d0b369-eac5-dcde-1f6c-c6e005332b12@redhat.com> (raw)
In-Reply-To: <CAJ+F1C+rXupKahjD5rDDfxKKg7iw9z7EhGqyyk=S3x6vVKi+pQ@mail.gmail.com>

On 09/06/2018 11:27 AM, Marc-André Lureau wrote:

> We use name=type (text) for devices properties, ex:
> 
> qemu-system-x86_64 -device tpm-tis,?
> tpm-tis.tpmdev=str (ID of a tpm to use as a backend)
> tpm-tis.irq=uint32
> tpm-tis.tpm-tis-mmio[0]=child<qemu:memory-region>
> 
> But
> qemu-img create -f qcow2 -o ?
> 
>      size             Virtual disk size
>      compat           Compatibility level (0.10 or 1.1)
>      backing_file     File name of a base image
> 
> I think I like more "name=type - text" form I introduced in "improve
> qemu_opts_print_help() output". I guess I should change device
> properties help for consistency then.

I don't have a strong preference for one form over the other, so much as 
consistency in the various applications using the form.


>>> +static gint
>>> +pstrcmp(const char **a, const char **b)
>>> +{
>>> +    return g_strcmp0(*a, *b);
>>> +}
>>
>> This is the second time your series has added this static helper. Should
>> it be a common helper instead?
> 
> as qemu_pstrcmp in cutils? inline in the header?

Does glib not already have such a helper? cutils sounds as good a place 
as any, although inline may be at odds with typically using it as a 
callback function (I don't know how well the compiler and linker handle 
such a situation).

> 
>>
>>
>>> +        g_ptr_array_sort(array, (GCompareFunc)pstrcmp);
>>> +        for (i = 0; i < array->len; i++) {
>>> +            error_printf("%s\n", (char *)array->pdata[i]);
>>> +        }
>>> +        g_ptr_array_set_free_func(array, g_free);
>>> +        g_ptr_array_free(array, true);
>>> +        exit(0);
>>
>> Again, printing to stderr then exiting with status 0 is awkward.  Print
>> to stdout when successfully offering help text.
> 
> We use error_printf() for qdev list (qdev_device_help), which
> redirects to monitor or stderr.
> 
> Should I also change ir for consistency? hopefully nobody relies on
> the output going to stderr...

I don't worry too much about that. We've already fixed other places 
where qemu binaries were antisocial, such as commit ac1307ab fixing 
'qemu-img --help' to give status 0 instead of 1.

In general, when a user asks for help, the help text should go to 
stdout, and the exit status should be 0 (unless you go to great lengths 
to also detect write failures such as ENOSPC or EPIPE, in which case you 
should ALSO attempt to write to stderr prior to exiting with nonzero 
status that you couldn't output the help text - but since FILE* I/O can 
cache things, detecting all possible write errors is not reliable unless 
you check the result of fclose(stdout), which in turn has to be deferred 
to the end of your program execution, generally via atexit().  The extra 
complications and code maintenance for checking for --help output 
failures is something that I'm personally okay with skipping).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

      reply	other threads:[~2018-09-06 17:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06 15:12 [Qemu-devel] [PATCH 00/10] Various qemu command line options help improvements Marc-André Lureau
2018-09-06 15:12 ` [Qemu-devel] [PATCH 01/10] qemu-option: add help fallback to print the list of options Marc-André Lureau
2018-09-06 15:26   ` Eric Blake
2018-09-06 15:12 ` [Qemu-devel] [PATCH 02/10] qemu-option: improve qemu_opts_print_help() output Marc-André Lureau
2018-09-06 15:30   ` Eric Blake
2018-09-06 15:12 ` [Qemu-devel] [PATCH 03/10] qom/object: fix iterating properties over a class Marc-André Lureau
2018-09-06 15:12 ` [Qemu-devel] [PATCH 04/10] qom/object: register 'type' property as class property Marc-André Lureau
2018-09-06 15:12 ` [Qemu-devel] [PATCH 05/10] tests/qom-proplist: check duplicate "bv" property registration failed Marc-André Lureau
2018-09-06 15:12 ` [Qemu-devel] [PATCH 06/10] tests/qom-proplist: check properties are not listed multiple times Marc-André Lureau
2018-09-06 15:12 ` [Qemu-devel] [PATCH 07/10] tests/qom-proplist: check class properties iterator Marc-André Lureau
2018-09-06 15:12 ` [Qemu-devel] [PATCH 08/10] vl: handle -object ? Marc-André Lureau
2018-09-06 15:34   ` Eric Blake
2018-09-06 15:12 ` [Qemu-devel] [PATCH 09/10] hostmem: add some properties description Marc-André Lureau
2018-09-06 15:12 ` [Qemu-devel] [PATCH 10/10] vl: list user creatable propeties if '?' as argument Marc-André Lureau
2018-09-06 15:39   ` Eric Blake
2018-09-06 16:27     ` Marc-André Lureau
2018-09-06 17:05       ` Eric Blake [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b7d0b369-eac5-dcde-1f6c-c6e005332b12@redhat.com \
    --to=eblake@redhat.com \
    --cc=afaerber@suse.de \
    --cc=armbru@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).