From: Kevin Wolf <kwolf@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: pbonzini@redhat.com, berrange@redhat.com, qemu-devel@nongnu.org,
eblake@redhat.com, ehabkost@redhat.com
Subject: Re: [RFC PATCH 10/12] qapi: Generate QOM config marshalling code
Date: Fri, 10 Dec 2021 17:50:44 +0100 [thread overview]
Message-ID: <YbOFZOPjGm9JGOj9@redhat.com> (raw)
In-Reply-To: <87h7c3554i.fsf@dusky.pond.sub.org>
Am 23.11.2021 um 15:16 hat Markus Armbruster geschrieben:
> Kevin Wolf <kwolf@redhat.com> writes:
>
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> > backends/rng-random.c | 17 ++------
> > backends/rng.c | 17 ++------
> > scripts/qapi/main.py | 2 +
> > scripts/qapi/qom.py | 91 +++++++++++++++++++++++++++++++++++++++++++
> > qapi/meson.build | 3 ++
> > 5 files changed, 104 insertions(+), 26 deletions(-)
> > create mode 100644 scripts/qapi/qom.py
> >
> > diff --git a/backends/rng-random.c b/backends/rng-random.c
> > index b221308091..35738df3c6 100644
> > --- a/backends/rng-random.c
> > +++ b/backends/rng-random.c
> > @@ -14,6 +14,7 @@
> > #include "sysemu/rng-random.h"
> > #include "sysemu/rng.h"
> > #include "qapi/error.h"
> > +#include "qapi/qapi-qom-qom.h"
> > #include "qapi/visitor.h"
> > #include "qapi/qmp/qerror.h"
> > #include "qemu/main-loop.h"
> > @@ -90,7 +91,8 @@ static char *rng_random_get_filename(Object *obj, Error **errp)
> > return g_strdup(s->filename);
> > }
> >
> > -static bool rng_random_config(Object *obj, const char *filename, Error **errp)
> > +bool qom_rng_random_config(Object *obj, bool has_filename,
> > + const char *filename, Error **errp)
> > {
> > RngRandom *s = RNG_RANDOM(obj);
> >
> > @@ -100,17 +102,6 @@ static bool rng_random_config(Object *obj, const char *filename, Error **errp)
> > return true;
> > }
> >
> > -static bool rng_random_marshal_config(Object *obj, Visitor *v, Error **errp)
> > -{
> > - g_autofree char *filename = NULL;
> > -
> > - if (!visit_type_str(v, "filename", &filename, errp)) {
> > - return false;
> > - }
> > -
> > - return rng_random_config(obj, filename, errp);
> > -}
> > -
>
> Generated replacement:
>
> bool qom_rng_random_marshal_config(Object *obj, Visitor *v, Error **errp)
> {
> q_obj_rng_random_config config = {0};
>
> if (!visit_type_q_obj_rng_random_config_members(v, &config, errp)) {
> return false;
> }
>
> return qom_rng_random_config(obj, config.has_filename, config.filename, errp);
> }
>
> where visit_type_q_obj_rng_random_config_members() is
>
> bool visit_type_q_obj_rng_random_config_members(Visitor *v, q_obj_rng_random_config *obj, Error **errp)
> {
> if (visit_optional(v, "filename", &obj->has_filename)) {
> if (!visit_type_str(v, "filename", &obj->filename, errp)) {
> return false;
> }
> }
> return true;
> }
>
> The handwritten version lacks a visit_optional(), I think.
Yes, this looks like a bug in the handwritten version from patch 5.
The generated version seems to have a bug, too: It doesn't free the
members of @config after calling qom_rng_random_config().
Kevin
next prev parent reply other threads:[~2021-12-10 16:51 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-03 17:29 [RFC PATCH 00/12] QOM/QAPI integration part 1 Kevin Wolf
2021-11-03 17:29 ` [RFC PATCH 01/12] qapi: Add visit_next_struct_member() Kevin Wolf
2021-11-03 17:29 ` [RFC PATCH 02/12] qom: Create object_configure() Kevin Wolf
2021-11-23 15:23 ` Markus Armbruster
2021-12-14 9:52 ` Kevin Wolf
2021-11-03 17:29 ` [RFC PATCH 03/12] qom: Make object_configure() public Kevin Wolf
2021-11-03 17:29 ` [RFC PATCH 04/12] qom: Add instance_config() to TypeInfo Kevin Wolf
2021-11-03 17:29 ` [RFC PATCH 05/12] rng-random: Implement .instance_config Kevin Wolf
2021-11-03 17:29 ` [RFC PATCH 06/12] rng-backend: " Kevin Wolf
2021-11-03 17:29 ` [RFC PATCH 07/12] qapi: Allow defining QOM classes Kevin Wolf
2021-11-23 10:02 ` Markus Armbruster
2021-12-10 17:53 ` Kevin Wolf
2021-11-03 17:29 ` [RFC PATCH 08/12] qapi: Create qom-config:... type for classes Kevin Wolf
2021-11-23 13:00 ` Markus Armbruster
2021-12-10 17:41 ` Kevin Wolf
2021-11-03 17:29 ` [RFC PATCH 09/12] qapi/qom: Convert rng-backend/random to class Kevin Wolf
2021-11-23 13:15 ` Markus Armbruster
2021-12-10 17:57 ` Kevin Wolf
2021-11-03 17:30 ` [RFC PATCH 10/12] qapi: Generate QOM config marshalling code Kevin Wolf
2021-11-23 14:16 ` Markus Armbruster
2021-12-10 16:50 ` Kevin Wolf [this message]
2021-11-03 17:30 ` [RFC PATCH 11/12] qapi/qom: Add class definition for rng-builtin Kevin Wolf
2021-11-03 17:30 ` [RFC PATCH 12/12] qapi/qom: Add class definition for rng-egd Kevin Wolf
2021-11-03 21:26 ` [RFC PATCH 00/12] QOM/QAPI integration part 1 Paolo Bonzini
2021-11-04 9:07 ` Kevin Wolf
2021-11-04 12:39 ` Paolo Bonzini
2021-11-04 14:26 ` Kevin Wolf
2021-11-04 14:49 ` Paolo Bonzini
2021-11-04 15:51 ` Kevin Wolf
2021-11-04 15:52 ` Damien Hedde
2021-11-05 13:55 ` Kevin Wolf
2021-11-23 16:05 ` Markus Armbruster
2021-12-14 10:23 ` Kevin Wolf
2021-12-14 10:40 ` Peter Maydell
2021-12-14 11:52 ` Kevin Wolf
2021-12-14 14:45 ` Markus Armbruster
2021-12-14 16:00 ` Kevin Wolf
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=YbOFZOPjGm9JGOj9@redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.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).