From patchwork Sat Aug 11 20:59:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10563543 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E68831390 for ; Sat, 11 Aug 2018 21:01:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D819D29CCD for ; Sat, 11 Aug 2018 21:01:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB28629CD1; Sat, 11 Aug 2018 21:01:41 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 5236129CCD for ; Sat, 11 Aug 2018 21:01:41 +0000 (UTC) Received: from localhost ([::1]:33178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fob12-0005tE-Fj for patchwork-qemu-devel@patchwork.kernel.org; Sat, 11 Aug 2018 17:01:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1foazJ-0004NX-Pk for qemu-devel@nongnu.org; Sat, 11 Aug 2018 16:59:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1foazI-000155-T5 for qemu-devel@nongnu.org; Sat, 11 Aug 2018 16:59:53 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:35824) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1foazI-00014j-Mp for qemu-devel@nongnu.org; Sat, 11 Aug 2018 16:59:52 -0400 Received: by mail-pg1-x52c.google.com with SMTP id w10-v6so5872207pgv.2 for ; Sat, 11 Aug 2018 13:59:52 -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=bpx5nNk4c2i+Qel/d4lL7jT0w+UFVx5G4ipkEW0Rma0=; b=ClZBExym7OBkgvKHO7xIrM0C+y2E0WJki4DPWcQfetTv3G/ETV+Yk+8gSkbBYl9YnH Kp0QMimkC5TkwSBx9Hhv5ymF5IGVNFSynxTdpWBSe8o/gZbosahGTn1p3AKsVUD8FqPI C4VJsG5p/rmdSUwKWu5HhgM/AYTroBtGkQ1RC1hi/AjKcMPrnkKgq1e1MjL5IycEPfU2 pcy9sscECuIolGOFWq+4gSjLZ/8sewbjb6S0o8eMM+EDukyWQq6qNTwn4JN6nH5PSbXg 5HMlT4JeLqZt5V7WviQswoKp4KbLIoxeiuDDqH8RA3VJwFYhyEDE9L+IwaUfapcvl8eU ZkUA== 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=bpx5nNk4c2i+Qel/d4lL7jT0w+UFVx5G4ipkEW0Rma0=; b=EPYbowDj1DlJjkojqkhnFhCb04fqOhs+EoU9F+EwG8BXaTxJcDXngCHXdg71p7Qthv 9okYtdwMVKDKkGg6vwB00Gy9v2X93oOJCPGZ3Juimxp5lBRxRcX99om22A9viISw3wwH IfZeQwnuDESHiRLS1h0Ui4EEHZ4nugis/ax/3e+Glr8Imj5CZXYwmqC/f8ORSPwF5Jng GruWtsN1wKumLmVfOaFTlImGgUBeDBRjKr7mCayjGlmuHkrhMSxxXbAlVLWvHP4gla4o dEtLE35/eqFK1vao6ojqTzw/hL6vsEjTQgyMw8E7ztRIOqmxkpZF15QRIVh8s2L8Y1zk zyLA== X-Gm-Message-State: AOUpUlHNEslKKSdJUxtPPZ1pNB4xAvttmVGLTFZfZaLltCKOko6XkRAL cUWLASolfXTA+Wl1q3jCtNlehsRJ X-Google-Smtp-Source: AA+uWPxHqd4AICH8jcTb+tbnUpJY6rk6WOzOUhuO5q6G3K0355jrjvgvKFcJGWNHthftCkm9DAJYvw== X-Received: by 2002:a62:1d49:: with SMTP id d70-v6mr12760657pfd.101.1534021191258; Sat, 11 Aug 2018 13:59:51 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id h24-v6sm23502641pfk.113.2018.08.11.13.59.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Aug 2018 13:59:50 -0700 (PDT) From: Zhang Chen To: qemu-devel@nongnu.org, Paolo Bonzini , Juan Quintela , "Dr . David Alan Gilbert" , Jason Wang , Eric Blake , Markus Armbruster Date: Sun, 12 Aug 2018 04:59:07 +0800 Message-Id: <20180811205924.4113-4-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180811205924.4113-1-zhangckid@gmail.com> References: <20180811205924.4113-1-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::52c Subject: [Qemu-devel] [PATCH V11 03/20] 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: Zhang Chen , zhanghailiang , Li Zhijian , Zhang Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP It's a good idea to use notifier to notify COLO frame of inconsistent packets comparing. Signed-off-by: Zhang Chen Signed-off-by: Zhang Chen Signed-off-by: zhanghailiang --- net/colo-compare.c | 37 ++++++++++++++++++++++++++----------- net/colo-compare.h | 2 ++ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 80e6532e8b..426eab5973 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 @@ -427,10 +431,7 @@ sec: qemu_hexdump((char *)spkt->data, stderr, "colo-compare spkt", spkt->size); - /* - * colo_compare_inconsistent_notify(); - * TODO: notice to checkpoint(); - */ + colo_compare_inconsistency_notify(); } } @@ -561,8 +562,24 @@ static int colo_old_packet_check_one(Packet *pkt, int64_t *check_time) } } +static void colo_compare_inconsistency_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 +590,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_inconsistency_notify(); return 0; } @@ -620,11 +634,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_inconsistency_notify(); break; } } diff --git a/net/colo-compare.h b/net/colo-compare.h index 1b1ce76aea..22ddd512e2 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 */