From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKgjX-0000gp-8f for qemu-devel@nongnu.org; Thu, 30 Jul 2015 01:50:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZKgjT-0004rY-Rz for qemu-devel@nongnu.org; Thu, 30 Jul 2015 01:50:23 -0400 Received: from [59.151.112.132] (port=32281 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKgjS-0004q8-SR for qemu-devel@nongnu.org; Thu, 30 Jul 2015 01:50:19 -0400 Message-ID: <55B9BB13.1010601@cn.fujitsu.com> Date: Thu, 30 Jul 2015 13:50:11 +0800 From: Yang Hongyang MIME-Version: 1.0 References: <1438167116-29270-1-git-send-email-yanghy@cn.fujitsu.com> <1438167116-29270-11-git-send-email-yanghy@cn.fujitsu.com> <55B9B53B.8070603@redhat.com> In-Reply-To: <55B9B53B.8070603@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 10/12] netbuffer: add a public api filter_buffer_release_all List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang , qemu-devel@nongnu.org Cc: thuth@redhat.com, stefanha@redhat.com, zhang.zhanghailiang@huawei.com, mrhines@linux.vnet.ibm.com On 07/30/2015 01:25 PM, Jason Wang wrote: > > > 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 >> --- >> 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. Sorry, could you explain more about this? do you mean to check the vm state before bh_schedule? how to stop&restart a bh? bh_delete bh_new bh_schedule? > >> } 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; [...] >> + >> +/* 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? Right, it's not used in this series. But it can be used by MC to release packets at checkpoint, Should I mark this unused, or drop this API? > >> 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) >> { > > . > -- Thanks, Yang.