qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Yang Hongyang <yanghy@cn.fujitsu.com>, qemu-devel@nongnu.org
Cc: thuth@redhat.com, stefanha@redhat.com,
	zhang.zhanghailiang@huawei.com, mrhines@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH 10/12] netbuffer: add a public api filter_buffer_release_all
Date: Thu, 30 Jul 2015 13:25:15 +0800	[thread overview]
Message-ID: <55B9B53B.8070603@redhat.com> (raw)
In-Reply-To: <1438167116-29270-11-git-send-email-yanghy@cn.fujitsu.com>



On 07/29/2015 06:51 PM, Yang Hongyang wrote:
> add a public api filter_buffer_release_all to release all
> buffered packets.
> also introduce qemu_find_netfilters_by_model to find all buffer
> filters.
>
> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
> ---
>  include/net/filter.h |  5 +++++
>  net/filter-buffer.c  | 41 +++++++++++++++++++++++++++++++++++++++++
>  net/filter.c         | 18 ++++++++++++++++++
>  3 files changed, 64 insertions(+)
>
> diff --git a/include/net/filter.h b/include/net/filter.h
> index 5292563..798b5b2 100644
> --- a/include/net/filter.h
> +++ b/include/net/filter.h
> @@ -50,5 +50,10 @@ NetFilterState *qemu_new_net_filter(NetFilterInfo *info,
>                                      const char *name);
>  void netfilter_add(QemuOpts *opts, Error **errp);
>  void qmp_netfilter_add(QDict *qdict, QObject **ret, Error **errp);
> +int qemu_find_netfilters_by_model(const char *model, NetFilterState **nfs,
> +                                  int max);
> +
> +/* netbuffer filter */
> +void filter_buffer_release_all(void);
>  
>  #endif /* QEMU_NET_FILTER_H */
> diff --git a/net/filter-buffer.c b/net/filter-buffer.c
> index 628e66f..8bac73b 100644
> --- a/net/filter-buffer.c
> +++ b/net/filter-buffer.c
> @@ -11,12 +11,14 @@
>  #include "filters.h"
>  #include "qemu-common.h"
>  #include "qemu/error-report.h"
> +#include "qemu/main-loop.h"
>  
>  typedef struct FILTERBUFFERState {
>      NetFilterState nf;
>      NetClientState dummy; /* used to send buffered packets */
>      NetQueue *incoming_queue;
>      NetQueue *inflight_queue;
> +    QEMUBH *flush_bh;

bh should be stopped and restarted during vm stop and continue.

>  } FILTERBUFFERState;
>  
>  static void packet_send_completed(NetClientState *nc, ssize_t len)
> @@ -56,6 +58,27 @@ static void filter_buffer_flush(NetFilterState *nf)
>      }
>  }
>  
> +static void filter_buffer_flush_bh(void *opaque)
> +{
> +    FILTERBUFFERState *s = opaque;
> +    NetFilterState *nf = &s->nf;
> +    filter_buffer_flush(nf);
> +}
> +
> +static void filter_buffer_release_one(NetFilterState *nf)
> +{
> +    FILTERBUFFERState *s = DO_UPCAST(FILTERBUFFERState, nf, nf);
> +
> +    /* flush inflight packets */
> +    if (s->inflight_queue) {
> +        filter_buffer_flush(nf);
> +    }
> +
> +    s->inflight_queue = s->incoming_queue;
> +    s->incoming_queue = qemu_new_net_queue(nf);
> +    qemu_bh_schedule(s->flush_bh);
> +}
> +
>  /* filter APIs */
>  static ssize_t filter_buffer_receive(NetFilterState *nf,
>                                       NetClientState *sender,
> @@ -93,6 +116,10 @@ static void filter_buffer_cleanup(NetFilterState *nf)
>      s->incoming_queue = NULL;
>      filter_buffer_flush(nf);
>  
> +    if (s->flush_bh) {
> +        qemu_bh_delete(s->flush_bh);
> +        s->flush_bh = NULL;
> +    }
>      return;
>  }
>  
> @@ -122,6 +149,20 @@ int net_init_filter_buffer(const NetFilterOptions *opts, const char *name,
>       */
>      s->dummy.peer = netdev;
>      s->incoming_queue = qemu_new_net_queue(nf);
> +    s->flush_bh = qemu_bh_new(filter_buffer_flush_bh, s);
>  
>      return 0;
>  }
> +
> +/* public APIs */
> +void filter_buffer_release_all(void)
> +{
> +    NetFilterState *nfs[MAX_QUEUE_NUM];
> +    int queues, i;
> +
> +    queues = qemu_find_netfilters_by_model("buffer", nfs, MAX_QUEUE_NUM);
> +
> +    for (i = 0; i < queues; i++) {
> +        filter_buffer_release_one(nfs[i]);
> +    }
> +}

Looks like the function was never used by following patches?

> diff --git a/net/filter.c b/net/filter.c
> index e741e2a..b9a6216 100644
> --- a/net/filter.c
> +++ b/net/filter.c
> @@ -93,6 +93,24 @@ static NetFilterState *qemu_find_netfilter(const char *id)
>      return NULL;
>  }
>  
> +int qemu_find_netfilters_by_model(const char *model, NetFilterState **nfs,
> +                                  int max)
> +{
> +    NetFilterState *nf;
> +    int ret = 0;
> +
> +    QTAILQ_FOREACH(nf, &net_filters, next) {
> +        if (!strcmp(nf->model, model)) {
> +            if (ret < max) {
> +                nfs[ret] = nf;
> +            }
> +            ret++;
> +        }
> +    }
> +
> +    return ret;
> +}
> +
>  static int net_init_filter(void *dummy, QemuOpts *opts, Error **errp);
>  void netfilter_add(QemuOpts *opts, Error **errp)
>  {

  reply	other threads:[~2015-07-30  5:25 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-29 10:51 [Qemu-devel] [PATCH 00/12] For QEMU 2.5: Add a netfilter object and netbuffer filter Yang Hongyang
2015-07-29 10:51 ` [Qemu-devel] [PATCH 01/12] net: add a new object netfilter Yang Hongyang
2015-07-29 13:53   ` Thomas Huth
2015-07-29 14:05     ` Yang Hongyang
2015-07-29 14:20       ` Thomas Huth
2015-07-29 14:32         ` Yang Hongyang
2015-07-29 10:51 ` [Qemu-devel] [PATCH 02/12] init/cleanup of netfilter object Yang Hongyang
2015-07-29 13:33   ` Thomas Huth
2015-07-29 13:50     ` Yang Hongyang
2015-07-29 13:58       ` Thomas Huth
2015-07-29 14:08         ` Yang Hongyang
2015-07-29 10:51 ` [Qemu-devel] [PATCH 03/12] netfilter: add netfilter_{add|del} commands Yang Hongyang
2015-07-29 14:15   ` Thomas Huth
2015-07-29 14:28     ` Yang Hongyang
2015-07-29 14:30       ` Yang Hongyang
2015-07-29 10:51 ` [Qemu-devel] [PATCH 04/12] net: add/remove filters from network backend Yang Hongyang
2015-07-29 10:51 ` [Qemu-devel] [PATCH 05/12] netfilter: hook packets before receive Yang Hongyang
2015-07-30  4:51   ` Jason Wang
2015-07-30  7:22     ` Yang Hongyang
2015-07-29 10:51 ` [Qemu-devel] [PATCH 06/12] netfilter: provide a compat receive_iov Yang Hongyang
2015-07-29 10:51 ` [Qemu-devel] [PATCH 07/12] net/queue: export qemu_net_queue_append Yang Hongyang
2015-07-29 10:51 ` [Qemu-devel] [PATCH 08/12] move out net queue structs define Yang Hongyang
2015-07-29 10:51 ` [Qemu-devel] [PATCH 09/12] netfilter: add a netbuffer filter Yang Hongyang
2015-07-30  1:45   ` Li Zhijian
2015-07-30  1:53     ` Yang Hongyang
2015-07-30  5:13   ` Jason Wang
2015-07-30  6:47     ` Yang Hongyang
2015-07-30  8:40       ` Jason Wang
2015-07-30  9:04         ` Yang Hongyang
2015-07-30  9:33           ` Jason Wang
2015-07-30  9:49             ` Yang Hongyang
2015-07-30 10:14               ` Jason Wang
2015-07-30 10:28                 ` Yang Hongyang
2015-07-30 14:16                   ` Thomas Huth
2015-07-30 15:00                     ` Yang Hongyang
2015-07-30 13:46                 ` Yang Hongyang
2015-07-30  7:00     ` Yang Hongyang
2015-07-30  8:52       ` Jason Wang
2015-07-29 10:51 ` [Qemu-devel] [PATCH 10/12] netbuffer: add a public api filter_buffer_release_all Yang Hongyang
2015-07-30  5:25   ` Jason Wang [this message]
2015-07-30  5:50     ` Yang Hongyang
2015-07-30  8:42       ` Jason Wang
2015-07-30  8:53         ` Yang Hongyang
2015-07-30  8:50       ` Jason Wang
2015-07-30  9:06         ` Yang Hongyang
2015-07-29 10:51 ` [Qemu-devel] [PATCH 11/12] filter/buffer: add an interval option to buffer filter Yang Hongyang
2015-07-30  5:27   ` Jason Wang
2015-07-30  5:37     ` Yang Hongyang
2015-07-30  8:53       ` Jason Wang
2015-07-30  9:12         ` Yang Hongyang
2015-07-29 10:51 ` [Qemu-devel] [PATCH 12/12] filter/buffer: update command description and help Yang Hongyang
2015-07-29 12:56 ` [Qemu-devel] [PATCH 00/12] For QEMU 2.5: Add a netfilter object and netbuffer filter Thomas Huth
2015-07-29 13:39   ` Yang Hongyang
2015-07-29 13:48     ` Thomas Huth

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=55B9B53B.8070603@redhat.com \
    --to=jasowang@redhat.com \
    --cc=mrhines@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    --cc=yanghy@cn.fujitsu.com \
    --cc=zhang.zhanghailiang@huawei.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).