From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
To: Jason Wang <jasowang@redhat.com>, qemu devel <qemu-devel@nongnu.org>
Cc: "eddie . dong" <eddie.dong@intel.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
Li Zhijian <lizhijian@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH] net/net: Add ReadState for reuse codes
Date: Thu, 12 May 2016 16:23:00 +0800 [thread overview]
Message-ID: <57343D64.7070503@cn.fujitsu.com> (raw)
In-Reply-To: <573439B4.9040300@redhat.com>
On 05/12/2016 04:07 PM, Jason Wang wrote:
>
>
> On 2016年05月12日 14:33, Zhang Chen wrote:
>>>>>> + ret = net_fill_rstate(&s->rs, buf, size);
>>>>>> +
>>>>>> + if (ret == -1) {
>>>>>> + goto eoc;
>>>>>> + } else if (ret == 1) {
>>>>>> + if (qemu_send_packet_async(&s->nc, s->rs.buf,
>>>>>> + s->rs.packet_len,
>>>>>> + net_socket_send_completed) == 0) {
>>>>>> + net_socket_read_poll(s, false);
>>>>>
>>>>> This looks not elegant, maybe we could use callback (which was
>>>>> initialized by the helper I mention above) to do this. Any
>>>>> thoughts on this?
>>>>
>>>> Do you mean:
>>>>
>>>> remove
>>>> + if (qemu_send_packet_async(&s->nc, s->rs.buf,
>>>> + s->rs.packet_len,
>>>> + net_socket_send_completed) == 0) {
>>>> + net_socket_read_poll(s, false);
>>>>
>>>> add
>>>>
>>>> s->rs->done
>>>>
>>>> void socket_fill_rsstate_done_cb(SocketReadState *srs, void *opaque)
>>>> {
>>>> NetSocketState *s = opaque;
>>>>
>>>> if (qemu_send_packet_async(&s->nc, srs->buf,
>>>> srs->packet_len,
>>>> net_socket_send_completed) == 0) {
>>>> net_socket_read_poll(s, false);
>>>> }
>>>> }
>>>
>>> Yes, but there's no need for opaque, we can infer the container by
>>> container_of().
>>>
>>
>> But in filter-mirror.c we need do this:
>>
>>
>> void redirector_fill_rsstate_done_cb(SocketReadState *srs, void
>> *opaque)
>> {
>> NetFilterState *nf = opaque;
>>
>> redirector_to_filter(nf, srs->buf, srs->packet_len);
>> }
>>
>> so,I think we have to use void *opaque.
>>
>>
>>
>
> You mean you need to get nf? Since SocketReadState were embedded in
> MirrorState, so you could get the address of MirrorState, then it's
> not hard to get nf address?
>
>
Got it~~
will fix it in next version.
Thanks
Zhang Chen
> .
>
--
Thanks
zhangchen
prev parent reply other threads:[~2016-05-12 8:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-06 10:56 [Qemu-devel] [PATCH] net/net: Add ReadState for reuse codes Zhang Chen
2016-05-10 2:57 ` Li Zhijian
2016-05-10 5:33 ` Zhang Chen
2016-05-11 7:01 ` Zhang Chen
2016-05-11 9:01 ` Jason Wang
2016-05-11 11:20 ` Zhang Chen
2016-05-12 1:11 ` Jason Wang
2016-05-12 6:33 ` Zhang Chen
2016-05-12 8:07 ` Jason Wang
2016-05-12 8:23 ` Zhang Chen [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=57343D64.7070503@cn.fujitsu.com \
--to=zhangchen.fnst@cn.fujitsu.com \
--cc=dgilbert@redhat.com \
--cc=eddie.dong@intel.com \
--cc=jasowang@redhat.com \
--cc=lizhijian@cn.fujitsu.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).