qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: "Daniel P . Berrange" <berrange@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [PATCH 24/26] qom: introduce object_property_help()
Date: Fri, 12 Mar 2021 17:00:22 +0400	[thread overview]
Message-ID: <CAMxuvaysR6kGPd0DAY-ObTiqYHy-+Pu9abqRSDnBuP39o3jSYw@mail.gmail.com> (raw)
In-Reply-To: <c3bbad37-410a-6f6a-c0e0-f0c1ea10e0a4@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3842 bytes --]

Hi

On Fri, Mar 12, 2021 at 4:54 PM Thomas Huth <thuth@redhat.com> wrote:

> On 10/01/2020 16.30, Marc-André Lureau wrote:
> > Let's factor out the code to format a help string for a property. We
> > are going to reuse it in qdev next, which will bring some consistency.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >   include/qom/object.h    | 13 +++++++++++++
> >   qom/object_interfaces.c | 39 +++++++++++++++++++++++----------------
> >   2 files changed, 36 insertions(+), 16 deletions(-)
> >
> > diff --git a/include/qom/object.h b/include/qom/object.h
> > index 933e5c6cb9..a28e37a648 100644
> > --- a/include/qom/object.h
> > +++ b/include/qom/object.h
> > @@ -1854,6 +1854,19 @@ Object *container_get(Object *root, const char
> *path);
> >    */
> >   size_t object_type_get_instance_size(const char *typename);
> >
> > +/**
> > + * object_property_help:
> > + * @name: the name of the property
> > + * @type: the type of the property
> > + * @defval: the default value
> > + * @description: description of the property
> > + *
> > + * Returns: a user-friendly formatted string describing the property
> > + * for help purposes.
> > + */
> > +char *object_property_help(const char *name, const char *type,
> > +                           const char *defval, const char *description);
> > +
> >   G_DEFINE_AUTOPTR_CLEANUP_FUNC(Object, object_unref)
> >
> >   #endif
> > diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
> > index edb4cc4a3d..b7157d6ab0 100644
> > --- a/qom/object_interfaces.c
> > +++ b/qom/object_interfaces.c
> > @@ -158,6 +158,25 @@ int user_creatable_add_opts_foreach(void *opaque,
> QemuOpts *opts, Error **errp)
> >       return 0;
> >   }
> >
> > +char *object_property_help(const char *name, const char *type,
> > +                           const char *defval, const char *description)
> > +{
> > +    GString *str = g_string_new(NULL);
> > +
> > +    g_string_append_printf(str, "  %s=<%s>", name, type);
> > +    if (defval) {
> > +        g_string_append_printf(str, " (default: %s)", defval);
> > +    }
>
>   Hi!
>
> There is something weird going on wit the default value text...
>
> When I run:
>
> $ qemu-system-x86_64 -device isa-fdc,help
>
> I get:
>
> isa-fdc options:
>    bootindexA=<int32>
>    bootindexB=<int32>
>    dma=<uint32>           -  (default: (null))
>    driveA=<str>           - Node name or ID of a block device to use as a
> backend
>    driveB=<str>           - Node name or ID of a block device to use as a
> backend
>    fallback=<FdcDriveType> - FDC drive type, 144/288/120/none/auto
> (default: (null))
>    fdtypeA=<FdcDriveType> - FDC drive type, 144/288/120/none/auto
> (default: (null))
>    fdtypeB=<FdcDriveType> - FDC drive type, 144/288/120/none/auto
> (default: (null))
>    iobase=<uint32>        -  (default: (null))
>    irq=<uint32>           -  (default: (null))
>
> Why is it showing "(null)" as default values?
>

Congratulations, you found a regression! :)

QEMU emulator version 5.2.0 (qemu-5.2.0-6.fc33.1)
qemu-system-x86_64 -device isa-fdc,help
isa-fdc options:
  bootindexA=<int32>
  bootindexB=<int32>
  check_media_rate=<bool> - on/off (default: true)
  dma=<uint32>           -  (default: 2)
  driveA=<str>           - Node name or ID of a block device to use as a
backend
  driveB=<str>           - Node name or ID of a block device to use as a
backend
  fallback=<FdcDriveType> - FDC drive type, 144/288/120/none/auto (default:
"288")
  fdtypeA=<FdcDriveType> - FDC drive type, 144/288/120/none/auto (default:
"auto")
  fdtypeB=<FdcDriveType> - FDC drive type, 144/288/120/none/auto (default:
"auto")
  iobase=<uint32>        -  (default: 1008)
  irq=<uint32>           -  (default: 6)

[-- Attachment #2: Type: text/html, Size: 4949 bytes --]

  reply	other threads:[~2021-03-12 13:02 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10 15:30 [PATCH 00/26] Various qom & qdev enhancements Marc-André Lureau
2020-01-10 15:30 ` [PATCH 01/26] object: add extra sanity checks Marc-André Lureau
2020-01-10 19:18   ` Philippe Mathieu-Daudé
2020-01-10 15:30 ` [PATCH 02/26] qdev: remove duplicated qdev_property_add_static() doc Marc-André Lureau
2020-01-10 15:30 ` [PATCH 03/26] qdev: remove extraneous error Marc-André Lureau
2020-01-10 15:30 ` [PATCH 04/26] qdev: move helper function to monitor/misc Marc-André Lureau
2020-01-10 19:18   ` Philippe Mathieu-Daudé
2020-01-10 15:30 ` [PATCH 05/26] object: avoid extra class property key duplication Marc-André Lureau
2020-01-10 15:30 ` [PATCH 06/26] object: add class property initializer Marc-André Lureau
2020-01-10 15:30 ` [PATCH 07/26] object: add object_property_get_defaut() Marc-André Lureau
2020-01-10 15:30 ` [PATCH 08/26] object: make object_class_property_add* return property Marc-André Lureau
2020-01-10 15:30 ` [PATCH 09/26] qstring: add qstring_free() Marc-André Lureau
2020-01-10 15:30 ` [PATCH 10/26] object: add object_property_set_defaut_{bool, str, int, uint}() Marc-André Lureau
2020-01-23 11:28   ` Paolo Bonzini
2020-01-23 11:39     ` Marc-André Lureau
2020-01-23 14:34       ` Paolo Bonzini
2020-01-10 15:30 ` [PATCH 11/26] object: do not free class properties Marc-André Lureau
2020-01-10 15:30 ` [PATCH 12/26] object: check strong flag with & Marc-André Lureau
2020-01-10 15:30 ` [PATCH 13/26] object: rename link "child" to "target" Marc-André Lureau
2020-01-10 15:30 ` [PATCH 14/26] object: add direct link flag Marc-André Lureau
2020-01-10 15:30 ` [PATCH 15/26] object: express const link with link property Marc-André Lureau
2020-01-10 15:30 ` [PATCH 16/26] object: add object_class_property_add_link() Marc-André Lureau
2020-01-10 15:30 ` [PATCH 17/26] object: release all props Marc-André Lureau
2020-01-10 15:30 ` [PATCH 18/26] object: return self in object_ref() Marc-André Lureau
2020-01-10 19:22   ` Philippe Mathieu-Daudé
2020-01-10 15:30 ` [PATCH 19/26] qdev: set properties with device_class_set_props() Marc-André Lureau
2020-01-23 11:08   ` Paolo Bonzini
2020-01-23 11:11     ` Marc-André Lureau
2020-01-10 15:30 ` [PATCH 20/26] qdev: move instance properties to class properties Marc-André Lureau
2020-01-10 15:30 ` [PATCH 21/26] qdev: register properties as " Marc-André Lureau
2020-01-10 15:30 ` [PATCH 22/26] vl: print default value in object help Marc-André Lureau
2020-01-10 15:30 ` [PATCH 23/26] qom: simplify qmp_device_list_properties() Marc-André Lureau
2020-01-10 15:30 ` [PATCH 24/26] qom: introduce object_property_help() Marc-André Lureau
2021-03-12 12:54   ` Thomas Huth
2021-03-12 13:00     ` Marc-André Lureau [this message]
2020-01-10 15:30 ` [PATCH 25/26] qapi/qmp: add ObjectPropertyInfo.default-value Marc-André Lureau
2020-01-10 15:30 ` [PATCH 26/26] qdev: use object_property_help() Marc-André Lureau
2020-01-10 15:38 ` [PATCH 00/26] Various qom & qdev enhancements Marc-André Lureau
2020-01-20 16:45   ` Stefan Hajnoczi
2020-01-21 16:57   ` Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2019-12-01 11:15 [PATCH 00/26] Make QDev use class properties Marc-André Lureau
2019-12-01 11:15 ` [PATCH 24/26] qom: introduce object_property_help() Marc-André Lureau

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=CAMxuvaysR6kGPd0DAY-ObTiqYHy-+Pu9abqRSDnBuP39o3jSYw@mail.gmail.com \
    --to=marcandre.lureau@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /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).