From nobody Tue Feb 10 05:41:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1769962862; cv=none; d=zohomail.com; s=zohoarc; b=cKHxWJfghZBMjSPgLKhS1dN3HyPADiuErp35cBmSaKyKVRUrNYUeJH63pPz8lsK6vbJmz4mIEbHSjvNwuygSKEKpyebOdbsmG07ZhHshGtIXRIVWnqRXMgYx/xaxEfPM4YWRpXXLblLUrJ7gfLH3+0W7ht2GU+SNhAJKRNM25M4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769962862; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3FQTYV0oeBjEz+LJ2Xf+QTLx28lfTEWd/fh896lYb3E=; b=mG7taw3Bq6EvutHdQW0TSeyMZZdCY9mj5152vCVFsRZswQXlekaZquLJZAkqhCj9Ujey9b6onlZF54G8z1jRVT2iDhpbcfgSmCFeNLOubJnxGZ+/RdXFTTI47LOp4mRZJ661UbIrLb2bGIzU+UBMbSJ7+HU4CWztXi5OAvSjQcY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769962862920281.33335087191404; Sun, 1 Feb 2026 08:21:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vmaBU-0001CG-AA; Sun, 01 Feb 2026 11:20:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vmaBM-00019m-QF for qemu-devel@nongnu.org; Sun, 01 Feb 2026 11:20:16 -0500 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vmaBJ-0005YM-Py for qemu-devel@nongnu.org; Sun, 01 Feb 2026 11:20:16 -0500 Received: from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 6FA43807D1; Sun, 01 Feb 2026 19:20:11 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:765::1:3b]) by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 4Kp2C46Aq8c0-P8W3mn5K; Sun, 01 Feb 2026 19:20:11 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1769962811; bh=3FQTYV0oeBjEz+LJ2Xf+QTLx28lfTEWd/fh896lYb3E=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=SNRHGzA7MeX0+vnzt4Mgv+9rlD5AwK8dHTnu4A6nBEYGhmUdZ64xMgRXBXDHz3tZo YzDO7Uuf/jR+EjvIksCxGzr5oSyh7SUgSANyTHwvraHwpIkQzbUvm5k/cpOzw8AarF oNVeNBU9/zbBSbtDkZjuq/HnvgH73UqadauZXD0c= Authentication-Results: mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com, mst@redhat.com Cc: pbonzini@redhat.com, berrange@redhat.com, thuth@redhat.com, armbru@redhat.com, eblake@redhat.com, farosas@suse.de, peterx@redhat.com, zhao1.liu@intel.com, wangyanan55@huawei.com, philmd@linaro.org, marcel.apfelbaum@gmail.com, eduardo@habkost.net, davydov-max@yandex-team.ru, qemu-devel@nongnu.org, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, leiyang@redhat.com, raphael.s.norwitz@gmail.com, bchaney@akamai.com Subject: [PATCH v10 4/8] net: introduce vmstate_net_peer_backend Date: Sun, 1 Feb 2026 19:19:56 +0300 Message-ID: <20260201162001.296328-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260201162001.296328-1-vsementsov@yandex-team.ru> References: <20260201162001.296328-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1769962864704158500 Content-Type: text/plain; charset="utf-8" To implement backend-transfer migration in virtio-net in the next commit, we need a generic API to migrate net backend. Here is it. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/net/net.h | 4 ++++ net/net.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index 45bc86fc86..aa34043b1a 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -5,6 +5,7 @@ #include "qapi/qapi-types-net.h" #include "net/queue.h" #include "hw/core/qdev-properties-system.h" +#include "migration/vmstate.h" =20 #define MAC_FMT "%02X:%02X:%02X:%02X:%02X:%02X" #define MAC_ARG(x) ((uint8_t *)(x))[0], ((uint8_t *)(x))[1], \ @@ -110,6 +111,7 @@ typedef struct NetClientInfo { SetSteeringEBPF *set_steering_ebpf; NetCheckPeerType *check_peer_type; GetVHostNet *get_vhost_net; + const VMStateDescription *backend_vmsd; } NetClientInfo; =20 struct NetClientState { @@ -354,4 +356,6 @@ static inline bool net_peer_needs_padding(NetClientStat= e *nc) return nc->peer && !nc->peer->do_not_pad; } =20 +extern const VMStateInfo vmstate_net_peer_backend; + #endif diff --git a/net/net.c b/net/net.c index a176936f9b..58e11b9597 100644 --- a/net/net.c +++ b/net/net.c @@ -58,6 +58,7 @@ #include "qapi/string-output-visitor.h" #include "qapi/qobject-input-visitor.h" #include "standard-headers/linux/virtio_net.h" +#include "migration/vmstate.h" =20 /* Net bridge is currently not supported for W32. */ #if !defined(_WIN32) @@ -2173,3 +2174,49 @@ int net_fill_rstate(SocketReadState *rs, const uint8= _t *buf, int size) assert(size =3D=3D 0); return 0; } + +static int get_peer_backend(QEMUFile *f, void *pv, size_t size, + const VMStateField *field) +{ + NetClientState *nc =3D pv; + Error *local_err =3D NULL; + int ret; + + if (!nc->peer) { + return -EINVAL; + } + nc =3D nc->peer; + + ret =3D vmstate_load_state(f, nc->info->backend_vmsd, nc, 0, &local_er= r); + if (ret < 0) { + error_report_err(local_err); + } + + return ret; +} + +static int put_peer_backend(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc) +{ + NetClientState *nc =3D pv; + Error *local_err =3D NULL; + int ret; + + if (!nc->peer) { + return -EINVAL; + } + nc =3D nc->peer; + + ret =3D vmstate_save_state(f, nc->info->backend_vmsd, nc, 0, &local_er= r); + if (ret < 0) { + error_report_err(local_err); + } + + return ret; +} + +const VMStateInfo vmstate_net_peer_backend =3D { + .name =3D "virtio-net-nic-nc-backend", + .get =3D get_peer_backend, + .put =3D put_peer_backend, +}; --=20 2.52.0