From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtaHa-0008Gg-Vs for qemu-devel@nongnu.org; Tue, 03 Nov 2015 07:01:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtaHX-0002vc-QX for qemu-devel@nongnu.org; Tue, 03 Nov 2015 07:01:46 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:11585) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtaHP-0002rk-Am for qemu-devel@nongnu.org; Tue, 03 Nov 2015 07:01:43 -0500 From: zhanghailiang Date: Tue, 3 Nov 2015 19:56:55 +0800 Message-ID: <1446551816-15768-38-git-send-email-zhang.zhanghailiang@huawei.com> In-Reply-To: <1446551816-15768-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1446551816-15768-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH COLO-Frame v10 37/38] colo: Use the netfilter to buffer and release packets List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: lizhijian@cn.fujitsu.com, quintela@redhat.com, yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, arei.gonglei@huawei.com, stefanha@redhat.com, amit.shah@redhat.com, zhanghailiang Signed-off-by: zhanghailiang --- v10: Use the new API --- migration/colo.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/migration/colo.c b/migration/colo.c index 36f737a..25335db 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -21,6 +21,8 @@ #include "qapi-event.h" #include "qmp-commands.h" #include "qapi-types.h" +#include "net/filter.h" +#include "net/net.h" /* * The delay time before qemu begin the procedure of default failover treatment. @@ -59,6 +61,24 @@ static bool colo_runstate_is_stopped(void) return runstate_check(RUN_STATE_COLO) || !runstate_is_running(); } +static int colo_init_filter_buffers(void) +{ + Error *local_err = NULL; + + qemu_auto_add_filter_buffer(NET_FILTER_DIRECTION_RX, &local_err); + if (local_err) { + error_report_err(local_err); + return -1; + } + filter_buffer_del_all_timers(); + return 0; +} + +static void colo_cleanup_filter_buffers(void) +{ + qemu_auto_del_filter_buffer(NULL); +} + static void secondary_vm_do_failover(void) { int old_state; @@ -123,6 +143,7 @@ static void primary_vm_do_failover(void) if (s->to_dst_file) { qemu_file_shutdown(s->to_dst_file); } + colo_cleanup_filter_buffers(); vm_start(); @@ -291,6 +312,8 @@ static int colo_do_checkpoint_transaction(MigrationState *s, goto out; } + filter_buffer_release_all(); + if (colo_shutdown) { colo_ctl_put(s->to_dst_file, COLO_COMMAND_GUEST_SHUTDOWN, 0); qemu_fflush(s->to_dst_file); @@ -339,6 +362,12 @@ static void colo_process_checkpoint(MigrationState *s) failover_init_state(); + ret = colo_init_filter_buffers(); + if (ret < 0) { + ret = -EINVAL; + goto out; + } + /* Dup the fd of to_dst_file */ fd = dup(qemu_get_fd(s->to_dst_file)); if (fd == -1) { -- 1.8.3.1