From: David Gibson <david@gibson.dropbear.id.au>
To: Markus Armbruster <armbru@redhat.com>
Cc: Greg Kurz <groug@kaod.org>,
qemu-devel@nongnu.org, Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH for-2.9 v2] qapi: add explicit null to string input and output visitors
Date: Thu, 15 Dec 2016 21:30:52 +1100 [thread overview]
Message-ID: <20161215103052.GP32647@umbus> (raw)
In-Reply-To: <87zijx34t9.fsf@dusky.pond.sub.org>
[-- Attachment #1: Type: text/plain, Size: 4744 bytes --]
On Thu, Dec 15, 2016 at 10:44:02AM +0100, Markus Armbruster wrote:
> Greg Kurz <groug@kaod.org> writes:
>
> > This may be used for deprecated object properties that are kept for
> > backwards compatibility.
> >
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> > ---
> > v2: - input visitor to reject non-empty strings
> >
> > This is needed for David's patch to work:
> >
> > [RFCv2 10/12] pseries: Move CPU compatibility property to machine
>
> Recommend to insert this patch less the fixup to David's patch before
> David's patch, then squash in the fixup, if it's needed.
That series of mine needs a bunch of rework for several things
including this. It'll probably be a while before I can get back to
that, so don't hold this up on my account.
>
> > Messag-Id: <1479248275-18889-11-git-send-email-david@gibson.dropbear.id.au>
> >
> > Since this v2 changes the behavior to reject non-empty null properties,
> > it is up to getset_compat_deprecated() to ignore the error. The following
> > folded into patch [RFCv2 10/12] does the trick:
> >
> > --- a/target-ppc/translate_init.c
> > +++ b/target-ppc/translate_init.c
> > @@ -8446,7 +8446,7 @@ static void getset_compat_deprecated(Object *obj, Visitor
> > if (!qtest_enabled()) {
> > error_report("CPU 'compat' property is deprecated and has no effect; us
> > }
> > - visit_type_null(v, name, errp);
> > + visit_type_null(v, name, NULL);
>
> Are you sure we want to ignore errors here?
>
> > }
> >
> > static PropertyInfo ppc_compat_deprecated_propinfo = {
> > ---
> > qapi/string-input-visitor.c | 11 +++++++++++
> > qapi/string-output-visitor.c | 14 ++++++++++++++
> > 2 files changed, 25 insertions(+)
> >
> > diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
> > index 8dfa5612522b..9e9d2a1d2865 100644
> > --- a/qapi/string-input-visitor.c
> > +++ b/qapi/string-input-visitor.c
> > @@ -314,6 +314,16 @@ static void parse_type_number(Visitor *v, const char *name, double *obj,
> > *obj = val;
> > }
> >
> > +static void parse_type_null(Visitor *v, const char *name, Error **errp)
> > +{
> > + StringInputVisitor *siv = to_siv(v);
> > +
> > + if (siv->string && siv->string[0]) {
> > + error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
> > + "null");
> > + }
> > +}
>
> When !siv->string, the other parse_type_FOO() generally do
>
> error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
> ... a description of the expected type...);
>
> This one doesn't. Why?
>
> Should the conditional be !siv->string || siv->string[0]?
>
> > +
> > static void parse_optional(Visitor *v, const char *name, bool *present)
> > {
> > StringInputVisitor *siv = to_siv(v);
> > @@ -348,6 +358,7 @@ Visitor *string_input_visitor_new(const char *str)
> > v->visitor.type_bool = parse_type_bool;
> > v->visitor.type_str = parse_type_str;
> > v->visitor.type_number = parse_type_number;
> > + v->visitor.type_null = parse_type_null;
> > v->visitor.start_list = start_list;
> > v->visitor.next_list = next_list;
> > v->visitor.end_list = end_list;
> > diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
> > index 94ac8211d144..5ec5352ca87c 100644
> > --- a/qapi/string-output-visitor.c
> > +++ b/qapi/string-output-visitor.c
> > @@ -266,6 +266,19 @@ static void print_type_number(Visitor *v, const char *name, double *obj,
> > string_output_set(sov, g_strdup_printf("%f", *obj));
> > }
> >
> > +static void print_type_null(Visitor *v, const char *name, Error **errp)
> > +{
> > + StringOutputVisitor *sov = to_sov(v);
> > + char *out;
> > +
> > + if (sov->human) {
> > + out = g_strdup("<null>");
> > + } else {
> > + out = g_strdup("");
> > + }
> > + string_output_set(sov, out);
> > +}
> > +
> > static void
> > start_list(Visitor *v, const char *name, GenericList **list, size_t size,
> > Error **errp)
> > @@ -351,6 +364,7 @@ Visitor *string_output_visitor_new(bool human, char **result)
> > v->visitor.type_bool = print_type_bool;
> > v->visitor.type_str = print_type_str;
> > v->visitor.type_number = print_type_number;
> > + v->visitor.type_null = print_type_null;
> > v->visitor.start_list = start_list;
> > v->visitor.next_list = next_list;
> > v->visitor.end_list = end_list;
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-12-15 12:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-14 17:04 [Qemu-devel] [PATCH for-2.9 v2] qapi: add explicit null to string input and output visitors Greg Kurz
2016-12-15 9:44 ` Markus Armbruster
2016-12-15 10:30 ` David Gibson [this message]
2016-12-15 10:54 ` Greg Kurz
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=20161215103052.GP32647@umbus \
--to=david@gibson.dropbear.id.au \
--cc=armbru@redhat.com \
--cc=groug@kaod.org \
--cc=mdroth@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.