From patchwork Mon May 14 03:23:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 912696 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N/3zHME9"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40kqhM43kzz9s02 for ; Mon, 14 May 2018 15:56:35 +1000 (AEST) Received: from localhost ([::1]:35735 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fI6TJ-0000Ic-6p for incoming@patchwork.ozlabs.org; Mon, 14 May 2018 01:56:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fI6Or-0007Ny-Az for qemu-devel@nongnu.org; Mon, 14 May 2018 01:51:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fI461-0007tt-Uh for qemu-devel@nongnu.org; Sun, 13 May 2018 23:24:22 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:42181) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fI461-0007s8-NQ for qemu-devel@nongnu.org; Sun, 13 May 2018 23:24:21 -0400 Received: by mail-pf0-x242.google.com with SMTP id p14-v6so5308071pfh.9 for ; Sun, 13 May 2018 20:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RyVyyiWz6BVrwmCmJeVQGLsDL7nGb6Qbw2cd4DzIUuw=; b=N/3zHME9iV4kBYLEG6u4Y9RPVTrve9SSa9W4LH+RQexMTnv5Kuf/IuwdyY1/kPlQUD n7D/GigZWMnxKJPoFDvPft5IIpfPsN9KISV3mbk1FANwDBtNSPfCwAnfXBl87mFrC/fG FXENlJs/XWR5xtR4lw1auHUPBm57MFi58AgSVdjLBh4BmhlvsQx6gBz1bx7c7BujvlOQ nQWpGVUw8P14+Da65J+uOpSkb29eRaF4cTZwK9BCowBqS73w7keSovag0AEQP3IftMjg inzS79/gHa0GAvYhCvZGKDufa5NqPN+3pbbq7O96xTKbSOvT0lrfOHs69jA4y24zH089 v1VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RyVyyiWz6BVrwmCmJeVQGLsDL7nGb6Qbw2cd4DzIUuw=; b=G3Yd/Y5jIjMVPh2AWgiyraerN1zAm5SXtEviTcP1B5YJN5+xgHEJo1xRx2I9fY8M8C 1msLRybj7Sz+8eHHAOC4MBwKXfb2uLaz71XvuVJ3JRum/k7mjwy/QU9Hzdg9puJJ4Qpv VPN8yC+u3lRO4SIvnyueFAvnurc+DQs5wpynKk3OsPezg2oEGhg6+yL2l8Wgm1ELD7AL atZO6L2jv1cKOK1E6TPgxy5lSWFhNTMn7u7QL4LHSi/ULhsmL5wMhHtcyFAv1QwfjjHE lP3OkCh8i5qWJO/s3eIeuu3ZQLI+Fm1U59w6PExq+n+N1/u0i+S8MdAZi/i1rUqhwazX u07g== X-Gm-Message-State: ALKqPwfg+amFA5NoycXVaYQbJy6e8wAMfSCcO1Qu9rmCFNgdPkTBwpNc kSHR+nUzz1ViX48IaA3Ohill4w== X-Google-Smtp-Source: AB8JxZqsKPQwVC4T7HMwe9QESZ6gSO35sK3zwSmhjdFMQVpGtsVy7PTOCDvc4hvDp/MTy98vIXL/Pg== X-Received: by 2002:a62:48d1:: with SMTP id q78-v6mr8633885pfi.70.1526268260513; Sun, 13 May 2018 20:24:20 -0700 (PDT) Received: from localhost.localdomain (109.227.199.104.bc.googleusercontent.com. [104.199.227.109]) by smtp.gmail.com with ESMTPSA id p6-v6sm17183532pfg.157.2018.05.13.20.24.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 May 2018 20:24:19 -0700 (PDT) From: Zhang Chen To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 11:23:34 +0800 Message-Id: <1526268228-27951-4-git-send-email-zhangckid@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526268228-27951-1-git-send-email-zhangckid@gmail.com> References: <1526268228-27951-1-git-send-email-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH V7 03/17] colo-compare: use notifier to notify packets comparing result 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 , Jason Wang , Markus Armbruster , "Dr . David Alan Gilbert" , Zhang Chen , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" It's a good idea to use notifier to notify COLO frame of inconsistent packets comparing. Signed-off-by: Zhang Chen Signed-off-by: zhanghailiang --- net/colo-compare.c | 32 +++++++++++++++++++++++++------- net/colo-compare.h | 2 ++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 7ff3ae8..05061cd 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -29,6 +29,7 @@ #include "sysemu/iothread.h" #include "net/colo-compare.h" #include "migration/colo.h" +#include "migration/migration.h" #define TYPE_COLO_COMPARE "colo-compare" #define COLO_COMPARE(obj) \ @@ -37,6 +38,9 @@ static QTAILQ_HEAD(, CompareState) net_compares = QTAILQ_HEAD_INITIALIZER(net_compares); +static NotifierList colo_compare_notifiers = + NOTIFIER_LIST_INITIALIZER(colo_compare_notifiers); + #define COMPARE_READ_LEN_MAX NET_BUFSIZE #define MAX_QUEUE_SIZE 1024 @@ -561,8 +565,24 @@ static int colo_old_packet_check_one(Packet *pkt, int64_t *check_time) } } +static void colo_compare_inconsistent_notify(void) +{ + notifier_list_notify(&colo_compare_notifiers, + migrate_get_current()); +} + +void colo_compare_register_notifier(Notifier *notify) +{ + notifier_list_add(&colo_compare_notifiers, notify); +} + +void colo_compare_unregister_notifier(Notifier *notify) +{ + notifier_remove(notify); +} + static int colo_old_packet_check_one_conn(Connection *conn, - void *user_data) + void *user_data) { GList *result = NULL; int64_t check_time = REGULAR_PACKET_CHECK_MS; @@ -573,10 +593,7 @@ static int colo_old_packet_check_one_conn(Connection *conn, if (result) { /* Do checkpoint will flush old packet */ - /* - * TODO: Notify colo frame to do checkpoint. - * colo_compare_inconsistent_notify(); - */ + colo_compare_inconsistent_notify(); return 0; } @@ -620,11 +637,12 @@ static void colo_compare_packet(CompareState *s, Connection *conn, /* * If one packet arrive late, the secondary_list or * primary_list will be empty, so we can't compare it - * until next comparison. + * until next comparison. If the packets in the list are + * timeout, it will trigger a checkpoint request. */ trace_colo_compare_main("packet different"); g_queue_push_head(&conn->primary_list, pkt); - /* TODO: colo_notify_checkpoint();*/ + colo_compare_inconsistent_notify(); break; } } diff --git a/net/colo-compare.h b/net/colo-compare.h index 1b1ce76..22ddd51 100644 --- a/net/colo-compare.h +++ b/net/colo-compare.h @@ -18,5 +18,7 @@ #define QEMU_COLO_COMPARE_H void colo_notify_compares_event(void *opaque, int event, Error **errp); +void colo_compare_register_notifier(Notifier *notify); +void colo_compare_unregister_notifier(Notifier *notify); #endif /* QEMU_COLO_COMPARE_H */