qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Zhang Chen <zhangchen.fnst@cn.fujitsu.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:07:16 +0800	[thread overview]
Message-ID: <573439B4.9040300@redhat.com> (raw)
In-Reply-To: <573423B6.2040602@cn.fujitsu.com>



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?

  reply	other threads:[~2016-05-12  8:07 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 [this message]
2016-05-12  8:23           ` Zhang Chen

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=573439B4.9040300@redhat.com \
    --to=jasowang@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eddie.dong@intel.com \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhangchen.fnst@cn.fujitsu.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).