[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC v5 05/26] qjson: add "opaque" field to JSONMessage
From: |
Peter Xu |
Subject: |
Re: [Qemu-devel] [RFC v5 05/26] qjson: add "opaque" field to JSONMessageParser |
Date: |
Sat, 16 Dec 2017 11:28:40 +0800 |
User-agent: |
Mutt/1.9.1 (2017-09-22) |
On Fri, Dec 15, 2017 at 12:45:24PM +0000, Stefan Hajnoczi wrote:
> On Fri, Dec 15, 2017 at 03:55:06PM +0800, Peter Xu wrote:
> > On Wed, Dec 13, 2017 at 03:37:02PM +0000, Stefan Hajnoczi wrote:
> > > On Tue, Dec 05, 2017 at 01:51:39PM +0800, Peter Xu wrote:
> > > > diff --git a/qga/main.c b/qga/main.c
> > > > index 62a62755bd..3b5ebbc1ee 100644
> > > > --- a/qga/main.c
> > > > +++ b/qga/main.c
> > > > @@ -593,7 +593,8 @@ static void process_command(GAState *s, QDict *req)
> > > > }
> > > >
> > > > /* handle requests/control events coming in over the channel */
> > > > -static void process_event(JSONMessageParser *parser, GQueue *tokens)
> > > > +static void process_event(JSONMessageParser *parser, GQueue *tokens,
> > > > + void *opaque)
> > > > {
> > > > GAState *s = container_of(parser, GAState, parser);
> > > > QDict *qdict;
> > > > @@ -1320,7 +1321,7 @@ static int run_agent(GAState *s, GAConfig
> > > > *config, int socket_activation)
> > > > s->command_state = ga_command_state_new();
> > > > ga_command_state_init(s, s->command_state);
> > > > ga_command_state_init_all(s->command_state);
> > > > - json_message_parser_init(&s->parser, process_event);
> > > > + json_message_parser_init(&s->parser, process_event, NULL);
> > >
> > > This patch leaves the code with 2 ways of getting at state from the
> > > parser pointer:
> > > 1. Use container_of() like existing users.
> > > 2. Use the new (unused) opaque argument.
> > >
> > > Given that #1 exists, is this patch really necessary?
> >
> > I didn't really notice that. Thanks for pointing out.
> >
> > However even if so I would still prefer the opaque way to do it if
> > asked. Existing #1 of course works but IMHO is less flexible and has
> > dependency between structure layouts.
> >
> > How about I append another patch to convert existing users (or, I can
> > post as separate patches after this series)? It's not really a lot,
> > and the conversion would be obvious:
> >
> > *** qga/main.c:
> > run_agent[1324] json_message_parser_init(&s->parser,
> > process_event, NULL);
> > *** qobject/qjson.c:
> > qobject_from_jsonv[45] json_message_parser_init(&state.parser,
> > parse_json, NULL);
> > *** tests/libqtest.c:
> > qmp_fd_receive[438] json_message_parser_init(&qmp.parser,
> > qmp_response, NULL);
> >
> > Though, if you still insist, I can drop it too.
>
> I prefer dropping it. Smaller patch series get reviewed quicker, cause
> fewer merge conflicts, are lower risk, etc.
Will do. Thanks,
--
Peter Xu
- [Qemu-devel] [RFC v5 02/26] qobject: introduce qobject_get_try_str(), (continued)
[Qemu-devel] [RFC v5 06/26] monitor: move the cur_mon hack deeper for QMP, Peter Xu, 2017/12/05
[Qemu-devel] [RFC v5 07/26] monitor: unify global init, Peter Xu, 2017/12/05
- Re: [Qemu-devel] [RFC v5 07/26] monitor: unify global init, Stefan Hajnoczi, 2017/12/13
- Re: [Qemu-devel] [RFC v5 07/26] monitor: unify global init, Peter Xu, 2017/12/15
- Re: [Qemu-devel] [RFC v5 07/26] monitor: unify global init, Stefan Hajnoczi, 2017/12/15
- Re: [Qemu-devel] [RFC v5 07/26] monitor: unify global init, Peter Xu, 2017/12/15
- Re: [Qemu-devel] [RFC v5 07/26] monitor: unify global init, Stefan Hajnoczi, 2017/12/16
- Re: [Qemu-devel] [RFC v5 07/26] monitor: unify global init, Peter Xu, 2017/12/17