From patchwork Thu Feb 16 06:00:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 9576541 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E9B0E60244 for ; Thu, 16 Feb 2017 06:03:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC997284F0 for ; Thu, 16 Feb 2017 06:03:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D119C285A2; Thu, 16 Feb 2017 06:03:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 52F14284F0 for ; Thu, 16 Feb 2017 06:03:37 +0000 (UTC) Received: from localhost ([::1]:44719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceFAG-0005Zw-2x for patchwork-qemu-devel@patchwork.kernel.org; Thu, 16 Feb 2017 01:03:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceF7u-0003Dg-2p for qemu-devel@nongnu.org; Thu, 16 Feb 2017 01:01:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceF7t-0003Cd-Ba for qemu-devel@nongnu.org; Thu, 16 Feb 2017 01:01:10 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:14615) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceF7s-0003BN-JM for qemu-devel@nongnu.org; Thu, 16 Feb 2017 01:01:09 -0500 Received: from 172.24.1.136 (EHLO szxeml428-hub.china.huawei.com) ([172.24.1.136]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DZA88896; Thu, 16 Feb 2017 14:00:59 +0800 (CST) Received: from localhost (10.177.24.212) by szxeml428-hub.china.huawei.com (10.82.67.183) with Microsoft SMTP Server id 14.3.235.1; Thu, 16 Feb 2017 14:00:51 +0800 From: zhanghailiang To: , , Date: Thu, 16 Feb 2017 14:00:21 +0800 Message-ID: <1487224821-120916-5-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 2.7.2.windows.1 In-Reply-To: <1487224821-120916-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1487224821-120916-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.24.212] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.58A54020.0160, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: e9d2756a1b6e82bdcead10da042578ba X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 58.251.152.64 Subject: [Qemu-devel] [PATCH v2 4/4] colo-compare: Fix removing fds been watched incorrectly in finalization X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: zhanghailiang , xuquan8@huawei.com, qemu-devel@nongnu.org, pss.wulizhen@huawei.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We will catch the bellow error report while try to delete compare object by qmp command: chardev/char-io.c:91: io_watch_poll_finalize: Assertion `iwp->src == ((void *)0)' failed. This is caused by failing to remove the right fd been watched while call qemu_chr_fe_set_handlers(); Fix it by pass the worker_context parameter to qemu_chr_fe_set_handlers(). Signed-off-by: zhanghailiang --- net/colo-compare.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 37ce75c..a6fc2ff 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -84,6 +84,7 @@ typedef struct CompareState { /* compare thread, a thread for each NIC */ QemuThread thread; + GMainContext *worker_context; GMainLoop *compare_loop; } CompareState; @@ -497,30 +498,29 @@ static gboolean check_old_packet_regular(void *opaque) static void *colo_compare_thread(void *opaque) { - GMainContext *worker_context; CompareState *s = opaque; GSource *timeout_source; - worker_context = g_main_context_new(); + s->worker_context = g_main_context_new(); qemu_chr_fe_set_handlers(&s->chr_pri_in, compare_chr_can_read, - compare_pri_chr_in, NULL, s, worker_context, true); + compare_pri_chr_in, NULL, s, s->worker_context, true); qemu_chr_fe_set_handlers(&s->chr_sec_in, compare_chr_can_read, - compare_sec_chr_in, NULL, s, worker_context, true); + compare_sec_chr_in, NULL, s, s->worker_context, true); - s->compare_loop = g_main_loop_new(worker_context, FALSE); + s->compare_loop = g_main_loop_new(s->worker_context, FALSE); /* To kick any packets that the secondary doesn't match */ timeout_source = g_timeout_source_new(REGULAR_PACKET_CHECK_MS); g_source_set_callback(timeout_source, (GSourceFunc)check_old_packet_regular, s, NULL); - g_source_attach(timeout_source, worker_context); + g_source_attach(timeout_source, s->worker_context); g_main_loop_run(s->compare_loop); g_source_unref(timeout_source); g_main_loop_unref(s->compare_loop); - g_main_context_unref(worker_context); + g_main_context_unref(s->worker_context); return NULL; } @@ -717,8 +717,10 @@ static void colo_compare_finalize(Object *obj) { CompareState *s = COLO_COMPARE(obj); - qemu_chr_fe_deinit(&s->chr_pri_in); - qemu_chr_fe_deinit(&s->chr_sec_in); + qemu_chr_fe_set_handlers(&s->chr_pri_in, NULL, NULL, NULL, NULL, + s->worker_context, true); + qemu_chr_fe_set_handlers(&s->chr_sec_in, NULL, NULL, NULL, NULL, + s->worker_context, true); qemu_chr_fe_deinit(&s->chr_out); g_main_loop_quit(s->compare_loop);