From nobody Wed Nov 5 02:29:55 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 1532288717533479.38219559176935; Sun, 22 Jul 2018 12:45:17 -0700 (PDT) Received: from localhost ([::1]:57263 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhKI8-0002Sv-Ep for importer@patchew.org; Sun, 22 Jul 2018 15:45:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhK8r-0003LK-0y for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhK8p-00011n-UA for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:41 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:32976) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhK8p-00011X-O7 for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:39 -0400 Received: by mail-pg1-x529.google.com with SMTP id r5-v6so10658752pgv.0 for ; Sun, 22 Jul 2018 12:35:39 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id 87-v6sm14215353pfn.103.2018.07.22.12.35.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jul 2018 12:35:37 -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=CfEoMIqL7qqiMO3dLjhS4on0yvtvChay14/KE6chgvY=; b=ZDkAH6meq2PfurVWTB7c8uFNCeM619N+s0+AiA5pVs/WWIP2EKhpkzzVxey1+0H6Su myLCJLnZ7lN+ceUTO8aUJmJxKF/XZXALTJiS6sSD5r68TwOO1+J0NMPTTZ/MQqqJ7sTM 7gmhxBBCj8tKXYwbSyBrewWXTQz4lINQEJizrQX7ZHaI58cRFfTB5ccm63WlqOJICOsg R55EbRX4HqVKDVW3nRDzeiHe7v/840cT24OLmIeqx+Pi4Ftdd13YDk/UGZCzvK5tMUiX 0mlTXiOEyunoO//Eh6uCgiUJDd31yfrmKA7Seayw4Y2FnIe0pdAQylH9xqwh/TARDm6P WATQ== 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=CfEoMIqL7qqiMO3dLjhS4on0yvtvChay14/KE6chgvY=; b=p47HsgWELkVlrmBtk7Uv3oqyfGuEFh7CjUugnUu13c3XSoVl6k8NIYMSzvXeYTiOMf 8x6JDEEVS/VuwfDGEWj5g4h4QpWx0QvUueSr7TuOkifat7Y0wlXbnQXr5ubo02Bmm3b5 ZQGpHJHHyCf56ZfiroUWTesf174UsT6pSMIyob0J8Aha1sOg7pR3eA2/trHg/Iyk+fYD 0NU8bLxErTKB0d8iP/c0F1elbRmNELs+iWJThg55lMafcwci+uwBuxDSDklNUYdxH+f9 BuCHUIulM4HVf5OGbd1S2bt/k+t0r/ZW4ygu3Ghv+x9IT5TMCpILTZTnTcb/Zh/tFmxL F0FA== X-Gm-Message-State: AOUpUlHSW1dbuUIN1bd2ujAU2kYd/prBgxnOV1TxXlwmJ4m0/IoSZpGk AOJtFzDRtzEjhex4wcs4aMhtSUvo X-Google-Smtp-Source: AAOMgpcFmIyNla/VrJJSKuk49bKjukX/C0MkZd4MNqhtyGBK/LOD6QeiJu+a8ypBBGsT7fJzStihTQ== X-Received: by 2002:a63:5143:: with SMTP id r3-v6mr9792523pgl.11.1532288138546; Sun, 22 Jul 2018 12:35:38 -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: Mon, 23 Jul 2018 03:33:46 +0800 Message-Id: <20180722193350.6028-17-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180722193350.6028-1-zhangckid@gmail.com> References: <20180722193350.6028-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::529 Subject: [Qemu-devel] [PATCH V10 16/20] filter: Add handle_event method for NetFilterClass 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 , Zhang Chen 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" Filter needs to process the event of checkpoint/failover or other event passed by COLO frame. Signed-off-by: zhanghailiang --- include/net/filter.h | 5 +++++ net/filter.c | 17 +++++++++++++++++ net/net.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/include/net/filter.h b/include/net/filter.h index 435acd6f82..49da666ac0 100644 --- a/include/net/filter.h +++ b/include/net/filter.h @@ -38,6 +38,8 @@ typedef ssize_t (FilterReceiveIOV)(NetFilterState *nc, =20 typedef void (FilterStatusChanged) (NetFilterState *nf, Error **errp); =20 +typedef void (FilterHandleEvent) (NetFilterState *nf, int event, Error **e= rrp); + typedef struct NetFilterClass { ObjectClass parent_class; =20 @@ -45,6 +47,7 @@ typedef struct NetFilterClass { FilterSetup *setup; FilterCleanup *cleanup; FilterStatusChanged *status_changed; + FilterHandleEvent *handle_event; /* mandatory */ FilterReceiveIOV *receive_iov; } NetFilterClass; @@ -77,4 +80,6 @@ ssize_t qemu_netfilter_pass_to_next(NetClientState *sende= r, int iovcnt, void *opaque); =20 +void colo_notify_filters_event(int event, Error **errp); + #endif /* QEMU_NET_FILTER_H */ diff --git a/net/filter.c b/net/filter.c index 2fd7d7d663..0f17eba143 100644 --- a/net/filter.c +++ b/net/filter.c @@ -17,6 +17,8 @@ #include "net/vhost_net.h" #include "qom/object_interfaces.h" #include "qemu/iov.h" +#include "net/colo.h" +#include "migration/colo.h" =20 static inline bool qemu_can_skip_netfilter(NetFilterState *nf) { @@ -245,11 +247,26 @@ static void netfilter_finalize(Object *obj) g_free(nf->netdev_id); } =20 +static void dummy_handle_event(NetFilterState *nf, int event, Error **errp) +{ + switch (event) { + case COLO_EVENT_CHECKPOINT: + break; + case COLO_EVENT_FAILOVER: + object_property_set_str(OBJECT(nf), "off", "status", errp); + break; + default: + break; + } +} + static void netfilter_class_init(ObjectClass *oc, void *data) { UserCreatableClass *ucc =3D USER_CREATABLE_CLASS(oc); + NetFilterClass *nfc =3D NETFILTER_CLASS(oc); =20 ucc->complete =3D netfilter_complete; + nfc->handle_event =3D dummy_handle_event; } =20 static const TypeInfo netfilter_info =3D { diff --git a/net/net.c b/net/net.c index a77ea88fff..b4f6a2efb2 100644 --- a/net/net.c +++ b/net/net.c @@ -1331,6 +1331,34 @@ void hmp_info_network(Monitor *mon, const QDict *qdi= ct) } } =20 +void colo_notify_filters_event(int event, Error **errp) +{ + NetClientState *nc, *peer; + NetClientDriver type; + NetFilterState *nf; + NetFilterClass *nfc =3D NULL; + Error *local_err =3D NULL; + + QTAILQ_FOREACH(nc, &net_clients, next) { + peer =3D nc->peer; + type =3D nc->info->type; + if (!peer || type !=3D NET_CLIENT_DRIVER_TAP) { + continue; + } + QTAILQ_FOREACH(nf, &nc->filters, next) { + nfc =3D NETFILTER_GET_CLASS(OBJECT(nf)); + if (!nfc->handle_event) { + continue; + } + nfc->handle_event(nf, event, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + } + } +} + void qmp_set_link(const char *name, bool up, Error **errp) { NetClientState *ncs[MAX_QUEUE_NUM]; --=20 2.17.1