On 07/30/2015 04:50 PM, Jason Wang wrote:


On 07/30/2015 01:50 PM, Yang Hongyang wrote:
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 <yan...@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.

Sorry, could you explain more about this? do you mean to check
the vm state before bh_schedule?

Rethink about this. Looks safe since qemu_can_send_packet() check vmstate.

how to stop&restart a bh? bh_delete bh_new bh_schedule?

qemu_bh_cancel() and qemu_bh_schedule().

Got it, Thank you!


.


--
Thanks,
Yang.

Reply via email to