From nobody Sat Oct 25 10:38:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520717657540742.3990187359668; Sat, 10 Mar 2018 13:34:17 -0800 (PST) Received: from localhost ([::1]:52025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eum88-0003Si-Ht for importer@patchew.org; Sat, 10 Mar 2018 16:34:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eulxg-00037N-3b for qemu-devel@nongnu.org; Sat, 10 Mar 2018 16:23:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eulxf-0003Sj-4z for qemu-devel@nongnu.org; Sat, 10 Mar 2018 16:23:28 -0500 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:37779) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eulxe-0003SZ-V3 for qemu-devel@nongnu.org; Sat, 10 Mar 2018 16:23:27 -0500 Received: by mail-pl0-x241.google.com with SMTP id w12-v6so7169350plp.4 for ; Sat, 10 Mar 2018 13:23:26 -0800 (PST) Received: from localhost.localdomain (120.236.201.35.bc.googleusercontent.com. [35.201.236.120]) by smtp.gmail.com with ESMTPSA id q65sm10532191pfd.140.2018.03.10.13.23.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 13:23:24 -0800 (PST) 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=yijnkq2aZJzcfDOsrvzCmN7/fNn/vCG0KxlIi2wD7mQ=; b=EtcHL8sbMhFFFuRH9b0BzoneuesHyZc6jmN6Cgzj+pFx9sSc0D14x/eY85fSmkXL0U +z6H8Sjs2kNzE6zM2yV/7oWTNptq3eqKgQ081bd5XD1KIdHdCGqF9npYJ/EPgwZcbQU8 wP0F0riAAYphZZUMuyEz0gozyC7IdykWSVmjtCDf18Q5QweuNDohCfpbHJZBvrEMXOeD 8jheF7aCzlKqLuZNoZ2KfeLwQhmdkDidlxwD0S00Z9N+BUkH/vEKoRvis3OifSlBIsPw W6nWvqvEm0hanJ6J0UeBw7Bdh88Oy9sbmP040PBzPEtQKEMWa68N93ywGOJnttR51vnU sQtQ== 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=yijnkq2aZJzcfDOsrvzCmN7/fNn/vCG0KxlIi2wD7mQ=; b=KHLiIVwdrsixBBlLpEowl+bhijcK/olzeD39+eZ47b2pQfAmx2RhdP/rACw14MbA/E 1hW9kvkzdHy0NV7C376hhGzfhoehX7/gIeUMPeYUOwvxPlg4AqhAVT5slgx1V6l719rY yvnC8UzD4oY+mI04LKrrSOs2Q4D3pWiwR2pBFLTUGLkVrQizC5Gq148NEPOWST8FyqIp ZBKUE+IDq1+mlyyu7WZ6hcaTeqHMvMJ6C7d+SS5w+4Fpqng6Ztl1qrKtAmP8uizyroZH yV2ZDA/nUJ9KHgEWvohhbJtIs8r+UeSWnc8QI5SipfT1EvGEhOBkolzHTzG83lVRucJg Ob5A== X-Gm-Message-State: AElRT7F/qG81vXEtvxWl84b7YMIkZUQFqvVSq0rvnuu+9l/otbb3s4ea pnfrkEZZdrPXbFqVlwLzdsmNYncT X-Google-Smtp-Source: AG47ELtJD7r0urY1LzA6o2dfIFQ1mbl0gC+7Uc7JSOJQ28VfCQKFbivTy5+YP30Y1fpRaqm1D03iLQ== X-Received: by 2002:a17:902:7598:: with SMTP id j24-v6mr3089083pll.1.1520717005736; Sat, 10 Mar 2018 13:23:25 -0800 (PST) From: Zhang Chen To: qemu-devel@nongnu.org Date: Sun, 11 Mar 2018 05:22:05 +0800 Message-Id: <1520716927-17068-16-git-send-email-zhangckid@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520716927-17068-1-git-send-email-zhangckid@gmail.com> References: <1520716927-17068-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:c01::241 Subject: [Qemu-devel] [PATCH V5 15/17] filter-rewriter: handle checkpoint and failover event 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 , Li Zhijian , Juan Quintela , Jason Wang , "Dr . David Alan Gilbert" , Markus Armbruster , Zhang Chen , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" After one round of checkpoint, the states between PVM and SVM become consistent, so it is unnecessary to adjust the sequence of net packets for old connections, besides, while failover happens, filter-rewriter needs to check if it still needs to adjust sequence of net packets. Signed-off-by: zhanghailiang Signed-off-by: Zhang Chen --- migration/colo.c | 13 +++++++++++++ net/filter-rewriter.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/migration/colo.c b/migration/colo.c index 1633aed..6834f3d 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -30,6 +30,7 @@ #include "block/block.h" #include "qapi/qapi-events-migration.h" #include "sysemu/cpus.h" +#include "net/filter.h" =20 static bool vmstate_loading; static Notifier packets_compare_notifier; @@ -81,6 +82,11 @@ static void secondary_vm_do_failover(void) if (local_err) { error_report_err(local_err); } + /* Notify all filters of all NIC to do checkpoint */ + colo_notify_filters_event(COLO_EVENT_FAILOVER, &local_err); + if (local_err) { + error_report_err(local_err); + } =20 if (!autostart) { error_report("\"-S\" qemu option will be ignored in secondary side= "); @@ -787,6 +793,13 @@ void *colo_process_incoming_thread(void *opaque) goto out; } =20 + /* Notify all filters of all NIC to do checkpoint */ + colo_notify_filters_event(COLO_EVENT_CHECKPOINT, &local_err); + if (local_err) { + qemu_mutex_unlock_iothread(); + goto out; + } + vmstate_loading =3D false; vm_start(); trace_colo_vm_state_change("stop", "run"); diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c index 0909a9a..f3c306c 100644 --- a/net/filter-rewriter.c +++ b/net/filter-rewriter.c @@ -20,6 +20,8 @@ #include "qemu/main-loop.h" #include "qemu/iov.h" #include "net/checksum.h" +#include "net/colo.h" +#include "migration/colo.h" =20 #define FILTER_COLO_REWRITER(obj) \ OBJECT_CHECK(RewriterState, (obj), TYPE_FILTER_REWRITER) @@ -277,6 +279,43 @@ static ssize_t colo_rewriter_receive_iov(NetFilterStat= e *nf, return 0; } =20 +static void reset_seq_offset(gpointer key, gpointer value, gpointer user_d= ata) +{ + Connection *conn =3D (Connection *)value; + + conn->offset =3D 0; +} + +static gboolean offset_is_nonzero(gpointer key, + gpointer value, + gpointer user_data) +{ + Connection *conn =3D (Connection *)value; + + return conn->offset ? true : false; +} + +static void colo_rewriter_handle_event(NetFilterState *nf, int event, + Error **errp) +{ + RewriterState *rs =3D FILTER_COLO_REWRITER(nf); + + switch (event) { + case COLO_EVENT_CHECKPOINT: + g_hash_table_foreach(rs->connection_track_table, + reset_seq_offset, NULL); + break; + case COLO_EVENT_FAILOVER: + if (!g_hash_table_find(rs->connection_track_table, + offset_is_nonzero, NULL)) { + object_property_set_str(OBJECT(nf), "off", "status", errp); + } + break; + default: + break; + } +} + static void colo_rewriter_cleanup(NetFilterState *nf) { RewriterState *s =3D FILTER_COLO_REWRITER(nf); @@ -332,6 +371,7 @@ static void colo_rewriter_class_init(ObjectClass *oc, v= oid *data) nfc->setup =3D colo_rewriter_setup; nfc->cleanup =3D colo_rewriter_cleanup; nfc->receive_iov =3D colo_rewriter_receive_iov; + nfc->handle_event =3D colo_rewriter_handle_event; } =20 static const TypeInfo colo_rewriter_info =3D { --=20 2.7.4