From nobody Sun Mar 22 14:28:26 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=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1774016506; cv=none; d=zohomail.com; s=zohoarc; b=TnIHwNiGuFNfL0FH8Iz29mv0mKMaK9p2f2PE4RTKGGu9WjqnJN3JOgks2dPsfae+M+kAvZIat1n4kAD53hW517BIUnexubNj83WMJwqNhH89Tq6Wx2DiIaLAQdtaJv+XmsQIQVIwEc2LvSG7LprgD9gci9sbI43uBhJg1kDGnVw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016506; 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=uI8IglFLYDJRx7W0jNdr2C9/1ScT5QmOSawTRa4KXCc=; b=b52AfKA98G28NdO9wsaxk20fX4lYnsqKD3HKLr2c0P9Fk8lEw/+FZknTXXteeJpNrMUDaAFtRTYttvR4kUUf5cMP3SY4pPFJakP6PkNACYRFR2CqUo/x/CLg5PGyf6IPAMK/aGLaHZg0iT3oYJpXdJfD703KjP4OnFegoEQM0yg= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1774016506129178.27982463530668; Fri, 20 Mar 2026 07:21:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3aiX-0002x7-TK; Fri, 20 Mar 2026 10:20:49 -0400 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 1w3aiU-0002w3-EH for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:47 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3aiS-0007Pw-73 for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:46 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8Yx423255891; Fri, 20 Mar 2026 14:20:20 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cvyj69pbx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:20 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KDoNiX030576; Fri, 20 Mar 2026 14:20:20 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb3x0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:19 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2JX016730; Fri, 20 Mar 2026 14:20:19 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-2; Fri, 20 Mar 2026 14:20:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=uI8Ig lFLYDJRx7W0jNdr2C9/1ScT5QmOSawTRa4KXCc=; b=F5Cc6IwoYceHXIUrQ82Dl LEEMc5Pew2xgnhsHLKKu9XaNh16wryaE1IWorYAYecGmPxBxtuYZCrsFWxgqRlUa gz4fe3S9sb3+5Nljabq9QBFIY3s6XqcJzg8ZtSZRvbqRWjL02XMKjsIEZezIJ1YN LVvSmkf5Xbvo8QuzqjR6zYotKcVURTjaVmlOiiQLX+fp1yUy5eqB2e+ylrV1jac8 cTuWnFsfjw1Bg1ZyTb4/qgfLsHGgTC2T4bfoEXJKzyUCXN0yrUVv+HNKGTZdMAgj Aseevek2+KuZMBi17MjXQUI4gEs76XhsqP3nlaewLDGSZWTM0yCAPsGawhVxWlVy A== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 01/14] machine,virtio-net: add early-mig property Date: Fri, 20 Mar 2026 14:20:02 +0000 Message-ID: <20260320142015.3856652-2-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Authority-Analysis: v=2.4 cv=LKFrgZW9 c=1 sm=1 tr=0 ts=69bd57a4 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=EIcjfB9IiI4px24ztqRk:22 a=yPCof4ZbAAAA:8 a=uYdD1a5eg0DnrcKIs-gA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfXwbr7ybUEUST0 WkVnfHRL3BCVw8gClVpmaoDxaNUy3QMvJ5VQEsCu27LD6DyPcni8jGuMoUvJQxAD2k5W8dxod3q GFv3KqaXuK5t1TlZZyplBsfbC21i/ZWO5pmM5D2xBbkyt6oUUfSrR12Kqa88Ma360O6lCA8xGsd ABekwPMMEs550jBA8KoQoE+ipLqqkJxOzPE5RwN5lXS6z+5ZHD1rqsLXmQ4JLKzBJHP+RWQTUsR 5nmQ0YaI0eBiocou9RCvHir4zN4Pt+EWixoTUuv/iXF3wRpbHzIAnV7nWLdm4inuiop6kho4zFi AruuCXbgCjQpq/2LhtEPHT/viwalSeNL/JnW9fjS24CVgEvwr3iWnPpzF4jtfCuXo0DfXHo2SDg kGmtVdO3FMiC8RF0FjQzu/9ETyMhdw69zhuRVhGl6ybeyTUFJFkj0tG4GJuTnuYUyXIzUzJ4SDa WakduQeuiP4XLDy0kLw== X-Proofpoint-GUID: Z73GoIBUqHMxImCG9SUlEYgLxdGwPi2p X-Proofpoint-ORIG-GUID: Z73GoIBUqHMxImCG9SUlEYgLxdGwPi2p 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=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list 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 @oracle.com) X-ZM-MESSAGEID: 1774016506550158500 Content-Type: text/plain; charset="utf-8" Introduce a new 'early-mig' property that enables the early migration path for virtio-net devices on machine types >=3D 10.2: - virtio-net-device,early-mig=3Don - virtio-net-pci,early-mig=3Don - virtio-net-pci-transitional,early-mig=3Don - virtio-net-pci-non-transitional,early-mig=3Don - virtio-net-ccw,early-mig=3Don To preserve compatibility for older machine types (<=3D 10.1), add compat overrides in hw_compat_10_1 to keep the legacy default (off). With this, machine types 10.2 and newer enable early migration by default while older machine types retain the previous behavior. Users may still override explicitly via: -device virtio-net-pci,early-mig=3Doff or -global virtio-net-device.early-mig=3Doff Follow-up patches will implement the actual early migration feature for virtio-net devices. Signed-off-by: Jonah Palmer --- hw/core/machine.c | 5 +++++ hw/net/virtio-net.c | 1 + include/hw/virtio/virtio-net.h | 1 + 3 files changed, 7 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index 6cf0e2f404..1b6c7db119 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -45,6 +45,11 @@ const size_t hw_compat_10_2_len =3D G_N_ELEMENTS(hw_comp= at_10_2); =20 GlobalProperty hw_compat_10_1[] =3D { { TYPE_ACPI_GED, "x-has-hest-addr", "false" }, + { "virtio-net-device", "early-mig", "off" }, + { "virtio-net-pci", "early-mig", "off" }, + { "virtio-net-pci-transitional", "early-mig", "off" }, + { "virtio-net-pci-non-transitional", "early-mig", "off" }, + { "virtio-net-ccw", "early-mig", "off" }, { TYPE_VIRTIO_NET, "host_tunnel", "off" }, { TYPE_VIRTIO_NET, "host_tunnel_csum", "off" }, { TYPE_VIRTIO_NET, "guest_tunnel", "off" }, diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 2a5d642a64..12b3456ca2 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -4258,6 +4258,7 @@ static const Property virtio_net_properties[] =3D { VIRTIO_NET_F_GUEST_USO6, true), DEFINE_PROP_BIT64("host_uso", VirtIONet, host_features, VIRTIO_NET_F_HOST_USO, true), + DEFINE_PROP_BOOL("early-mig", VirtIONet, early_mig, true), DEFINE_PROP_ON_OFF_AUTO_BIT64("hash-ipv4", VirtIONet, rss_data.specified_hash_types, VIRTIO_NET_HASH_REPORT_IPv4 - 1, diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 371e376428..ddb141fefc 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -230,6 +230,7 @@ struct VirtIONet { struct EBPFRSSContext ebpf_rss; uint32_t nr_ebpf_rss_fds; char **ebpf_rss_fds; + bool early_mig; }; =20 size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev, --=20 2.51.0 From nobody Sun Mar 22 14:28:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1774016789; cv=none; d=zohomail.com; s=zohoarc; b=RPbT0nZgXwm7gEMpgXvanbgJvLSSgi1aZk8C6cYO3RKysDobVtafVR1OByVSgGadYBh8nkEkzAagutDmm9wUBiOkTTFzWMV99bfyR0ELW1nObyKKk26aTRJAFWpiIpA7YD55CJ/ulS5ZlHFBg5T0FfHl2RgNDa7AIpj0N1XjT+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016789; 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:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=11O1nlIAbwkDq0XsRmbItWfRrNrfkL+vYhFfZeFFKIE=; b=TbyzxPZLOHDj4UBYoKp+a2YbBXGATqstSOSjGU0mQpNP8ey63Aanet8e8ffhR71+yH4mxLnRgh1eJTWt8HaTCcm8iNt9xUMJj7oscguskJW1GNGsquGfYabvgv4Gz9x3dyy8EYJZd5oa/PjPqwqMendo1roHY+BecmEfKDFoCBQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1774016789166489.26977996770745; Fri, 20 Mar 2026 07:26:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3anP-0000PQ-8r; Fri, 20 Mar 2026 10:25:51 -0400 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 1w3anL-0000P7-ID for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:25:47 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3anI-0008Cf-QU for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:25:46 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8Y3bP2600046; Fri, 20 Mar 2026 14:20:23 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cvx8x9th0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:23 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KCi27c030664; Fri, 20 Mar 2026 14:20:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb3yf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:21 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2JZ016730; Fri, 20 Mar 2026 14:20:21 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-3; Fri, 20 Mar 2026 14:20:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=11O1n lIAbwkDq0XsRmbItWfRrNrfkL+vYhFfZeFFKIE=; b=J8IuqtpFb4ZZ42H8T18nd VNLDIrZ4WU2L0XGGisRZQF0yOpgTYij8Qdpv3RbWJfnRClVqJ8wXt/cBapI6v3ge hMX9in6TJVGSZx4L8AFu1M2MRj/RUTSUH7uwgVE4X8iGwgUpOwkXMtr5BRLcA0dn OwbPyEVax5HK8NK2Pk5cr4uGjDq8b5aTOt8UQZcyvPzRPT2Lobf5SUNfhUpvoCmf P4ttipcpM7fozcv+K6OL8jJARFGqV2njJEiaq+1vJzmt/9z0EGeCemi2MBDAT3QS Th7V0BrVX+oGD7o6eVK5e8BWlMu9KcHBET7aEmg/9eVT+UeH7ubjiJr+WCoOxSX1 w== To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 02/14] virtio, virtio-net: add initial early VMSD for setup-phase migration Date: Fri, 20 Mar 2026 14:20:03 +0000 Message-ID: <20260320142015.3856652-3-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Proofpoint-GUID: T4Kn0Sbe6OIZqz5paG60HduzP2ce9Ftr X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfX3vf6EZP7WzT3 9xJSWJIPO2RIqY6zo4ZuHxDOtwPqSdGfO6OpQFHn3wXQv2ycZOzUZ032+uDApguk0G8MrGKOM73 jkDInwEWMGLXVANk1tmsGylPjFN//T/G7ibsoo/aOUG6WobQAcRTbdXVYVCtq5uVtQtEht1PWGV OW2Eit+pEYZkV9zJ5yr8yyGs9y6cJz9wGYfgeWHkvbTle9xdYkAovnzy1kAqv2PeQsh1O0igbOl hGHBV1ZWeZ54BnIuk5WsbEgbU65esRVEphf94+1l5FWLzEP8JiGrGmReMAfwvpg1z5/8KA6oPRq VGvGaHJuki/W7+Lcrij8ga6h05EZXTNNTS1aTwYIILYdA/YJavA0XzVXBPYg6O9sXATh36WbAvp e3BRgsraeIIBnzts8WYzYW5k5344FCV6dhK4UOvs+NihFwR/R1UKxi0rA5iO+TX0p5d8zSHTbFT dJ7A3vViPEIgYgvKTYw== X-Authority-Analysis: v=2.4 cv=dJmrWeZb c=1 sm=1 tr=0 ts=69bd57a7 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=RD47p0oAkeU5bO7t-o6f:22 a=yPCof4ZbAAAA:8 a=n8FzOVadAr_i4xXxhBoA:9 X-Proofpoint-ORIG-GUID: T4Kn0Sbe6OIZqz5paG60HduzP2ce9Ftr 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=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Jonah Palmer From: Jonah Palmer via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1774016790450154100 Content-Type: text/plain; charset="utf-8" Adds a separate VMStateDescription for virtio-net that uses the .early_setup feature. With this feature, we can migrate a virtio-net device's state earlier, before the stop-and-copy phase. Future patches will utilize this to move control plane operations out of the stop-and-copy phase to reduce the downtime latency caused by migrating a virtio-net device. A VirtIODevMigration migration data structure is also introduced here for VirtIODevices to help track the current state of a migration. The early_load member is used to signal that a VirtIODevice is being loaded early and to not throw an error regarding vring indices. Inconsistent indices shouldn't be an issue for a device so long as the final indices are eventually loaded before the device starts. Signed-off-by: Jonah Palmer --- hw/net/virtio-net.c | 53 ++++++++++++++++++++++++++++++++++++++ hw/virtio/virtio.c | 14 +++++++++- include/hw/virtio/virtio.h | 9 +++++++ 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 12b3456ca2..ddd6ed6e62 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3864,6 +3864,37 @@ static bool failover_hide_primary_device(DeviceListe= ner *listener, return qatomic_read(&n->failover_primary_hidden); } =20 +static int virtio_net_early_pre_load(void *opaque) +{ + VirtIONet *n =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + + vdev->migration->early_load =3D true; + return 0; +} + +static int virtio_net_early_post_load(void *opaque, int version_id) +{ + VirtIONet *n =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + + vdev->migration->early_load =3D false; + return 0; +} + +static const VMStateDescription vmstate_virtio_net_early =3D { + .name =3D "virtio-net-early", + .minimum_version_id =3D VIRTIO_NET_VM_VERSION, + .version_id =3D VIRTIO_NET_VM_VERSION, + .early_setup =3D true, + .pre_load =3D virtio_net_early_pre_load, + .post_load =3D virtio_net_early_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_VIRTIO_DEVICE, + VMSTATE_END_OF_LIST() + }, +}; + static void virtio_net_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -4046,6 +4077,21 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) n->rss_data.specified_hash_types.on_bits | n->rss_data.specified_hash_types.auto_bits; } + + if (n->early_mig) { + if (nc->peer && nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_VHOS= T_USER) { + /* + * vhost-user backend is not currently supported for the early + * migration path. + */ + n->early_mig =3D false; + } else { + vdev->migration =3D g_new0(VirtIODevMigration, 1); + vdev->migration->early_load =3D false; + + vmstate_register_any(VMSTATE_IF(n), &vmstate_virtio_net_early,= n); + } + } } =20 static void virtio_net_device_unrealize(DeviceState *dev) @@ -4090,6 +4136,13 @@ static void virtio_net_device_unrealize(DeviceState = *dev) g_free(n->rss_data.indirections_table); net_rx_pkt_uninit(n->rx_pkt); virtio_cleanup(vdev); + + if (n->early_mig) { + g_free(vdev->migration); + vdev->migration =3D NULL; + + vmstate_unregister(VMSTATE_IF(n), &vmstate_virtio_net_early, n); + } } =20 static void virtio_net_reset(VirtIODevice *vdev) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 8fcf6cfd0b..48de4a430b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3323,6 +3323,7 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int vers= ion_id) int32_t config_len; uint32_t num; uint32_t features; + bool inconsistent_indices; BusState *qbus =3D qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); @@ -3460,6 +3461,14 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int ver= sion_id) if (vdev->vq[i].vring.desc) { uint16_t nheads; =20 + /* + * Ring indices will be inconsistent for a VMStateDescription + * performing an early load. This shouldn't be an issue as the + * final indices will get sent later once the source has been + * stopped. + */ + inconsistent_indices =3D vdev->migration && vdev->migration->e= arly_load; + /* * VIRTIO-1 devices migrate desc, used, and avail ring address= es so * only the region cache needs to be set up. Legacy devices n= eed @@ -3481,12 +3490,15 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int ve= rsion_id) =20 nheads =3D vring_avail_idx(&vdev->vq[i]) - vdev->vq[i].last_av= ail_idx; /* Check it isn't doing strange things with descriptor numbers= . */ - if (nheads > vdev->vq[i].vring.num) { + if (!inconsistent_indices && nheads > vdev->vq[i].vring.num) { virtio_error(vdev, "VQ %d size 0x%x Guest index 0x%x " "inconsistent with Host index 0x%x: delta 0x%= x", i, vdev->vq[i].vring.num, vring_avail_idx(&vdev->vq[i]), vdev->vq[i].last_avail_idx, nheads); + inconsistent_indices =3D true; + } + if (inconsistent_indices) { vdev->vq[i].used_idx =3D 0; vdev->vq[i].shadow_avail_idx =3D 0; vdev->vq[i].inuse =3D 0; diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 6344bd7b68..4c886eb48b 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -99,6 +99,14 @@ enum virtio_device_endian { VIRTIO_DEVICE_ENDIAN_BIG, }; =20 +/** + * struct VirtIODevMigration - Common VirtIODevice migration structure + * @early_load: Flag to indicate an early virtio_load for the device. + */ +typedef struct VirtIODevMigration { + bool early_load; +} VirtIODevMigration; + /** * struct VirtIODevice - common VirtIO structure * @name: name of the device @@ -168,6 +176,7 @@ struct VirtIODevice */ EventNotifier config_notifier; bool device_iotlb_enabled; + VirtIODevMigration *migration; }; =20 struct VirtioDeviceClass { --=20 2.51.0 From nobody Sun Mar 22 14:28:26 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=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1774016479; cv=none; d=zohomail.com; s=zohoarc; b=CJAx2YwiARoTNbcTeNh+S2ANx4GTgJkADKbm1qywC5e40ZuQaqlPV6uoctNn4lkpuo9MwVogqu4/T80jxPO5Im2qn1lYWvglCtGuUuiQpyD8hN2gL4AghRbHEHaMH5VFFZA1HsMSibeFD4frtKlVZeLxR1NDuAYDz0v3N2cQNrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016479; 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=4pKiPN0UZLV3R994mn1SAhPIcdW74P8eqNMb5OK2Yj0=; b=K9Di0pS4wj01XfOWdmsdTxkXKn7c3d907jERzrMK368pPhOOeq7Qm5Biu2BEgXEr1PID0M2ddBwD+tGl/Zh04FS6JXhtlKPGZYif7yHs+oRV4IHrJQTZyIATB0yOZ+r/49ZTC3U5kqrZjEJt+gw1+niM0OjZKS5sS00tVVuSziM= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1774016479631175.37146687282655; Fri, 20 Mar 2026 07:21:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3aiX-0002x6-PX; Fri, 20 Mar 2026 10:20:49 -0400 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 1w3aiU-0002w4-NR for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:47 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3aiS-0007QA-IX for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:46 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8YfvV2601039; Fri, 20 Mar 2026 14:20:25 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cvx8x9th3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:24 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KDEaMW030672; Fri, 20 Mar 2026 14:20:23 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb40t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:23 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2Jb016730; Fri, 20 Mar 2026 14:20:22 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-4; Fri, 20 Mar 2026 14:20:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=4pKiP N0UZLV3R994mn1SAhPIcdW74P8eqNMb5OK2Yj0=; b=W34XtsnjNMQhq4++lDRns GC+eUrt0Ghp263xf2QC57rOtpaCOBF/SLQZWG+fIL4qmTtSF9Ml3iCXm4Q2cQdN7 kDIV8JkkPl7Vt/o4iZKkIWCegiTiiR7aoHQGaquS8gq+flcffrQqGVPLapPrfhls UJlXD7rTXAxjdezWeUwlNa2btx/bbTylfQpQOhA4Y+8Z7Bol6UkcCW6B9jsgepbO Sw1g5gDFMzvgYmGjwkwQu3vq61M3VffAKLM2VhfqMBiZUusPTowjY2qfjC8vLk6U pbZ1lLctIdVqoaKKeBjvJCvJioq16qK7NrXYVDSyMpDpQMC+NEb9CiJKJNLAjdE3 Q== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 03/14] virtio,virtio-net: virtio-delta VMSD - VQ state Date: Fri, 20 Mar 2026 14:20:04 +0000 Message-ID: <20260320142015.3856652-4-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Proofpoint-GUID: abe9vLnBy0tzKWjSa2fVzIVBn-jw87Xj X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfX5c+7A5zubeMD KQ18sgWYZX7wf6rsTXvG7eeLrEVxdtx3uTqR7pLCqQoKsfmr8674WebmDGsnN9oPsav9IFJKAzv YeSgV+Ext5wPzpkt7YV25QrJgOpIROoze9IqIu1GZxnf5lYFEMsN7D+vuCBpFgXwtnxFO6BUkis Wy/FhOtIP+AhgZm0F8erA080ZkbdrausPi3S11EMweGMy09JGDs5y5VwHxLxPeyjQISKatrSagB k3fUt7Bk8bGfjRBWQKLFLOyE0mzumM6N+GrmEJFauEcZnGRR8nqyIWI0Jf5Ri4XomFg+1F4rNIl s9TbyT3/QlIt93FwIy0cWM1QOtfYdGuRQJT3wc0rk8f2ALUoI4l0Lb+D5xxoPT4+oV4TYpfj9YM q5WH1Nv7Vlcp/GZWKpWOKnurspSntWhtHmx1I8MDHU5aadI/OAOSMSEm4zwRbSgsG+LIkISL833 yfpQ4H5GZNIIzitBZdA== X-Authority-Analysis: v=2.4 cv=dJmrWeZb c=1 sm=1 tr=0 ts=69bd57a8 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=RD47p0oAkeU5bO7t-o6f:22 a=yPCof4ZbAAAA:8 a=5Z4hCT9oO6PqrKkAV_EA:9 X-Proofpoint-ORIG-GUID: abe9vLnBy0tzKWjSa2fVzIVBn-jw87Xj 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=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list 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 @oracle.com) X-ZM-MESSAGEID: 1774016481986154100 Content-Type: text/plain; charset="utf-8" Introduce a new virtio VMStateDescription vmstate_virtio_delta for VirtIODevices. This parent VMSD will be used by virtio devices that send their state early (before the stop-and-copy phase) and only need to resend any state that changed since then. Any data that is re-sent is done during the stop-and-copy phase, when the source has been paused. This patch also adds subsections to vmstate_virtio_delta for resyncing a VirtIODevice's VQs' state. Since it's more likely than not that these fields changed since they were sent early, we just send their updated values without checking if they did indeed change. After loading delta VQ state, re-sync runtime shadow queue indices to the delta-loaded avail indices and clear signalled_used_valid so runtime queue bookkeeping stays consistent for both split and packed rings. Lastly, this new VirtIODevice parent VMSD is registered for a virtio-net device only if it has its early-mig property enabled. Signed-off-by: Jonah Palmer --- hw/net/virtio-net.c | 2 + hw/virtio/virtio.c | 150 +++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 3 + 3 files changed, 155 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index ddd6ed6e62..5d71ad235e 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -4090,6 +4090,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) vdev->migration->early_load =3D false; =20 vmstate_register_any(VMSTATE_IF(n), &vmstate_virtio_net_early,= n); + virtio_delta_vmsd_register(vdev); } } } @@ -4142,6 +4143,7 @@ static void virtio_net_device_unrealize(DeviceState *= dev) vdev->migration =3D NULL; =20 vmstate_unregister(VMSTATE_IF(n), &vmstate_virtio_net_early, n); + virtio_delta_vmsd_unregister(vdev); } } =20 diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 48de4a430b..47236bf7d7 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2780,6 +2780,13 @@ static bool virtio_virtqueue_needed(void *opaque) return virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1); } =20 +static bool virtio_split_virtqueue_needed(void *opaque) +{ + VirtIODevice *vdev =3D opaque; + + return !virtio_host_has_feature(vdev, VIRTIO_F_RING_PACKED); +} + static bool virtio_packed_virtqueue_needed(void *opaque) { VirtIODevice *vdev =3D opaque; @@ -2842,6 +2849,18 @@ static const VMStateDescription vmstate_virtqueue = =3D { } }; =20 +static const VMStateDescription vmstate_split_virtqueue =3D { + .name =3D "split_virtqueue_state", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT16(last_avail_idx, struct VirtQueue), + VMSTATE_UINT16(used_idx, struct VirtQueue), + VMSTATE_UINT32(inuse, struct VirtQueue), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_packed_virtqueue =3D { .name =3D "packed_virtqueue_state", .version_id =3D 1, @@ -2856,6 +2875,89 @@ static const VMStateDescription vmstate_packed_virtq= ueue =3D { } }; =20 +/* + * Temporary type used with VMSTATE_WITH_TMP to migrate + * active VQs only for VirtIODevices that participated + * in early live migration. + */ +typedef struct VirtIOMigVQsTmp { + VirtIODevice *parent; + VirtQueue *vqs; + uint16_t num_vqs; +} VirtIOMigVQsTmp; + +static int virtio_delta_vqs_pre_save(void *opaque) +{ + VirtIOMigVQsTmp *tmp =3D opaque; + tmp->vqs =3D tmp->parent->vq; + tmp->num_vqs =3D virtio_get_num_queues(tmp->parent); + return 0; +} + +static int virtio_delta_vqs_pre_load(void *opaque) +{ + VirtIOMigVQsTmp *tmp =3D opaque; + uint16_t num_vqs =3D virtio_get_num_queues(tmp->parent); + + tmp->vqs =3D tmp->parent->vq; + tmp->num_vqs =3D num_vqs; + + if (tmp->num_vqs > VIRTIO_QUEUE_MAX) { + return -EINVAL; + } + return 0; +} + +/* Re-sync runtime shadow queue indices with final delta-loaded indices */ +static int virtio_delta_vqs_post_load(void *opaque, int version_id) +{ + VirtIOMigVQsTmp *tmp =3D opaque; + bool packed =3D virtio_vdev_has_feature(tmp->parent, VIRTIO_F_RING_PAC= KED); + int i; + + for (i =3D 0; i < tmp->num_vqs; i++) { + VirtQueue *vq =3D &tmp->vqs[i]; + + if (!vq->vring.desc) { + continue; + } + + vq->shadow_avail_idx =3D vq->last_avail_idx; + if (packed) { + vq->shadow_avail_wrap_counter =3D vq->last_avail_wrap_counter; + } + vq->signalled_used_valid =3D false; + } + + return 0; +} + +static const VMStateDescription vmstate_virtio_delta_split_vqs_tmp =3D { + .name =3D "virtio-delta/split_vqs_tmp", + .pre_save =3D virtio_delta_vqs_pre_save, + .pre_load =3D virtio_delta_vqs_pre_load, + .post_load =3D virtio_delta_vqs_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_STRUCT_VARRAY_POINTER_UINT16(vqs, VirtIOMigVQsTmp, num_vqs, + vmstate_split_virtqueue, + VirtQueue), + VMSTATE_END_OF_LIST() + }, +}; + +static const VMStateDescription vmstate_virtio_delta_packed_vqs_tmp =3D { + .name =3D "virtio-delta/packed_vqs_tmp", + .pre_save =3D virtio_delta_vqs_pre_save, + .pre_load =3D virtio_delta_vqs_pre_load, + .post_load =3D virtio_delta_vqs_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_STRUCT_VARRAY_POINTER_UINT16(vqs, VirtIOMigVQsTmp, num_vqs, + vmstate_packed_virtqueue, + VirtQueue), + VMSTATE_END_OF_LIST() + }, +}; + static const VMStateDescription vmstate_virtio_virtqueues =3D { .name =3D "virtio/virtqueues", .version_id =3D 1, @@ -3053,6 +3155,54 @@ static const VMStateDescription vmstate_virtio =3D { } }; =20 +static const VMStateDescription vmstate_virtio_delta_split_virtqueues =3D { + .name =3D "virtio-delta/split_virtqueues", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D &virtio_split_virtqueue_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_WITH_TMP(VirtIODevice, VirtIOMigVQsTmp, + vmstate_virtio_delta_split_vqs_tmp), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_virtio_delta_packed_virtqueues =3D= { + .name =3D "virtio-delta/packed_virtqueues", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D &virtio_packed_virtqueue_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_WITH_TMP(VirtIODevice, VirtIOMigVQsTmp, + vmstate_virtio_delta_packed_vqs_tmp), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_virtio_delta =3D { + .name =3D "virtio-delta", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription * const []) { + &vmstate_virtio_delta_split_virtqueues, + &vmstate_virtio_delta_packed_virtqueues, + NULL + } +}; + +void virtio_delta_vmsd_register(VirtIODevice *vdev) +{ + vmstate_register_any(VMSTATE_IF(vdev), &vmstate_virtio_delta, vdev); +} + +void virtio_delta_vmsd_unregister(VirtIODevice *vdev) +{ + vmstate_unregister(VMSTATE_IF(vdev), &vmstate_virtio_delta, vdev); +} + int virtio_save(VirtIODevice *vdev, QEMUFile *f) { BusState *qbus =3D qdev_get_parent_bus(DEVICE(vdev)); diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 4c886eb48b..74fed8c324 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -305,6 +305,9 @@ int virtqueue_get_avail_bytes(VirtQueue *vq, unsigned i= nt *in_bytes, =20 void virtio_notify(VirtIODevice *vdev, VirtQueue *vq); =20 +void virtio_delta_vmsd_register(VirtIODevice *vdev); +void virtio_delta_vmsd_unregister(VirtIODevice *vdev); + int virtio_save(VirtIODevice *vdev, QEMUFile *f); =20 extern const VMStateInfo virtio_vmstate_info; --=20 2.51.0 From nobody Sun Mar 22 14:28:26 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=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1774016577; cv=none; d=zohomail.com; s=zohoarc; b=Cv9OL83DFtWj2SD9NuutU0SEHe+63aIuPxUzJVMubJeFqRJQOgZ3hY/D5QLu4ZpymLFgWXUzgk6umwzq55R3u+Eo3cLl4q71R9C46aTs8P9wVPn9S2UWu41lNDZgqKiphSVuWAkoGAcuYcFj4t2PfyU0eJACIImXW435MmLoZto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016577; 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=gjr6X6FjLOGEcEwKsJNBVN5o5O7x2XraQbiJzpXv154=; b=DceSAOc9I4aeekWZosJZs8DFd4VoDq6Abpzgpp7BScF7IXNDMspsZk1cITjLcI4C9XsPqGbAsAQWZ7kKklR+MmRGgCWNPCiMh7xWGv2XiRi6f7fr19SLQ8/e0QzisprsWj9pq5SArgB/I0MaSwUv94PlxZNEq18B1G0of/+3pcI= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1774016577428285.0825620036403; Fri, 20 Mar 2026 07:22:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3aiZ-0002xz-Si; Fri, 20 Mar 2026 10:20:51 -0400 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 1w3aiX-0002wn-5F for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:49 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3aiU-0007QL-OP for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:48 -0400 Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8Y3OH3323029; Fri, 20 Mar 2026 14:20:29 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cvxk8htjt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:29 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KDoNif030576; Fri, 20 Mar 2026 14:20:29 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb44d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:28 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2Jd016730; Fri, 20 Mar 2026 14:20:28 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-5; Fri, 20 Mar 2026 14:20:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=gjr6X 6FjLOGEcEwKsJNBVN5o5O7x2XraQbiJzpXv154=; b=J7XLN43yJByLpY61H20lh Yn90q1t2zuD7r9Y/qss0Ul040frInlOCgC1m+bT5Op4vPBziOvADd0cJOUoGA3RU 5P8pZbTFiqmyCT6qTi6RU2UtBpjrnnn7Hq3vX65RwtJ9oD9eRvGC8+fZkIj4fRgY m/+knvA9P+hKtkqMhApE7bwcr7NmE2qsPzcLsL9qb6oJbV1PIBLPht3HUPJ5rEo/ 3/SrDmZ6iPVBJBA8k0E5jl/d0aw8+xiIi8s/VTxrz+qdWZBXFGB9+fHaRL6xLvNc BenlqmIMjS14XEfjppihsyqZvP48Xj3L7ddC1DE8AKvHZCo7wvU34N3U/Y65NeRc Q== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 04/14] virtio-net: detect VirtIODevice status mid-migration change Date: Fri, 20 Mar 2026 14:20:05 +0000 Message-ID: <20260320142015.3856652-5-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfX3u40vBUkEWlC qWI3mSxS7+eaID9dEKs1HyJG3Z1BWl8jwybKNBDjjSoG8hFK2VV3mxGPHBAscFR1SAI4qlrYeKQ FqHVi6emQ286kwC+Mfpsg4vfqOnJTuNKs2r5d4tJb3XUw1mUoQIFYwQhKymza7GUnr72oBJZ0ws 1/zXtmeqn95rnpfjdTxI4mGOenm0uPhfAhJSfBGbSkrCjNh5As10YpLdMpzyUYXx2XhhBLJKy3V AL82zwC6RiW4+JAN44ZjidfIUhWZZ5R4f2R8lyEXuNh040YABasCj6BfwnLnTvfDEI72gTZ0zja IvdX227Hxy65CecY/2wewG5mZ+xrkLIril93OWla99Xqdy1y8o3xFRPHxlvvJ4S+3g4Dmvpbh2T oJZPveiIsE7FL+VihQN/uLEeBOCIEWi6sA6Cr2dW6/cqcOketEmjvJu8HVNmgZoCfqqsGutixQq i0LbK/+qhWfQSjCS31A== X-Authority-Analysis: v=2.4 cv=AI0/m/Lt c=1 sm=1 tr=0 ts=69bd57ad b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=x0eKOSpe3m1H3M0S9YoZ:22 a=yPCof4ZbAAAA:8 a=3r8ui8mxyQxcokH5ohsA:9 X-Proofpoint-GUID: SPzg3wI3BoN1i1W-kmlVJ-2P1y3qFRMv X-Proofpoint-ORIG-GUID: SPzg3wI3BoN1i1W-kmlVJ-2P1y3qFRMv 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=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list 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 @oracle.com) X-ZM-MESSAGEID: 1774016578950158500 Content-Type: text/plain; charset="utf-8" This patch introduces the mechanism in which this series will use to detect VirtIODevice & VirtIONet state deltas, starting with the VirtIODevice's 'status' member of a virtio-net device. Before we send the device's state early, we save each piece of its state in a temporary structure via virtio_net_early_pre_save. Later, once the source VM has been paused, we compare the current values of those pieces to what we saved earlier. If any mismatch is found, virtio-net's VMSD (vmstate_virtio_net) is enabled and resends all state and device prep work (as it's normally done today when live migrating a virtio-net device). Once all relevant delta checks are in place, a no-delta case will skip vmstate_virtio_net and only resend updated VQ indices. For this patch, keep a temporary always-true fallback in virtio_net_has_delta/virtio_net_needed until follow-up patches cover the remaining VirtIONet & VirtIODevice deltas. Signed-off-by: Jonah Palmer --- hw/net/virtio-net.c | 40 ++++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 2 ++ 2 files changed, 42 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 5d71ad235e..2733e0130c 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3864,6 +3864,16 @@ static bool failover_hide_primary_device(DeviceListe= ner *listener, return qatomic_read(&n->failover_primary_hidden); } =20 +static int virtio_net_early_pre_save(void *opaque) +{ + VirtIONet *n =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + VirtIODevMigration *vdev_mig =3D vdev->migration; + + vdev_mig->status_early =3D vdev->status; + return 0; +} + static int virtio_net_early_pre_load(void *opaque) { VirtIONet *n =3D opaque; @@ -3887,6 +3897,7 @@ static const VMStateDescription vmstate_virtio_net_ea= rly =3D { .minimum_version_id =3D VIRTIO_NET_VM_VERSION, .version_id =3D VIRTIO_NET_VM_VERSION, .early_setup =3D true, + .pre_save =3D virtio_net_early_pre_save, .pre_load =3D virtio_net_early_pre_load, .post_load =3D virtio_net_early_post_load, .fields =3D (const VMStateField[]) { @@ -4231,10 +4242,39 @@ static bool dev_unplug_pending(void *opaque) return vdc->primary_unplug_pending(dev); } =20 +static bool virtio_net_has_delta(VirtIONet *n, VirtIODevice *vdev) +{ + VirtIODevMigration *vdev_mig =3D vdev->migration; + + /* Has the VirtIODevice's status changed? */ + if (vdev->status !=3D vdev_mig->status_early) { + return true; + } + + /* + * Always return true for now until we're able to detect all possible + * changes to a VirtIONet device. + */ + return true; +} + +static bool virtio_net_needed(void *opaque) +{ + VirtIONet *n =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + + if (!n->early_mig) { + return true; + } + + return virtio_net_has_delta(n, vdev); +} + static const VMStateDescription vmstate_virtio_net =3D { .name =3D "virtio-net", .minimum_version_id =3D VIRTIO_NET_VM_VERSION, .version_id =3D VIRTIO_NET_VM_VERSION, + .needed =3D virtio_net_needed, .fields =3D (const VMStateField[]) { VMSTATE_VIRTIO_DEVICE, VMSTATE_END_OF_LIST() diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 74fed8c324..752c46ce53 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -102,9 +102,11 @@ enum virtio_device_endian { /** * struct VirtIODevMigration - Common VirtIODevice migration structure * @early_load: Flag to indicate an early virtio_load for the device. + * @status_early: Device status at the time it was sent early. */ typedef struct VirtIODevMigration { bool early_load; + uint8_t status_early; } VirtIODevMigration; =20 /** --=20 2.51.0 From nobody Sun Mar 22 14:28:26 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=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1774016572; cv=none; d=zohomail.com; s=zohoarc; b=gOlhDZrzrWP/HU+9mXhT8+ovsqzDtEICVP+7VkEuM36oz70OqvHW91h0r2Bd+C34E3/7M67CyDrZZ8GLjTTQivdUTqt5IrJcFzIJ/+4jOKpbO41jzMXn8MHJodfcC4rCidcrdiE1YQE6S6+cLp3+jEgPZvwMNT1BgyI0fE6NZ/E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016572; 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=Sv8WmSJvIUPxUqFls32F8YWlQumpgBOdkE/KHWzHOE0=; b=URk9zAth8zEKIOB10/t/j+6bNO5DTN/DpeXwvwlfdpq4FZZG2yP4CXPfQZp/hgcrdOu4s6xO0Uhv68ZMXPySHG3MeQZB72AKIc8edGX07gPKwEUZDmSoP0TCJredoySQcvY9elQsZzFKE9IRDb6FtceiYeyO4KafO6ihGy+QF1o= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177401657271877.67136779743373; Fri, 20 Mar 2026 07:22:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3aiZ-0002xc-Az; Fri, 20 Mar 2026 10:20:51 -0400 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 1w3aiW-0002wb-Mt for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:48 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3aiV-0007QP-1c for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:48 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8Y1Yk2599977; Fri, 20 Mar 2026 14:20:31 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cvx8x9tha-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:31 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KDEaMa030672; Fri, 20 Mar 2026 14:20:30 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb45e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:30 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2Jf016730; Fri, 20 Mar 2026 14:20:29 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-6; Fri, 20 Mar 2026 14:20:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=Sv8Wm SJvIUPxUqFls32F8YWlQumpgBOdkE/KHWzHOE0=; b=Namk8hFSlcXJSbvMdix/u d92faPzwe0J4RFINq5xw3MJ8JfbgBVqjuFq9GbB5WIOmbCzrAJlT3CjY0WLxTspr U1arIN1UQXmz+vl5nlAizXUgQngGfSLZSXwvkLnFBCahIFCBxWMrAsXspmpcXOBC xZJLYzfo9c5+m+DLJ/jO4aBGYsUHCSovFNuK4nQyyf0aFjIJp1pLnvHq5pLX9RxB oDIPhdRk9sEWr8WyzIfwaHPMv9Qv8LiXBQVxunCSIcV1W8qQ6Izub7wBtnH74Roc C5D3W+vWwBIzffIZzJgy2vlWEke7B7hVXfNJZW8YhRzbtukAfhM3WtynDsF6i10G Q== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 05/14] virtio-net: detect VirtIODevice config buffer mid-migration change Date: Fri, 20 Mar 2026 14:20:06 +0000 Message-ID: <20260320142015.3856652-6-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Proofpoint-GUID: jj9kXF1RJk9L2I3Ie9DumYTx6VlLpb4x X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfX+HIH9nDjHzd1 13UywatPY8zGwIViFKaGc44+JBF/3xNlxqQmWJdp3WJSpfz7Fj/FaA/ishTv7TYGWObZBbHCRfG HpXqS9bXMXYE03MwzYrKNgfTTld8pM8C8uXb3X5asfcxxRqgZbuLKX3DDWUuxI/D5SmJpAr7XcX pClLQNPibNq0ezlM2lf9kqSfwRl0/jVA1Iu8VTEuJeiLvC6xV/GRFB52Xm3KZcEPlL4p6H8DbkI dMbi5wcLlGbQSF+d0NUWBEZsfE/bLgeCkFcijAubWPADW2V11FB6l3XdfntohO+9q4DEvaO2vEO 8znTv4oDGvHpnHsZbIrEIqj1JamTcniLHMMYO6wg3MKj7z43bnofBXQ17XZyhOv5052Unk86dZV 2C3MICnQFtiGDNMZVrqstqxsQSbXqPfMA8TyxEjcR7OJiA1PtKFTHiZwiroyYcLaIOkETFm+IF8 OHkxhNNzHgg48RC3Rlw== X-Authority-Analysis: v=2.4 cv=dJmrWeZb c=1 sm=1 tr=0 ts=69bd57af b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=RD47p0oAkeU5bO7t-o6f:22 a=yPCof4ZbAAAA:8 a=1bn3fnhKCm_T0IbXVqwA:9 X-Proofpoint-ORIG-GUID: jj9kXF1RJk9L2I3Ie9DumYTx6VlLpb4x 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=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list 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 @oracle.com) X-ZM-MESSAGEID: 1774016574874154100 Content-Type: text/plain; charset="utf-8" This patch saves the config buffer and its length of a virtio-net device's VirtIODevice to compare with later during the stop-and-copy phase. Signed-off-by: Jonah Palmer --- hw/net/virtio-net.c | 21 +++++++++++++++++++++ include/hw/virtio/virtio.h | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 2733e0130c..ca4385df1a 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3871,6 +3871,15 @@ static int virtio_net_early_pre_save(void *opaque) VirtIODevMigration *vdev_mig =3D vdev->migration; =20 vdev_mig->status_early =3D vdev->status; + + /* VirtIODevice config buffer snapshot */ + g_free(vdev_mig->config_early); + vdev_mig->config_len_early =3D vdev->config_len; + if (vdev->config_len) { + vdev_mig->config_early =3D g_memdup2(vdev->config, vdev->config_le= n); + } else { + vdev_mig->config_early =3D NULL; + } return 0; } =20 @@ -4150,6 +4159,9 @@ static void virtio_net_device_unrealize(DeviceState *= dev) virtio_cleanup(vdev); =20 if (n->early_mig) { + g_free(vdev->migration->config_early); + vdev->migration->config_early =3D NULL; + g_free(vdev->migration); vdev->migration =3D NULL; =20 @@ -4251,6 +4263,15 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtI= ODevice *vdev) return true; } =20 + /* Has the VirtIODevice's config buffer changed? */ + if (vdev->config_len !=3D vdev_mig->config_len_early) { + return true; + } + if (vdev->config_len && memcmp(vdev->config, vdev_mig->config_early, + vdev->config_len) !=3D 0) { + return true; + } + /* * Always return true for now until we're able to detect all possible * changes to a VirtIONet device. diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 752c46ce53..9949b94b64 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -103,10 +103,14 @@ enum virtio_device_endian { * struct VirtIODevMigration - Common VirtIODevice migration structure * @early_load: Flag to indicate an early virtio_load for the device. * @status_early: Device status at the time it was sent early. + * @config_len_early: Length of the config buffer at the time it was sent = early. + * @config_early: Config buffer at the time it was sent early. */ typedef struct VirtIODevMigration { bool early_load; uint8_t status_early; + size_t config_len_early; + uint8_t *config_early; } VirtIODevMigration; =20 /** --=20 2.51.0 From nobody Sun Mar 22 14:28:26 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=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1774016500; cv=none; d=zohomail.com; s=zohoarc; b=ZjdLJzVj5aMhEZh0AbIxFSJbNLrhd9UCO9LjuHxfV6z/bmdkMMr5GzjnmujjAkvtH+QaaigrXo7lXWX1WzVPr/BAf72UGfLRIpp48MsWIZz8343PeIw029MhGTl3tVJD4EpKWk8dyrt2XS9T3aOwJCwfT7a4L66q2++qEflVL2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016500; 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=u0Ceku5uwY3Rhyqmj+7G8YPzYEyaStJkZcVRk2j5kng=; b=gDfldD5EhZ663dWnFq8W9HDNCZENFQ3QWdm5IjSZ3wdmwsFskcmRGYPaZ3axv/FXm/dKO/DYY4Zlk0nYrzv+VF1wzRVSVjsDZ7oHSpmIrwDJZJ9TmH0bx8woIiWUHNGS1DqnHH4NZ4za2GQV6f/AARTSTSSkFTj9YU2qarB4OlY= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1774016500331981.797184085437; Fri, 20 Mar 2026 07:21:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3aia-0002y9-A6; Fri, 20 Mar 2026 10:20:52 -0400 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 1w3aiV-0002wI-St for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:47 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3aiS-0007QH-PJ for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:47 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8YO2i3950545; Fri, 20 Mar 2026 14:20:33 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cvy9s1kgm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:32 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KCoWWF030490; Fri, 20 Mar 2026 14:20:32 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb464-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:32 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2Jh016730; Fri, 20 Mar 2026 14:20:31 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-7; Fri, 20 Mar 2026 14:20:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=u0Cek u5uwY3Rhyqmj+7G8YPzYEyaStJkZcVRk2j5kng=; b=rIkyGOFwjQ2Yo/4RLpIIc uadqLmgHnXUu2j+T55B9p1anOUp79kogWfYczBOBP1yPTIqV4WfWKBDqSo01jTCn JaWIhkPedyAb+EzaJzPpweYMphBRAV5Zp/vT6wLhBdZ2w4nI+0Ei1FWzCSLI0rkT zj19adOJ2n89Rz1g+qNhIzQ0xQ4O+9BfSU66ebLHzfz0OknW+Y+5gCVwNXlAbULY qr45aDahd6T+FgHfCPNPIqBZmGWdm2IfKBL31I16xB0reX4tzzj/9/G/NY1p0tQb FdVUU7+pZJZN0hOJVL+f/OUQxtdeQkATuVOmTK3RcW2SVW0y5XgCgfob47HXltbG g== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 06/14] virtio-net: detect VirtIONet MAC addr mid-migration change Date: Fri, 20 Mar 2026 14:20:07 +0000 Message-ID: <20260320142015.3856652-7-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Authority-Analysis: v=2.4 cv=X5Vf6WTe c=1 sm=1 tr=0 ts=69bd57b1 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=3I1J8UUJPc9JN9BFgKH3:22 a=yPCof4ZbAAAA:8 a=9wsuJtwwkntus7d062oA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfXyyFzzK7o/aBO 3KQXYq37R7JjW4bTVqd7R2C8qfza03KtRDB4/JlHQNjFoTI2RxS03q+eS/qUCoWeYpbgswLe/R/ E4DobyzYWovLnLddn/jsSL1E3RBUcqEdCsDpgBvUqnN+EylDSoiHEJX8IedTBMVCrNzlS4VD9Lj +wdY4JCqgaH4ifz/Gy9hCalXNoX+5y5ckxxXKRJ/nyfbvHZpqySThGThlX3AEcIsS/TT1h654W2 Ktre2lEWg/Mdd0l+ivI8Dj1kzZPBO8wDOakDlmHSVRN7QLe8yYDrscOcr6wNniXgcqugOuoyvMM oXEFBr0FTpLJBwWt3haeMxeZ6HrC2L4r8uVw2mmIoCylTAzbNXyo+B1xnmy/TDCEnysbxSSOrGN TBp5fWEFGyNJLL4MBmRxuA+KlKltHgSFYbq7p1xEl+Z0x7zhCyNdGBe9OfORULS+xKjsEmwXHIs pDeomjxOf19fJTaCweQ== X-Proofpoint-GUID: p0YQkDncQrnu9JJj-q7vy6oDV1X4PGEC X-Proofpoint-ORIG-GUID: p0YQkDncQrnu9JJj-q7vy6oDV1X4PGEC 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=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list 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 @oracle.com) X-ZM-MESSAGEID: 1774016503168158500 Content-Type: text/plain; charset="utf-8" This patch saves the virtio-net device's MAC address to compare with later during the stop-and-copy phase. Also introduce VirtIONetMigration, a per-device migration scratch structure used to store early snapshots of VirtIONet state for later delta comparison. Signed-off-by: Jonah Palmer --- hw/net/virtio-net.c | 15 +++++++++++++++ include/hw/virtio/virtio-net.h | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index ca4385df1a..4f14bba510 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3869,6 +3869,7 @@ static int virtio_net_early_pre_save(void *opaque) VirtIONet *n =3D opaque; VirtIODevice *vdev =3D VIRTIO_DEVICE(n); VirtIODevMigration *vdev_mig =3D vdev->migration; + VirtIONetMigration *vnet_mig =3D n->migration; =20 vdev_mig->status_early =3D vdev->status; =20 @@ -3880,6 +3881,10 @@ static int virtio_net_early_pre_save(void *opaque) } else { vdev_mig->config_early =3D NULL; } + + /* VirtIONet MAC info snapshot */ + memcpy(vnet_mig->mac_early, n->mac, ETH_ALEN); + return 0; } =20 @@ -4108,6 +4113,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) } else { vdev->migration =3D g_new0(VirtIODevMigration, 1); vdev->migration->early_load =3D false; + n->migration =3D g_new0(VirtIONetMigration, 1); =20 vmstate_register_any(VMSTATE_IF(n), &vmstate_virtio_net_early,= n); virtio_delta_vmsd_register(vdev); @@ -4165,6 +4171,9 @@ static void virtio_net_device_unrealize(DeviceState *= dev) g_free(vdev->migration); vdev->migration =3D NULL; =20 + g_free(n->migration); + n->migration =3D NULL; + vmstate_unregister(VMSTATE_IF(n), &vmstate_virtio_net_early, n); virtio_delta_vmsd_unregister(vdev); } @@ -4257,6 +4266,7 @@ static bool dev_unplug_pending(void *opaque) static bool virtio_net_has_delta(VirtIONet *n, VirtIODevice *vdev) { VirtIODevMigration *vdev_mig =3D vdev->migration; + VirtIONetMigration *vnet_mig =3D n->migration; =20 /* Has the VirtIODevice's status changed? */ if (vdev->status !=3D vdev_mig->status_early) { @@ -4272,6 +4282,11 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtI= ODevice *vdev) return true; } =20 + /* Has the VirtIONet's MAC info changed? */ + if (memcmp(n->mac, vnet_mig->mac_early, ETH_ALEN) !=3D 0) { + return true; + } + /* * Always return true for now until we're able to detect all possible * changes to a VirtIONet device. diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index ddb141fefc..280155366c 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -167,8 +167,17 @@ typedef struct VirtIONetQueue { struct VirtIONet *n; } VirtIONetQueue; =20 +/** + * struct VirtIONetMigration - VirtIONet migration structure + * @mac_early: MAC address early migration snapshot. + */ +typedef struct VirtIONetMigration { + uint8_t mac_early[ETH_ALEN]; +} VirtIONetMigration; + struct VirtIONet { VirtIODevice parent_obj; + VirtIONetMigration *migration; uint8_t mac[ETH_ALEN]; uint16_t status; VirtIONetQueue *vqs; --=20 2.51.0 From nobody Sun Mar 22 14:28:26 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=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1774016765; cv=none; d=zohomail.com; s=zohoarc; b=buaG3zOT+7JukAfTP0LlIDyBhdGLMHqAPuB1Bilse9Wj8uAPDVMFmegGUw60L1Espr2dwfRyTMjdVEWVZ0VApnKQh0xscdnrIoFmuHwtR+rKNg+CzD5IWVw/vshg7xQ21zfV8XWDRJPldRocVjtMAqmanUTS8Vo2JsQQvJMxDrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016765; 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=CtDC4SmxftQNWsi8FwdOovszRY7UDOffW9Wp0/30uS8=; b=f1mkQKTo5JjXf8NGfMyuMZb/LmRuQcdxcRWCM4ho1LPh6r4eo9otTPUbsMBKulmrlAewMfZhj6XL3289ATsU2IaTgA5tLhPojpQoPyxNpnkaH736HO7wokYFD1xPPVkCKUFbbqNa2NSGqAv6f4Gb1q15hCW/+R4x7kJcj+Si1ro= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1774016765651382.3886796157758; Fri, 20 Mar 2026 07:26:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3anU-0000QE-Qs; Fri, 20 Mar 2026 10:25:56 -0400 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 1w3anT-0000Q0-2Z for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:25:55 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3anP-0008DC-Bf for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:25:54 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8YS0d2600858; Fri, 20 Mar 2026 14:20:34 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cvx8x9thd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:34 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KDON7h030599; Fri, 20 Mar 2026 14:20:33 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb46w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:33 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2Jj016730; Fri, 20 Mar 2026 14:20:33 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-8; Fri, 20 Mar 2026 14:20:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=CtDC4 SmxftQNWsi8FwdOovszRY7UDOffW9Wp0/30uS8=; b=WlSYdFbHjqUgBSKJ9Ceiv pwQYFBcY7+t0nM9U/TecTVyKggxvdTaIM9n0oPA4T0Iu0wDiEa1d/X9aekpF7pAM znrNoNP51OVgdn5NkLJUxQbjziqubeQaJap6ruwN7owTJvlXoYcUcqGiou5fiNmi u/Wbc1G4Q24edYQuGxzLHglMtoX++y7pzY5lrm7/wPr6lJGTwwLrHwjHbUYUwaL2 dKUhVb4ryecDUG/F/dkthOf74ZAFhJhYZIOiXtNP3k1kzB60Aqx0kDSZeTwztVMp q5YNtUBQU/0oazYeJots4e411enDsQ1SIv1QxRGv0jASKL5Ee9SU5Lq0Z+T0xLYG g== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 07/14] virtio-net: detect VirtIONet MAC table mid-migration changes Date: Fri, 20 Mar 2026 14:20:08 +0000 Message-ID: <20260320142015.3856652-8-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Proofpoint-GUID: 8xT3ica83MfohWhuayaEWfe9FF7EzM6n X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfXwOoMA4IfuWon QsImUiXTayI8bfHR0qnZDFdd/yN0ihfUFCYq3yBkijOMWMVWSSpXFdXuP0po/llXTZSq0zudzXa oyOvgofj6FVQmJcdSQ7x2nx9vH833krkQWaR9+lHagwiq61Pl7HrvQ4PscHXtlZaUethVjSj+ZE sG6O8TUjhlkUoUM7R4SjHOSxXEpNekJnweuZ8WmPteHehWKux9r2HnYoyw/i93tsy4pUswpuVpC J/+9zKx5esBv9QkyJXmsu0ZjECS5Eqit9BsxkoWMUyV5sAsOiilkUvxlHco9ZLjdc9RuEUjNMfm zYaXd+xrDIasCZ4ZIqxW8gWha+ltFnOA1t77AYyj0PS11ihBxUWcYoslonn6kfKzMXUM4XumBXP ofM5M7vZbpeqxkmaRvA6xyigiT4iH305srin+wKme2bgB0jpbGyaBS/rax+AXwPc1wbREYFUbGb d8wT+H796fynUyuj8zA== X-Authority-Analysis: v=2.4 cv=dJmrWeZb c=1 sm=1 tr=0 ts=69bd57b2 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=RD47p0oAkeU5bO7t-o6f:22 a=yPCof4ZbAAAA:8 a=uv6Ftj0Ief3x8EZWz6YA:9 X-Proofpoint-ORIG-GUID: 8xT3ica83MfohWhuayaEWfe9FF7EzM6n 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=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list 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 @oracle.com) X-ZM-MESSAGEID: 1774016768048154100 Content-Type: text/plain; charset="utf-8" This patch saves the virtio-net device's MAC table information to compare with later during the stop-and-copy phase. We leave out mac_table.first_multi since it's derived post-load. Note: we store the exact mac_table.in_use value and the MIN macro is only used to bound copy & compare byte spans for safety. Signed-off-by: Jonah Palmer --- hw/net/virtio-net.c | 34 ++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio-net.h | 8 ++++++++ 2 files changed, 42 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 4f14bba510..2dd130777e 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3884,6 +3884,26 @@ static int virtio_net_early_pre_save(void *opaque) =20 /* VirtIONet MAC info snapshot */ memcpy(vnet_mig->mac_early, n->mac, ETH_ALEN); + vnet_mig->mtable_in_use_early =3D n->mac_table.in_use; + vnet_mig->mtable_uni_overflow_early =3D n->mac_table.uni_overflow; + vnet_mig->mtable_multi_overflow_early =3D n->mac_table.multi_overflow; + /* + * Allocate baseline buffer once. Only copy the used slice each time. + * This avoids repeated allocations and keeps memcmp fast + */ + if (!vnet_mig->mtable_macs_early) { + vnet_mig->mtable_macs_early =3D + g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN); + } + /* + * Copy used portion only. Cap byte span with MIN for safety even if + * a buggy config reports more than capacity. + */ + if (vnet_mig->mtable_in_use_early) { + uint32_t used =3D MIN(vnet_mig->mtable_in_use_early, (uint32_t)MAC= _TABLE_ENTRIES); + size_t bytes =3D (size_t)used * ETH_ALEN; + memcpy(vnet_mig->mtable_macs_early, n->mac_table.macs, bytes); + } =20 return 0; } @@ -4171,6 +4191,8 @@ static void virtio_net_device_unrealize(DeviceState *= dev) g_free(vdev->migration); vdev->migration =3D NULL; =20 + g_free(n->migration->mtable_macs_early); + n->migration->mtable_macs_early =3D NULL; g_free(n->migration); n->migration =3D NULL; =20 @@ -4286,6 +4308,18 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtI= ODevice *vdev) if (memcmp(n->mac, vnet_mig->mac_early, ETH_ALEN) !=3D 0) { return true; } + if (n->mac_table.in_use !=3D vnet_mig->mtable_in_use_early || + n->mac_table.uni_overflow !=3D vnet_mig->mtable_uni_overflow_early= || + n->mac_table.multi_overflow !=3D vnet_mig->mtable_multi_overflow_e= arly) { + return true; + } + if (n->mac_table.in_use) { + uint32_t used =3D MIN(n->mac_table.in_use, (uint32_t)MAC_TABLE_ENT= RIES); + size_t bytes =3D (size_t)used * ETH_ALEN; + if (memcmp(n->mac_table.macs, vnet_mig->mtable_macs_early, bytes) = !=3D 0) { + return true; + } + } =20 /* * Always return true for now until we're able to detect all possible diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 280155366c..1e1f1a3995 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -170,9 +170,17 @@ typedef struct VirtIONetQueue { /** * struct VirtIONetMigration - VirtIONet migration structure * @mac_early: MAC address early migration snapshot. + * @mtable_in_use_early: In-use MAC table entries. + * @mtable_uni_overflow_early: Unicast overflow MAC table entries. + * @mtable_multi_overflow_early: Multicast overflow MAC table entries. + * @mtable_macs_early: MAC table entries. */ typedef struct VirtIONetMigration { uint8_t mac_early[ETH_ALEN]; + uint32_t mtable_in_use_early; + uint8_t mtable_uni_overflow_early; + uint8_t mtable_multi_overflow_early; + uint8_t *mtable_macs_early; } VirtIONetMigration; =20 struct VirtIONet { --=20 2.51.0 From nobody Sun Mar 22 14:28:26 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=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1774016541; cv=none; d=zohomail.com; s=zohoarc; b=NSSYVibzmwxI9xvyX+UkgL932kPAjYaqtF3KXQI5UA4rXvaDOQzU/8M3GPvtZZk3T81DcFjU4bXzx3Xm36ePtmQsVnIFjrnrbd4FCZ6R+exznPzVUeyEWjeOoVsSj1pxHd84wbmSYxjZompUQfyJZ4BVJpNXQDh02dlrgvZy9sA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016541; 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=eLmq75GeGNkeMqSupIjOA38TXJGPu/+T/5yeiI4IKGc=; b=XOMvNMUBVKSXzr+/mz55f0G+blf3/7dRska8f5WMYHPdaJsXIsaBMMgFmAXDsu9uptfIPqKZu/xKcKnkkhqj8nVnbD95H9EzOGZsO5B0rNaV7s8BloAQ2TbgB9pZieYWW0BC2V6ZSdEaTougwiy8+ZJsMcCkROOtzmUag3xoFpM= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1774016541609181.93353727435442; Fri, 20 Mar 2026 07:22:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3aih-0002zw-08; Fri, 20 Mar 2026 10:20:59 -0400 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 1w3aie-0002z5-Ve for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:57 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3aic-0007Sn-No for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:56 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8Y4Ob3254798; Fri, 20 Mar 2026 14:20:36 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cvyj69pce-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:36 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KDGJQn003488; Fri, 20 Mar 2026 14:20:35 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb484-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:35 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2Jl016730; Fri, 20 Mar 2026 14:20:35 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-9; Fri, 20 Mar 2026 14:20:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=eLmq7 5GeGNkeMqSupIjOA38TXJGPu/+T/5yeiI4IKGc=; b=gu3ss3icfa80m2XRddZ8I T5FT/Y9nyHWc7atf6X3P2AAOWevTAn5v5M2FsTHrztnukKvoxcTSsm6/WTHAtCyt XRYOUrxlTz7LIGBdw5MP7mY4m7Rj9aU4XpbO8Eharu6k/LR3EA21tESxklcZY3XI 0cnE1dVVmbqw5zeMfVRkhHouq/CMfqZTbJ3SHTX0uFUIlYhaZuPRW35W8aAiZLw/ UY2IilsiL7aREVyw/EKBnwZtgJXSZsFho8/AxfaF8zXAGlWm5ZjXsE2g2Stxyqj1 PkUCkQXLRxzcQmmRoGEe56KYtJmTwQ+OA+ntoTwLB6NNqxiSkU1P36vWf0mrKprs g== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 08/14] virtio-net: detect VirtIONet status mid-migration change Date: Fri, 20 Mar 2026 14:20:09 +0000 Message-ID: <20260320142015.3856652-9-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Authority-Analysis: v=2.4 cv=LKFrgZW9 c=1 sm=1 tr=0 ts=69bd57b4 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=EIcjfB9IiI4px24ztqRk:22 a=yPCof4ZbAAAA:8 a=05msrqz8p71NSpwwBZQA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfX2daJWhYEOrya n82EZAxl+1ZSqqkZ8WcdTBUv7JWb3Ym6ntr4vNJm2Jrfo0eeTtZsGExMpEyuofw+G3FF38k/mNW mWOG9fQB6A/1gPcCgE+WiCYSsdR/NhwrZFSAouVt9UFx8BE/shyUryvnJO7EvZkQbuEoP43mYH8 J9IQa9LsMqGwhTiEBSn1Oj+vFcRlEbqQOLoJZQ3uvQNjs49vMeLBq3zhC2oWnpHDDRffNSnshIc u7jfPHu4VvDdiliKbZxSqcb7QFtWz0cZvyS/i8kIOOpT671dPo85/BZspP7y1IN+ruspkw42x5V NWQ5uzWAN0Yi24KID5aWUu2T+lLZhe0H8zLVEvCkZxB3T0wxINItSwrE07LZiSeW6QWJK463wgc +Cem8mVIt65qOaPGD2RsW1aOtlJcPBjsHxKiDxDFARirVMzk2Qvf8rN1MPL1MJflc2y5yo9QrGC 3Ow2E/2fzRfhb5lGgaQ== X-Proofpoint-GUID: UQv5J_Y4hHZ7MB1lJovp-UFTEFUKB2nI X-Proofpoint-ORIG-GUID: UQv5J_Y4hHZ7MB1lJovp-UFTEFUKB2nI 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=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list 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 @oracle.com) X-ZM-MESSAGEID: 1774016542450154100 Content-Type: text/plain; charset="utf-8" Save VirtIONet's status field during early migration and compare it again during stop-and-copy. VirtIONet keeps its own status bits here, including VIRTIO_NET_S_LINK_UP and VIRTIO_NET_S_ANNOUNCE. Signed-off-by: Jonah Palmer --- hw/net/virtio-net.c | 6 ++++++ include/hw/virtio/virtio-net.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 2dd130777e..88ce33b1d2 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3872,6 +3872,7 @@ static int virtio_net_early_pre_save(void *opaque) VirtIONetMigration *vnet_mig =3D n->migration; =20 vdev_mig->status_early =3D vdev->status; + vnet_mig->status_early =3D n->status; =20 /* VirtIODevice config buffer snapshot */ g_free(vdev_mig->config_early); @@ -4304,6 +4305,11 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtI= ODevice *vdev) return true; } =20 + /* Has the VirtIONet's status changed? */ + if (n->status !=3D vnet_mig->status_early) { + return true; + } + /* Has the VirtIONet's MAC info changed? */ if (memcmp(n->mac, vnet_mig->mac_early, ETH_ALEN) !=3D 0) { return true; diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 1e1f1a3995..59345f1811 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -169,6 +169,7 @@ typedef struct VirtIONetQueue { =20 /** * struct VirtIONetMigration - VirtIONet migration structure + * @status_early: VirtIONet status snapshot. * @mac_early: MAC address early migration snapshot. * @mtable_in_use_early: In-use MAC table entries. * @mtable_uni_overflow_early: Unicast overflow MAC table entries. @@ -176,6 +177,7 @@ typedef struct VirtIONetQueue { * @mtable_macs_early: MAC table entries. */ typedef struct VirtIONetMigration { + uint16_t status_early; uint8_t mac_early[ETH_ALEN]; uint32_t mtable_in_use_early; uint8_t mtable_uni_overflow_early; --=20 2.51.0 From nobody Sun Mar 22 14:28:26 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=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1774016561; cv=none; d=zohomail.com; s=zohoarc; b=n/U2KpkMfM1C38r8wbQp6MrcVyCgQl5Er3a7+Kv29FzjfvHxyZ25Qeo6LUoP6BSkCGOG9DMe9h2F/UO4ZEkXsvWYFkexXlykGaBcdCTZl2EMD0sMNfteba66IHQSJTVtOPIRixePgSB5nX2D7jxsRYYISW0JIzPCYv6XInVX1WE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016561; 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=WZW6cfdUQ7XelXX/kKjZrZAeuGEVV32c0tTyGafjG/Y=; b=eLWW3wTNOSiSTRqXGRWnH+BefUpeMPByc+Uia/se4dOEEUf+b2KDIDqZnWVIR0iSePnu9ynvxbxPYtYwxu0w3O4BFMYbcbI/rX1548TRepAcYwKO7Yitdoi2tJZg1PqTPqM8x8Z7nNNYanEflY3fO316gTYh17hdWYrRwfv9I68= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1774016561781634.0712341278196; Fri, 20 Mar 2026 07:22:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3aie-0002z4-C6; Fri, 20 Mar 2026 10:20:56 -0400 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 1w3aic-0002ym-NH for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:54 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3aib-0007SU-5H for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:54 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8YgqU2601043; Fri, 20 Mar 2026 14:20:38 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cvx8x9thh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:37 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KCGFcf030802; Fri, 20 Mar 2026 14:20:37 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb48w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:37 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2Jn016730; Fri, 20 Mar 2026 14:20:36 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-10; Fri, 20 Mar 2026 14:20:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=WZW6c fdUQ7XelXX/kKjZrZAeuGEVV32c0tTyGafjG/Y=; b=g2Cc8n5b7YokDjrZgZU6h DrMGtoP7bNhH29vAMGAtdfwiyjqH0h74RduZ4eauFGiSyhu42moOIgdnW5b/uu5e jPIoGhr5hY7QK8OoJidhOfcvR5ZDeGCFQebAicbaAQ/J4jFOL71vSk+ZNPCAyUqe U3I4j1PkxcZNUWsrUPu0+AmW7+IvHTzswdR6ndQKv09Toz8e/qbhK+bA0QNS5gXK I/i6v8/hVivNrwHYN990Iyl8SeOKQLkTkM/HRYkZN8VbbP22WEZ9PIuf3iopsx9g PIOwuqTcm0dWB/xqcerlmUD+DjT7rz9oP7oJKgL7uKjD7iIgsXeFrc7MBUtQs4CC g== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 09/14] virtio-net: detect VirtIONet Rx filter mid-migration changes Date: Fri, 20 Mar 2026 14:20:10 +0000 Message-ID: <20260320142015.3856652-10-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Proofpoint-GUID: Yi2I8xQfZRn7ZtBEGdBxU_z3To095nWJ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfXy9KvEGOscD0T QLfDMT7UUmOZvG4gDdllAQ3JruaB2aWwXhIx+epkw19Z/AUeiFBVl/IUC19ZSNp1azwmCl2pF0W mGf5hUV5KAEVZOTIXxHmM1ytSDpttVx79RCOMs1VHHDzs9QXYFp7o+kxfmRBCIEXZImRvgII/Jn RYefriLoHqH2XhQJbkVyYkImvZcYnpo9TzQg6nz+G/CX0dQECl+FgwTV/tiww203R6xpCK3aRoD /hNnpPUOpI7XfDRmA/lsb7LbhcM+iMphf+IUKcVytZM6YH+l3Q5zKuC0oHwvr4xpdsqfMnxaa+M WbkpOvjD62BhUq/yQRdfohUJ/qrTon0Mz93Q8MmR2aYzWKCFR9/3iYvkCPQ6RUc6ExmOtHzqSvW BoO4CKwbUdOcXddlQS41YvpXwAOa/wQMQsz9FwdpglimqZQoma9gpc0CpZ1/yz9HIX4NbNGBeEM qy+DjxLqaLyjZpPXklQ== X-Authority-Analysis: v=2.4 cv=dJmrWeZb c=1 sm=1 tr=0 ts=69bd57b5 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=RD47p0oAkeU5bO7t-o6f:22 a=yPCof4ZbAAAA:8 a=nK3-aE-XDlKPtvZYpUgA:9 X-Proofpoint-ORIG-GUID: Yi2I8xQfZRn7ZtBEGdBxU_z3To095nWJ 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=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list 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 @oracle.com) X-ZM-MESSAGEID: 1774016562728154100 Content-Type: text/plain; charset="utf-8" This patch saves the virtio-net device's Rx filter flags as a bit-packed uint8_t to compare with later during the stop-and-copy phase. A local enum VirtIONetRxFlags and static inline virtio_net_rx_flags_pack function is introduced to bit-pack VirtIONet's promisc, allmulti, alluni, nomulti, nouni, and nobcast into a single byte for easier comparison. Signed-off-by: Jonah Palmer --- hw/net/virtio-net.c | 28 ++++++++++++++++++++++++++++ include/hw/virtio/virtio-net.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 88ce33b1d2..42c585142d 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3864,6 +3864,26 @@ static bool failover_hide_primary_device(DeviceListe= ner *listener, return qatomic_read(&n->failover_primary_hidden); } =20 +enum VirtIONetRxFlags { + VNET_RX_F_PROMISC =3D 1u << 0, + VNET_RX_F_ALLMULTI =3D 1u << 1, + VNET_RX_F_ALLUNI =3D 1u << 2, + VNET_RX_F_NOMULTI =3D 1u << 3, + VNET_RX_F_NOUNI =3D 1u << 4, + VNET_RX_F_NOBCAST =3D 1u << 5, +}; + +/* Pack current Rx filter flags into a single uint8_t for comparison */ +static inline uint8_t virtio_net_rx_flags_pack(const VirtIONet *n) +{ + return (n->promisc ? VNET_RX_F_PROMISC : 0) | + (n->allmulti ? VNET_RX_F_ALLMULTI : 0) | + (n->alluni ? VNET_RX_F_ALLUNI : 0) | + (n->nomulti ? VNET_RX_F_NOMULTI : 0) | + (n->nouni ? VNET_RX_F_NOUNI : 0) | + (n->nobcast ? VNET_RX_F_NOBCAST : 0); +} + static int virtio_net_early_pre_save(void *opaque) { VirtIONet *n =3D opaque; @@ -3906,6 +3926,9 @@ static int virtio_net_early_pre_save(void *opaque) memcpy(vnet_mig->mtable_macs_early, n->mac_table.macs, bytes); } =20 + /* Rx filter flags snapshot */ + vnet_mig->rx_flags_early =3D virtio_net_rx_flags_pack(n); + return 0; } =20 @@ -4327,6 +4350,11 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtI= ODevice *vdev) } } =20 + /* Has the VirtIONet's Rx filter flags changed? */ + if (virtio_net_rx_flags_pack(n) !=3D vnet_mig->rx_flags_early) { + return true; + } + /* * Always return true for now until we're able to detect all possible * changes to a VirtIONet device. diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 59345f1811..9135d277ff 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -175,6 +175,7 @@ typedef struct VirtIONetQueue { * @mtable_uni_overflow_early: Unicast overflow MAC table entries. * @mtable_multi_overflow_early: Multicast overflow MAC table entries. * @mtable_macs_early: MAC table entries. + * @rx_flags_early: Bit-packed RX filters (promisc, allmulti, alluni, etc.= ). */ typedef struct VirtIONetMigration { uint16_t status_early; @@ -183,6 +184,7 @@ typedef struct VirtIONetMigration { uint8_t mtable_uni_overflow_early; uint8_t mtable_multi_overflow_early; uint8_t *mtable_macs_early; + uint8_t rx_flags_early; } VirtIONetMigration; =20 struct VirtIONet { --=20 2.51.0 From nobody Sun Mar 22 14:28:26 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=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1774016532; cv=none; d=zohomail.com; s=zohoarc; b=IE+2r53RSu3vACTBWo94jnim+oxMC5p2DZR7ho+4BI8Om3xXCeXw9oDOcxvQ8LxyYSS+1qfEEHuHRKaVC503XY6lJua88rXKm5iU5yRMPRrgaVXJWS5aRtKJwJmfwgHtoA3HtOXGfZVmBBKPSPUbGsp14B4Kk3zSldoMFf7Q/u0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016532; 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=QPkNydstWfbqDceZLKUfsIAfh5zBIBp/4EWX8VCgJDs=; b=kVUFYRq7VbL16lxdN/q6gVhXyj+wmGkXFayf/p3PW6CtEJ0s3+Ay+4vEawUs9ISVF81RLKTZ7/+WbbFzD9A0ygMhsfmg6GKKb55q0p+NckkNDP5/XLB3E77DxWjiWT1rtsGQVEGAzJD2Mu6GKrJPkGW67T6G/XY7dB/xUi/LABE= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1774016532359360.1402308891313; Fri, 20 Mar 2026 07:22:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3aig-0002zv-JM; Fri, 20 Mar 2026 10:20:58 -0400 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 1w3aif-0002z9-3u for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:57 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3aid-0007T8-JC for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:20:56 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8YlNi2499511; Fri, 20 Mar 2026 14:20:39 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cw07rhsek-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:39 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KCs2Oh030277; Fri, 20 Mar 2026 14:20:38 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb49f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:38 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2Jp016730; Fri, 20 Mar 2026 14:20:38 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-11; Fri, 20 Mar 2026 14:20:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=QPkNy dstWfbqDceZLKUfsIAfh5zBIBp/4EWX8VCgJDs=; b=V6Ih8xlGiUhsFEhe9U8BD L0tawMhcUaRky5V3hGtxxZtecx+4WX6+7Rqmfy7dgLP74ayrGI7lQCE33j9bGy1b 1C4vF58CVzs2yhgj2snpPuIe/wJKy/FLIabDVDWFg8Z5JCvlX+wz3UUIppSKXmwG nSjnDVTnm6US+BaKSNYFdd/h28Z9H3280+/pIA72yOQU8J+WU4CrUnkEEBFpOPry /Dlpv2lWEwWtWdXfQA8FrzCaU2Xs0fhgFnRe/xsWm+CDYwLEjNMyFUHw2PWeQB5a GDXWG26J1RHdXGtpWauSMDX5BeTc23gTrebJUHIAfB43zXnjdHLUuKVfQojsQY5P A== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 10/14] virtio-net: detect VirtIONet VLAN filter table changes Date: Fri, 20 Mar 2026 14:20:11 +0000 Message-ID: <20260320142015.3856652-11-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Authority-Analysis: v=2.4 cv=HcsZjyE8 c=1 sm=1 tr=0 ts=69bd57b7 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=7Gl3-_t3PgB9XO-mQDs3:22 a=yPCof4ZbAAAA:8 a=uRB8GxAVLDhh3WKyutIA:9 X-Proofpoint-ORIG-GUID: B2hfockT636NSvyTkjRpq3dtqq6eRwX7 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfXylgWyGHO78jq cGQ2lvDcLXWOzeqpzcXodxX9a8o4HVBkhk1xd7QQ6XlzPssSzF3tp3XPGmCHNG4zBkAJTppuGHc 9JNPHT244MuDKPwYeIDgX1/Bs/VTEhEB6+rbmZxq6eE8djhwXGa5o5gyR5EbIQ9i/23qhPu8RL6 syefSiIQ6CYABRvGBBFXH7Lvr7nz4Ryu3kzh1Wk2XRnTSevEGnfYsjpddTE5dJAOWRxwP5O9jA1 xr/Rw7dPlKDbHY51fmAWRNYDT2cnwMAySnq/tpw8F2tMI81RX5BhFUjKj/M7HxGInY9L/FX+ju/ Akh5gGWFzYFB10JdJAHrwo5Gxq7NgyRYCEh73Mlpdd6qxgOQOiHupOwu45ONpdqmnF5UrOypq/i 4lfU3Om4WrZk4FP/mvIWls76l+AhTeFk+0+oSGzJQrntauWTFVehydMyxk0weDgN5T87UBs4x02 63UKHKoXCrZGOf1SPgQ== X-Proofpoint-GUID: B2hfockT636NSvyTkjRpq3dtqq6eRwX7 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=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list 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 @oracle.com) X-ZM-MESSAGEID: 1774016533063158500 Content-Type: text/plain; charset="utf-8" Save the current state of virtio-net's VLAN filter table at early migration time to compare with later during the stop-and-copy phase. Signed-off-by: Jonah Palmer --- hw/net/virtio-net.c | 14 ++++++++++++++ include/hw/virtio/virtio-net.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 42c585142d..b3f71d8f84 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3890,6 +3890,7 @@ static int virtio_net_early_pre_save(void *opaque) VirtIODevice *vdev =3D VIRTIO_DEVICE(n); VirtIODevMigration *vdev_mig =3D vdev->migration; VirtIONetMigration *vnet_mig =3D n->migration; + size_t vlans_size =3D (size_t)(MAX_VLAN >> 3); =20 vdev_mig->status_early =3D vdev->status; vnet_mig->status_early =3D n->status; @@ -3929,6 +3930,12 @@ static int virtio_net_early_pre_save(void *opaque) /* Rx filter flags snapshot */ vnet_mig->rx_flags_early =3D virtio_net_rx_flags_pack(n); =20 + /* VLAN filter table snapshot */ + if (!vnet_mig->vlans_early) { + vnet_mig->vlans_early =3D g_malloc0(vlans_size); + } + memcpy(vnet_mig->vlans_early, n->vlans, vlans_size); + return 0; } =20 @@ -4217,6 +4224,8 @@ static void virtio_net_device_unrealize(DeviceState *= dev) =20 g_free(n->migration->mtable_macs_early); n->migration->mtable_macs_early =3D NULL; + g_free(n->migration->vlans_early); + n->migration->vlans_early =3D NULL; g_free(n->migration); n->migration =3D NULL; =20 @@ -4355,6 +4364,11 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtI= ODevice *vdev) return true; } =20 + /* Has the VirtIONet's VLAN filter table changed? */ + if (memcmp(n->vlans, vnet_mig->vlans_early, MAX_VLAN >> 3) !=3D 0) { + return true; + } + /* * Always return true for now until we're able to detect all possible * changes to a VirtIONet device. diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 9135d277ff..5df2dd0513 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -176,6 +176,7 @@ typedef struct VirtIONetQueue { * @mtable_multi_overflow_early: Multicast overflow MAC table entries. * @mtable_macs_early: MAC table entries. * @rx_flags_early: Bit-packed RX filters (promisc, allmulti, alluni, etc.= ). + * @vlans_early: VLAN filter table snapshot. */ typedef struct VirtIONetMigration { uint16_t status_early; @@ -185,6 +186,7 @@ typedef struct VirtIONetMigration { uint8_t mtable_multi_overflow_early; uint8_t *mtable_macs_early; uint8_t rx_flags_early; + uint8_t *vlans_early; } VirtIONetMigration; =20 struct VirtIONet { --=20 2.51.0 From nobody Sun Mar 22 14:28:26 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=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1774016560; cv=none; d=zohomail.com; s=zohoarc; b=mSGjNB6AfHDOcwvvhXD+0qFsW0TjCjZJuqZ84raBmbTv/EW3G/Mw6bRa7NSlsH/7aPPEnMlRgvvjhcPC473gi1UJ0Toep/oYnQ+fhd+nR7ViXpC3tHDUU/iJAU3U3T7tKcqDT8JjA0/TwCWyFmSl4J/6jTtuOVCWlWu7tYO2adU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016560; 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=JHqAd7pd2hBqwvzRs6exVJIc5gcSW1KgIUAEh93nhxs=; b=j7nYfcHcf6jXcWgmHslJck1xAW6qJwXteuVCta48bX4qBgAZMydN5v2xBzGXL7keREVijLTn0g+ocFYbZM9xLESrKl4jtLLynRcWfUjc263ZbJ3pP+EPrL9S1RZQWOcXr8hP+Ai3cN5dCAn5dK/gGTuFGiOvwcNECeGX7VOmqlQ= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177401656035978.65853829652747; Fri, 20 Mar 2026 07:22:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3aij-000317-Bd; Fri, 20 Mar 2026 10:21:01 -0400 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 1w3aii-00030a-Fl for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:21:00 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3aig-0007Tu-LX for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:21:00 -0400 Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8Y3OM3323029; Fri, 20 Mar 2026 14:20:41 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cvxk8htk8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:41 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KDmXNA030464; Fri, 20 Mar 2026 14:20:40 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb4a7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:40 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2Jr016730; Fri, 20 Mar 2026 14:20:39 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-12; Fri, 20 Mar 2026 14:20:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=JHqAd 7pd2hBqwvzRs6exVJIc5gcSW1KgIUAEh93nhxs=; b=c0ujCpVjzWwlD+0mMJPW6 Hsn0mijCt+ZW96+N2CR1oQAmnANKPjZhNjGQu04s3lAJoBKv6vr7fEt68N8R5MVZ Jrnk4S53CHvYRjcoWyVxEwYB33v3kQsMAn4yAbfDPeLBEFa7Yx2j+e0oX7TF9OXh 1PbT3yBQt5kDcDuslL0liA5KE5BFLmsIaThUnIzJGs6pPSVrIFQXrsG9heEYI3dm cPKJb5JBxj9QhXYE5QSVG8Ir1m5GoQIW2xIIEw9boTXTnSosm8NNKPUQQ803HHio xDPNabKWpGj+QYzE0VO+OEA7PY5MtGdIQgpD120jX3jrMCAW2K8Kny/2k4Bew0RW g== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 11/14] virtio-net: detect VirtIONet guest offload & MQ mid-migration changes Date: Fri, 20 Mar 2026 14:20:12 +0000 Message-ID: <20260320142015.3856652-12-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfXx7GQF14C0HsV YtNvmURLzaK5FDnUJmW1REviiDnAw+VHRx8WAK8c1F/OY+gB07uCYE0ChZqkEhVLaMSj6eKpu68 Mr7YopJiAM63MJQ8LvLBov4SRx+Dm8/TfMHPFcSpmebiyif90wm4b3wa2cyAqFyl08OUfvzpzZM TCQoIBrm32hccPwgltzt5OnlLM5Fqj7jeuh00KNLOopeVx6uN9eDmR+SABvlnVBp54NX9f2uVJO ODa3BJrTnxWR5WFM7E7e4sysFJSajJ+OiQKRo8b+XEaIU65luQWq6oANQjRVLuCH8biyevKUdIV qmKw/096ZBGZEQ5R7fsSTejGMtcxaYB2Cu6lWlxmeKLaI/eZfsTIOew+djrkdo8/YLpxJA7loVm c6jBSa07022ntAKkiA4PRQj9eQhXFO8L88l09M9Dhh48NUEQXBZLcKLwtj/biXwHQanQCQdHSzh OfC4kTkqYFsZXHKWJpQ== X-Authority-Analysis: v=2.4 cv=AI0/m/Lt c=1 sm=1 tr=0 ts=69bd57b9 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=x0eKOSpe3m1H3M0S9YoZ:22 a=yPCof4ZbAAAA:8 a=rw_dZD_eKbb5xvwdQzAA:9 X-Proofpoint-GUID: PEmg51LwUQb-_BlgdrSCD13jnJxkLLSK X-Proofpoint-ORIG-GUID: PEmg51LwUQb-_BlgdrSCD13jnJxkLLSK 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=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list 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 @oracle.com) X-ZM-MESSAGEID: 1774016562635154100 Content-Type: text/plain; charset="utf-8" Save the state of virtio-net's guest offloads and multiqueue configuration at early migration time to compare with later during the stop-and-copy phase. Signed-off-by: Jonah Palmer --- hw/net/virtio-net.c | 20 ++++++++++++++++++++ include/hw/virtio/virtio-net.h | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index b3f71d8f84..2c0b42debb 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3936,6 +3936,13 @@ static int virtio_net_early_pre_save(void *opaque) } memcpy(vnet_mig->vlans_early, n->vlans, vlans_size); =20 + /* Guest offloads snapshot */ + vnet_mig->guest_offloads_early =3D n->curr_guest_offloads; + + /* Multiqueue state snapshot */ + vnet_mig->mq_early =3D n->multiqueue; + vnet_mig->queue_pairs_early =3D n->curr_queue_pairs; + return 0; } =20 @@ -4369,6 +4376,19 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtI= ODevice *vdev) return true; } =20 + /* Has the VirtIONet's guest offloads changed? */ + if (n->curr_guest_offloads !=3D vnet_mig->guest_offloads_early) { + return true; + } + + /* Has the VirtIONet's multiqueue state changed? */ + if (n->multiqueue !=3D vnet_mig->mq_early) { + return true; + } + if (n->curr_queue_pairs !=3D vnet_mig->queue_pairs_early) { + return true; + } + /* * Always return true for now until we're able to detect all possible * changes to a VirtIONet device. diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 5df2dd0513..5d6179fa19 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -177,6 +177,9 @@ typedef struct VirtIONetQueue { * @mtable_macs_early: MAC table entries. * @rx_flags_early: Bit-packed RX filters (promisc, allmulti, alluni, etc.= ). * @vlans_early: VLAN filter table snapshot. + * @guest_offloads_early: Guest offloads snapshot. + * @mq_early: Multiqueue state snapshot. + * @queue_pairs_early: Queue pairs snapshot. */ typedef struct VirtIONetMigration { uint16_t status_early; @@ -187,6 +190,9 @@ typedef struct VirtIONetMigration { uint8_t *mtable_macs_early; uint8_t rx_flags_early; uint8_t *vlans_early; + uint64_t guest_offloads_early; + int mq_early; + uint16_t queue_pairs_early; } VirtIONetMigration; =20 struct VirtIONet { --=20 2.51.0 From nobody Sun Mar 22 14:28:26 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=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1774016532; cv=none; d=zohomail.com; s=zohoarc; b=BjtFc7qtWzsoBcDN0857XpGP1GswJyth4QvqNoLueNrildCIiChwaU41az5EZqQImr7dk7Pps0LZgoEFsNaB2HK4JtRtMNUIZc6xjRzxnBQxAWpedBSq9zoTBcxkdfXPBtMRJcMgtQHQ0uEMjgqhxEjv1Rql0UU3JP0eG4FW3KE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016532; 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=4IRZNsKOEQvEBxuGoSOEPinbP8pM41l95Q7Te63ES10=; b=AmM/lfoPg6h69UiET01OwO9A7iDVVn30lUDyOYflnf5lONVKUAy2xsgU0vZB1ClAz4P2Um7xoPVZXONolq4+wWCQ7oRnChg4+qCtYedXIW9z/Sz2WjbiFnhJvGkbNfMtdHZ4owFYwACiM/z2fvMMWN37oCEIZhyBfADviXcSLIA= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1774016532204818.6041213948782; Fri, 20 Mar 2026 07:22:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3ail-00031o-Te; Fri, 20 Mar 2026 10:21:03 -0400 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 1w3aij-00031S-W5 for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:21:02 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3aii-0007U9-7t for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:21:01 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8Y1Pq3254709; Fri, 20 Mar 2026 14:20:42 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cvyj69pcq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:42 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KDO8G5030461; Fri, 20 Mar 2026 14:20:42 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb4ay-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:41 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2Jt016730; Fri, 20 Mar 2026 14:20:41 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-13; Fri, 20 Mar 2026 14:20:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=4IRZN sKOEQvEBxuGoSOEPinbP8pM41l95Q7Te63ES10=; b=mh1vuPJm531wFxjKRID2R aybWQIJXrbU6WRJIxmTNeug8jQoh4sTDbBjC+rusAY/tlZ361vjpFtPVsBrnnW43 KsFvGdAtlctZW+Zla+bZF3XU1CA4fjAqW/XxG2GnatOKelq84jcCJl/AMt9rFbtl BFdCnOClbCSomE1uSNuL6HzNmYtAf6G1ibmcAnSpl7cQOf5HzXzKL8w+vsz1HlWZ 2+bAhd99uEUTNi+SNEyZOWw67JzwvKqqQhpBmg5PQBR+tEFHLaB1A4m0r8cFvAel Kx+8njbH62GU/o6E5KE9Xpx7Wo0BX+kA46lEZ6rCHbEV9uSYNvuXyi+Ea0kJppYp g== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 12/14] virtio-net: detect RSS state mid-migration changes Date: Fri, 20 Mar 2026 14:20:13 +0000 Message-ID: <20260320142015.3856652-13-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Authority-Analysis: v=2.4 cv=LKFrgZW9 c=1 sm=1 tr=0 ts=69bd57ba b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=EIcjfB9IiI4px24ztqRk:22 a=yPCof4ZbAAAA:8 a=xolrWOXZR5NoubjuY-4A:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfXwa+KQBMeCwwq Xq+pA2+mHa0nT+59CbDeNpONOY2qvkrp40jx23p9Kej/LoCMprboF3g6nXPffMNdxDfEojQtYOA C9w4IB3eCAojpkYO57yAKO0mmcwK/N+s/T4YsUKGmgF4yc5/rNravsxzQ59t3wsdNVdRMLH41ZB 4fi8Xdu2OoVKm2D4cnjLTHx9evaelrXLXei8l5O0fA8t2v/0e9m+2I7uIDlL6aXHIrN43KJtZhf 8OlmvDH/s0kC3pqIdLAnXTz+YP5pya0zXGqOpoaYDsXEy3HQ9VKnaDJOQwR+Rv/ldHEFnpg3YeI pqtfWB1yXzCzcRORf9c+YJ1RRrZSh37V31xPCysWhxbyDp4eFDTTFMjdcPQNO6xyVfDSNDVJP3I SVHjFIXx+ley4Tx1EdHBJoHcfwhcFi4CkJ/YsJbQF6yI7O91+MTqRkClm91/2LYku1HGswDTAoO SbSNfBie74CPw+8hbIw== X-Proofpoint-GUID: WEvD-XYFaP69R0WpIVs1TLY38zLpbKrt X-Proofpoint-ORIG-GUID: WEvD-XYFaP69R0WpIVs1TLY38zLpbKrt 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=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list 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 @oracle.com) X-ZM-MESSAGEID: 1774016533101158501 Content-Type: text/plain; charset="utf-8" Save the current RSS state at early migration time to compare with later during the stop-and-copy phase. Only the RSS state that can change mid-migration is tracked. RSS fields derived from backend capability/feature negotiation (for example software-RSS capability flags and supported/peer hash capability metadata) are intentionally excluded from delta checks. Signed-off-by: Jonah Palmer --- hw/net/virtio-net.c | 50 ++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio-net.h | 16 +++++++++++ 2 files changed, 66 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 2c0b42debb..3ee49a043a 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3943,6 +3943,27 @@ static int virtio_net_early_pre_save(void *opaque) vnet_mig->mq_early =3D n->multiqueue; vnet_mig->queue_pairs_early =3D n->curr_queue_pairs; =20 + /* RSS state snapshot */ + vnet_mig->rss_enabled_early =3D n->rss_data.enabled; + vnet_mig->rss_redirect_early =3D n->rss_data.redirect; + vnet_mig->rss_populate_hash_early =3D n->rss_data.populate_hash; + vnet_mig->rss_runtime_hash_types_early =3D n->rss_data.runtime_hash_ty= pes; + vnet_mig->rss_indirections_len_early =3D n->rss_data.indirections_len; + vnet_mig->rss_default_queue_early =3D n->rss_data.default_queue; + memcpy(vnet_mig->rss_key_early, n->rss_data.key, VIRTIO_NET_RSS_MAX_KE= Y_SIZE); + + /* Snapshot RSS indirections table if present */ + g_free(vnet_mig->rss_indirections_table_early); + vnet_mig->rss_indirections_table_early =3D NULL; + + if (n->rss_data.indirections_len && n->rss_data.indirections_table) { + /* Casting to size_t avoids implicit narrow/widen arithmetic */ + size_t bytes =3D (size_t)n->rss_data.indirections_len * sizeof(uin= t16_t); + + vnet_mig->rss_indirections_table_early =3D + g_memdup2(n->rss_data.indirections_table, bytes); + } + return 0; } =20 @@ -4233,6 +4254,8 @@ static void virtio_net_device_unrealize(DeviceState *= dev) n->migration->mtable_macs_early =3D NULL; g_free(n->migration->vlans_early); n->migration->vlans_early =3D NULL; + g_free(n->migration->rss_indirections_table_early); + n->migration->rss_indirections_table_early =3D NULL; g_free(n->migration); n->migration =3D NULL; =20 @@ -4389,6 +4412,33 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtI= ODevice *vdev) return true; } =20 + /* Has the VirtIONet's RSS state changed? */ + if (n->rss_data.enabled !=3D vnet_mig->rss_enabled_early || + n->rss_data.redirect !=3D vnet_mig->rss_redirect_early || + n->rss_data.populate_hash !=3D vnet_mig->rss_populate_hash_early || + n->rss_data.runtime_hash_types !=3D vnet_mig->rss_runtime_hash_typ= es_early || + n->rss_data.indirections_len !=3D vnet_mig->rss_indirections_len_e= arly || + n->rss_data.default_queue !=3D vnet_mig->rss_default_queue_early) { + return true; + } + if (memcmp(n->rss_data.key, vnet_mig->rss_key_early, + VIRTIO_NET_RSS_MAX_KEY_SIZE) !=3D 0) { + return true; + } + if (n->rss_data.indirections_len) { + size_t bytes =3D (size_t)n->rss_data.indirections_len * sizeof(uin= t16_t); + + /* If either side lacks a buffer when len > 0, treat as changed */ + if (!n->rss_data.indirections_table || + !vnet_mig->rss_indirections_table_early) { + return true; + } + if (memcmp(n->rss_data.indirections_table, + vnet_mig->rss_indirections_table_early, bytes) !=3D 0) { + return true; + } + } + /* * Always return true for now until we're able to detect all possible * changes to a VirtIONet device. diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 5d6179fa19..88074a0976 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -180,6 +180,14 @@ typedef struct VirtIONetQueue { * @guest_offloads_early: Guest offloads snapshot. * @mq_early: Multiqueue state snapshot. * @queue_pairs_early: Queue pairs snapshot. + * @rss_enabled_early: RSS enabled flag. + * @rss_redirect_early: RSS redirect flag. + * @rss_populate_hash_early: RSS populate hash flag. + * @rss_runtime_hash_types_early: RSS runtime hash types. + * @rss_indirections_len_early: RSS indirections length. + * @rss_default_queue_early: RSS default queue. + * @rss_key_early: RSS key. + * @rss_indirections_table_early: RSS indirections table. */ typedef struct VirtIONetMigration { uint16_t status_early; @@ -193,6 +201,14 @@ typedef struct VirtIONetMigration { uint64_t guest_offloads_early; int mq_early; uint16_t queue_pairs_early; + bool rss_enabled_early; + bool rss_redirect_early; + bool rss_populate_hash_early; + uint32_t rss_runtime_hash_types_early; + uint16_t rss_indirections_len_early; + uint16_t rss_default_queue_early; + uint8_t rss_key_early[VIRTIO_NET_RSS_MAX_KEY_SIZE]; + uint16_t *rss_indirections_table_early; } VirtIONetMigration; =20 struct VirtIONet { --=20 2.51.0 From nobody Sun Mar 22 14:28:26 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=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1774016559; cv=none; d=zohomail.com; s=zohoarc; b=NunHhO0Gz9Z/LgVp/p3tHbLH/3QPd/IGj+b78G4Jq+2BNqOi76PoYraADo1CBRRzDwcf+W+CFG7Uink7P7xtnc6ODtTCb1Sbr62dQjhSNt61JmHcN0+GS1FNaZgBXkPwtCVRmjsggsibk/Sj3Pf7Xc3EV5+OYFMst+lU1WYyU5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016559; 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=6Tfha/Vo501llrdOlIhu+ARsJApYqvEGj9lM2fvEUW8=; b=hKvuMW4M0PDbLjaO7TlisAQUJEhYv0+XJPZ3uaTyZSpSk9IUKLWm9Rr5SvnmTRemeR4yEhE0Xfmd3BVRNklnt3dOoEPp+IHdoROpZSFyvDbNNhtnluHOi9X1E/5fm8pu1WBd+hsyn0FFdT3Ggn17p6lwZo6rt9o042BhO/zyVps= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1774016559049217.30254846112848; Fri, 20 Mar 2026 07:22:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3aio-00031p-M9; Fri, 20 Mar 2026 10:21:06 -0400 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 1w3aik-00031W-K4 for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:21:02 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3aii-0007UE-8F for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:21:02 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8YgqW2601043; Fri, 20 Mar 2026 14:20:44 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cvx8x9ths-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:44 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KECGLx030539; Fri, 20 Mar 2026 14:20:43 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb4bu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:43 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2Jv016730; Fri, 20 Mar 2026 14:20:42 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-14; Fri, 20 Mar 2026 14:20:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=6Tfha /Vo501llrdOlIhu+ARsJApYqvEGj9lM2fvEUW8=; b=b7UkA9NdSekd+p05fb8Pz zWPxU6NJvufuT4FRC6/7JCrma1iLn/DlDVOUQiN89cKWkaWfBw0jNbKw3sjqwsH3 Yr5I09L5N+9FdFwOflkZ7ohSgXd8Coz0BIOqKPOgBd+azLOqwBqvuP7tmUdzzuNG BInEFCp8LKX0UB6FyezEqso8CbJeE/vij0cOuqh7iBxAZMvKvhPotJ5/ERymJl1k ymqRtbn28WLjMfEiDmg0Z7fdmLaIJgoW3nsPAytRAjzAjjjmrcWdWclIUcQo6wu7 IS8WZIVorVS9CuwazeOpyLyP7ryuQ6ld+lwKpraz1J55CdjAtDeVBdy+YvaHlCdr w== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 13/14] virtio-net: detect pending Tx work for VQs mid-migration changes Date: Fri, 20 Mar 2026 14:20:14 +0000 Message-ID: <20260320142015.3856652-14-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Proofpoint-GUID: wQDeG2q5OHHnuZKdANF8J9E1PqO_WmSt X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfX4mmqkJ8VZ4j+ SzevoOjpCoAI2/JWWsdIb5xrGAVbB5JfkpHoVtOzPXzDpExt1B1Tp1rJT1j1I3iaxLdDAefH3C8 FIucKRIT76GPHME+XT4p9OosVqw81NPO6ho+k6/ZzFvfVU8uCOroNpSN4ZmTiSR1jwpqk6uBl+1 MmAYxNC3jSbiHUm8aUcP6iNfHOzMV8oI7NXDyD+trUWTD8EPXNhtRvTEsHxFaDrMnj7BiiVYZ9A wK76Gmm4TqKgOHM1MPvXMD4h/XVGJkynYLmfJgjn7HQHZLcjxWo+aRVQRTnmyR9YWfWhKmA7iya q5Z04slLsNyecb4Tqs/1VICrnjqqm781MLNExVLOT5+9YQ9G0opS4BZKNGzTPowceXtSdi5wagd gj07EFxMTwcWnlrDtH+qFAan185k3abwOHA8BrnEXUmYcmoC5d1eOZRrk3E2OQx27CU/WvDyB7A qls8wXVyQNgj6X5PEsg== X-Authority-Analysis: v=2.4 cv=dJmrWeZb c=1 sm=1 tr=0 ts=69bd57bc b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=RD47p0oAkeU5bO7t-o6f:22 a=yPCof4ZbAAAA:8 a=PoidfZ1iDD9ysA-sajAA:9 X-Proofpoint-ORIG-GUID: wQDeG2q5OHHnuZKdANF8J9E1PqO_WmSt 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=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list 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 @oracle.com) X-ZM-MESSAGEID: 1774016560863158500 Content-Type: text/plain; charset="utf-8" Track per-queue pending Tx work state during early migration time. This includes a snapshot of pending Tx state for active queue pairs, checking for deltas at the end of migration, and freeing the snapshot buffer during device unrealize. With this final delta signal in place, drop the temporary always-true fallback in virtio_net_has_delta and return false when no deltas are found. Signed-off-by: Jonah Palmer --- hw/net/virtio-net.c | 26 +++++++++++++++++++++----- include/hw/virtio/virtio-net.h | 2 ++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 3ee49a043a..483a43be4f 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3943,6 +3943,14 @@ static int virtio_net_early_pre_save(void *opaque) vnet_mig->mq_early =3D n->multiqueue; vnet_mig->queue_pairs_early =3D n->curr_queue_pairs; =20 + /* Tx waiting snapshot for active queue pairs */ + if (!vnet_mig->tx_waiting_early) { + vnet_mig->tx_waiting_early =3D g_new0(uint32_t, n->max_queue_pairs= ); + } + for (int i =3D 0; i < n->curr_queue_pairs; i++) { + vnet_mig->tx_waiting_early[i] =3D n->vqs[i].tx_waiting; + } + /* RSS state snapshot */ vnet_mig->rss_enabled_early =3D n->rss_data.enabled; vnet_mig->rss_redirect_early =3D n->rss_data.redirect; @@ -4254,6 +4262,8 @@ static void virtio_net_device_unrealize(DeviceState *= dev) n->migration->mtable_macs_early =3D NULL; g_free(n->migration->vlans_early); n->migration->vlans_early =3D NULL; + g_free(n->migration->tx_waiting_early); + n->migration->tx_waiting_early =3D NULL; g_free(n->migration->rss_indirections_table_early); n->migration->rss_indirections_table_early =3D NULL; g_free(n->migration); @@ -4412,6 +4422,16 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtI= ODevice *vdev) return true; } =20 + /* Has any active queue's tx_waiting changed? */ + if (!vnet_mig->tx_waiting_early) { + return true; + } + for (int i =3D 0; i < n->curr_queue_pairs; i++) { + if (n->vqs[i].tx_waiting !=3D vnet_mig->tx_waiting_early[i]) { + return true; + } + } + /* Has the VirtIONet's RSS state changed? */ if (n->rss_data.enabled !=3D vnet_mig->rss_enabled_early || n->rss_data.redirect !=3D vnet_mig->rss_redirect_early || @@ -4439,11 +4459,7 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtI= ODevice *vdev) } } =20 - /* - * Always return true for now until we're able to detect all possible - * changes to a VirtIONet device. - */ - return true; + return false; } =20 static bool virtio_net_needed(void *opaque) diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 88074a0976..dbbacc83bb 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -180,6 +180,7 @@ typedef struct VirtIONetQueue { * @guest_offloads_early: Guest offloads snapshot. * @mq_early: Multiqueue state snapshot. * @queue_pairs_early: Queue pairs snapshot. + * @tx_waiting_early: Per-queue pending-Tx snapshot. * @rss_enabled_early: RSS enabled flag. * @rss_redirect_early: RSS redirect flag. * @rss_populate_hash_early: RSS populate hash flag. @@ -201,6 +202,7 @@ typedef struct VirtIONetMigration { uint64_t guest_offloads_early; int mq_early; uint16_t queue_pairs_early; + uint32_t *tx_waiting_early; bool rss_enabled_early; bool rss_redirect_early; bool rss_populate_hash_early; --=20 2.51.0 From nobody Sun Mar 22 14:28:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1774016562; cv=none; d=zohomail.com; s=zohoarc; b=VzFKJHmrH8YwXd8drsDcg6VdxW4PY1gY8lkGS1fLACeBWDaIUTW9Flj9SDFpAB+hTuW/hUZO1kdHsMJbUKP/yQRRpTM5ElVnOzm1OD4/NRGwqCpWwn9X8GrrSgos1Am7iTFtBOgwy4CZbKZ4/A8JwosCcdA93SaVzyhjBL+5YY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774016562; 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:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=gbqbMrs7LdafLAZ6yqHmxkhLZEPGK/o30SzLEplpO8w=; b=oGj4V4LcDNh1OwCO20u+L6K8Xf9UvMfxR16j/96TOnCOdvsGJfW3WxftnJ/b43nImx+B0yvdHcQ76758haWRsDc7cSHUIUQzgukbj1M3mO5mRNoGbtbusiJGb5rKFcxmWCr4COoJ2V/rnIfJgCB2tfFrzkdZr4ZFLGEG1kLVr6E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1774016562204240.68432002027964; Fri, 20 Mar 2026 07:22:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w3air-00033N-Fp; Fri, 20 Mar 2026 10:21:09 -0400 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 1w3aip-00032p-Rq for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:21:07 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w3aim-0007V8-Ve for qemu-devel@nongnu.org; Fri, 20 Mar 2026 10:21:07 -0400 Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K8YDn53323103; Fri, 20 Mar 2026 14:20:46 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4cvxk8htke-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:45 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 62KDON7l030599; Fri, 20 Mar 2026 14:20:45 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4cvx4eb4cp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 14:20:45 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 62KEK2Jx016730; Fri, 20 Mar 2026 14:20:44 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4cvx4eb3ue-15; Fri, 20 Mar 2026 14:20:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=gbqbM rs7LdafLAZ6yqHmxkhLZEPGK/o30SzLEplpO8w=; b=Jaq9I8lGg4T1bgkrZbV7H W+YdI1BFU2lpz3gWSpBOC0POEZl23Yc1T2rB00GPBN+rh9FepvQvwHgOoXfs9MVI s6hCxqry0mkDIn20SL8iyBQHOQParxpY1w4gU0oYz6+tmSnpGZ00Nl3pbNyzm4mu AfqxiBkvbx6tD9VloC0Lgfu76ddoSp2D7dlGowQagMLoEb5ViidspGeE1ecc3A/p lM/nLK+hM08GBo+k1susbZ2Vy7/Dqyy4zrQKNI2haAEZF/WzpJPneeoTWkrVz0M+ k6/b9780aGFPneZu6LaD2YDKZ60BxmwwBvpvTrB5ES5Mvv+l3K9EmMLOAbINe86P g== To: qemu-devel@nongnu.org Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com, sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, armbru@redhat.com, jonah.palmer@oracle.com Subject: [RFC v2 14/14] virtio-net, vhost-net: early migration support for vhost-net Date: Fri, 20 Mar 2026 14:20:15 +0000 Message-ID: <20260320142015.3856652-15-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260320142015.3856652-1-jonah.palmer@oracle.com> References: <20260320142015.3856652-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-20_02,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2603050001 definitions=main-2603200114 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDExNCBTYWx0ZWRfX0hf//rzTR+cK ZLIcIy3xXCpBS4NNt61ZCadj6LhQOf4zdwHWEpNNyCAtlZCU6AjWMT0ilrgUIhJ5HB6owK7h8QI Wl06V1hsjOMg5XpyY14Lvqmt3r4+DJPlOp69uGzphzE+9HGYgQgKEBs33pBvxmQ99Q491KjyL0U jvL3fjnZMo2fYQDtfdRgPmgnaNPOL9yjOFCjsq9RZe6B9syiQx3eH6W2m+EcH5K+ucubeqXvA9r sqtn/5MzDOeV1ZNID4rxAe6FmMYQ676irm6bsvNJl7jlPUJyOlZF9xoVSPc9LzZ2yns9hcOSU7R UzuqSnRLo6A0F1DCYWq2Uej/XYjSECC60gLB3CAur86mq6hVAlHbzdvsBV6h5f5muo15jmSYfvp yXQfiwUb81P/BSHHdfZSKGWNFpPhaKTP7Dtq1+lEG0QlxDtXZBVe/hxq5GlO31IYstzQUHwhfmX cMR22iOUUJutW5ZCHNA== X-Authority-Analysis: v=2.4 cv=AI0/m/Lt c=1 sm=1 tr=0 ts=69bd57bd b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jiCTI4zE5U7BLdzWsZGv:22 a=x0eKOSpe3m1H3M0S9YoZ:22 a=yPCof4ZbAAAA:8 a=Xb7ORfVXokAGz2rkdSYA:9 X-Proofpoint-GUID: rqVfpMpNzv8eA8JQZ1ZjEyXYUfDJVTkD X-Proofpoint-ORIG-GUID: rqVfpMpNzv8eA8JQZ1ZjEyXYUfDJVTkD 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=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Jonah Palmer From: Jonah Palmer via qemu development Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1774016562926158500 Content-Type: text/plain; charset="utf-8" This patch implements early migration support for virtio-net devices using a TAP backend accelerated by vhost-net. More specifically, we initiate the vhost startup routine during early migration time but guard against binding TAP backends at this time. We need to wait until the source VM has been paused before we want the device to actually start. For vhost-net, the remaining stop-and-copy work is to apply final vring bases and bind TAP backends. This is handled via the virtio-net vhost subsection (vmstate_virtio_net_vhost) post_load callback. When a mid-migration delta is detected and we fall back to a full virtio-net reload, explicitly stop any early-started vhost instance before restart so notifier/backend state is handled safely. Failures while starting vhost-net during early post-load, and failures during stop-and-copy quickstart finalization, are treated as non-fatal for migration. In those cases the destination continues migration and falls back to userspace virtio-net datapath. After switchover, the normal vhost start path may retry once status is set; if that retry also fails, the device continues running on userspace virtio-net. By moving most of the post-load startup work out of the stop-and-copy phase, we further minimize the guest-visible downtime incurred by migrating a virtio-net device using vhost-net. A future improvement to this patch should handle deltas more gracefully by updating only what was changed mid-migration instead of relying on a full vhost/virtio-net restart. Signed-off-by: Jonah Palmer --- hw/net/vhost_net.c | 183 +++++++++++++++++++++++++++++++++ hw/net/virtio-net.c | 127 ++++++++++++++++++++++- include/hw/virtio/virtio-net.h | 2 + include/net/vhost_net.h | 9 ++ 4 files changed, 319 insertions(+), 2 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index a8ee18a912..f11f30b4f0 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -353,6 +353,13 @@ static int vhost_net_start_one(struct vhost_net *net, /* Queue might not be ready for start */ continue; } + if (dev->migration && dev->migration->early_load) { + /* + * Queue isn't ready to start as we're in the middle of an + * early migration. Set the backend later when we're ready. + */ + continue; + } r =3D vhost_net_set_backend(&net->dev, &file); if (r < 0) { r =3D -errno; @@ -695,3 +702,179 @@ err_start: =20 return r; } + +/* + * Helper function for vhost_net_post_load_migration_quickstart: + * + * Sets vring bases for all vhost virtqueues. + */ +int vhost_net_set_all_vring_bases(struct VirtIONet *n, VirtIODevice *vdev, + NetClientState *ncs, int queue_pairs, + int cvq, int nvhosts) +{ + NetClientState *peer; + struct vhost_net *vnet; + struct vhost_dev *hdev; + int queue_idx; + int i, j, r; + + for (i =3D 0; i < nvhosts; i++) { + peer =3D qemu_get_peer(ncs, i < queue_pairs ? i : n->max_queue_pai= rs); + vnet =3D get_vhost_net(peer); + if (!vnet) { + continue; + } + hdev =3D &vnet->dev; + + for (j =3D 0; j < hdev->nvqs; ++j) { + queue_idx =3D hdev->vq_index + j; + struct vhost_vring_state state =3D { + .index =3D hdev->vhost_ops->vhost_get_vq_index(hdev, queue= _idx), + .num =3D virtio_queue_get_last_avail_idx(vdev, queue_idx), + }; + + r =3D hdev->vhost_ops->vhost_set_vring_base(hdev, &state); + if (r) { + error_report("vhost_set_vring_base failed (vq %d)", queue_= idx); + goto fail; + } + } + } + return 0; + +fail: + vhost_net_stop_one(vnet, vdev); + + while (--i >=3D 0) { + peer =3D qemu_get_peer(ncs, i < queue_pairs ? i : n->max_queue_pai= rs); + vhost_net_stop_one(get_vhost_net(peer), vdev); + } + return r; +} + +/* + * Helper function for vhost_net_post_load_migration_quickstart: + * + * Binds TAP backends to all vhost-net virtqueues. All vring bases must be= set + * before attempting to start any backends. + */ +int vhost_net_start_all_backends(struct VirtIONet *n, VirtIODevice *vdev, + NetClientState *ncs, int queue_pairs, int= cvq, + int nvhosts) +{ + NetClientState *peer; + struct vhost_dev *hdev; + struct vhost_vring_file file =3D { }; + struct vhost_net *vnet; + int i, r; + + for (i =3D 0; i < nvhosts; i++) { + peer =3D qemu_get_peer(ncs, i < queue_pairs ? i : n->max_queue_pai= rs); + vnet =3D get_vhost_net(peer); + if (!vnet) { + continue; + } + hdev =3D &vnet->dev; + + qemu_set_fd_handler(vnet->backend, NULL, NULL, NULL); + file.fd =3D vnet->backend; + + for (file.index =3D 0; file.index < hdev->nvqs; ++file.index) { + if (!virtio_queue_enabled(vdev, hdev->vq_index + file.index)) { + /* Queue might not be ready to start */ + continue; + } + + r =3D vhost_net_set_backend(hdev, &file); + if (r < 0) { + r =3D -errno; + goto fail; + } + } + } + return 0; + +fail: + file.fd =3D -1; + while (file.index-- > 0) { + if (!virtio_queue_enabled(vdev, hdev->vq_index + file.index)) { + continue; + } + int ret =3D vhost_net_set_backend(hdev, &file); + assert(ret >=3D 0); + } + if (vnet->nc->info->poll) { + vnet->nc->info->poll(vnet->nc, true); + } + vhost_dev_stop(hdev, vdev, false); + + while (--i >=3D 0) { + peer =3D qemu_get_peer(ncs, i < queue_pairs ? i : n->max_queue_pai= rs); + vhost_net_stop_one(get_vhost_net(peer), vdev); + } + return r; +} + +/* + * Quickstart path for a virtio-net device using vhost acceleration: + * + * Used during migration of a virtio-net device that opted-in to early + * migration. + * + * The goal of this function is to perform any remaining startup work that + * can only be done during the stop-and-copy phase, once the source has be= en + * stopped. + * + * Note: By the time this function is called, the device has essentially b= een + * fully configured, albeit with a few last-minute configurations to be ma= de. + * This means our error handling must completely unwind the device with + * full-stop semantics. + */ +int vhost_net_post_load_migration_quickstart(struct VirtIONet *n) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + NetClientState *ncs =3D qemu_get_queue(n->nic); + BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusState *vbus =3D VIRTIO_BUS(qbus); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(vbus); + + int queue_pairs =3D n->multiqueue ? n->max_queue_pairs : 1; + int cvq =3D virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ) ? + n->max_ncs - n->max_queue_pairs : 0; + int nvhosts =3D queue_pairs + cvq; + int total_notifiers =3D queue_pairs * 2 + cvq; + NetClientState *peer =3D qemu_get_peer(ncs, 0); + + int r, e; + + /* First peer must exist for the realized virtio-net device */ + assert(peer); + + /* Apply final vring bases for all vhosts */ + r =3D vhost_net_set_all_vring_bases(n, vdev, ncs, queue_pairs, cvq, nv= hosts); + if (r < 0) { + goto fail; + } + + /* Bind backends (TAP devices only) */ + if (peer->info->type =3D=3D NET_CLIENT_DRIVER_TAP) { + r =3D vhost_net_start_all_backends(n, vdev, ncs, queue_pairs, cvq,= nvhosts); + if (r < 0) { + goto fail; + } + } + return 0; + +fail: + e =3D k->set_guest_notifiers(qbus->parent, total_notifiers, false); + if (e < 0) { + fprintf(stderr, "vhost guest notifier cleanup failed: %d\n", e); + fflush(stderr); + } + vhost_net_disable_notifiers(vdev, ncs, queue_pairs, cvq); + + error_report("unable to start vhost net: %d: " + "falling back on userspace virtio", -r); + n->vhost_started =3D 0; + return r; +} diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 483a43be4f..950137c568 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3864,6 +3864,38 @@ static bool failover_hide_primary_device(DeviceListe= ner *listener, return qatomic_read(&n->failover_primary_hidden); } =20 +static int virtio_net_vhost_early_start(VirtIONet *n, VirtIODevice *vdev) +{ + NetClientState *ncs =3D qemu_get_queue(n->nic); + int queue_pairs =3D n->multiqueue ? n->max_queue_pairs : 1; + int cvq =3D virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ) ? + n->max_ncs - n->max_queue_pairs : 0; + int r; + + /* Return early if there's no vhost backend */ + if (!ncs || !ncs->peer || !get_vhost_net(ncs->peer)) { + return 0; + } + + if (virtio_has_feature(vdev->guest_features, VIRTIO_NET_F_MTU)) { + r =3D vhost_net_set_mtu(get_vhost_net(ncs->peer), n->net_conf.mtu); + if (r < 0) { + error_report("%u bytes MTU not supported by the backend", + n->net_conf.mtu); + return r; + } + } + + n->vhost_started =3D 1; + r =3D vhost_net_start(vdev, n->nic->ncs, queue_pairs, cvq); + if (r < 0) { + error_report("unable to start vhost net: %d: " + "falling back on userspace virtio", -r); + n->vhost_started =3D 0; + } + return r; +} + enum VirtIONetRxFlags { VNET_RX_F_PROMISC =3D 1u << 0, VNET_RX_F_ALLMULTI =3D 1u << 1, @@ -3892,6 +3924,9 @@ static int virtio_net_early_pre_save(void *opaque) VirtIONetMigration *vnet_mig =3D n->migration; size_t vlans_size =3D (size_t)(MAX_VLAN >> 3); =20 + /* Reset source-side delta decision for this migration iteration. */ + n->migration->reloaded =3D false; + vdev_mig->status_early =3D vdev->status; vnet_mig->status_early =3D n->status; =20 @@ -3989,6 +4024,14 @@ static int virtio_net_early_post_load(void *opaque, = int version_id) VirtIONet *n =3D opaque; VirtIODevice *vdev =3D VIRTIO_DEVICE(n); =20 + /* + * Start the vhost backend if one is present. Note that while + * vdev->migration->early_load is true, not all vhost startup operatio= ns + * are performed. For example, we defer setting the backends (vhost-ne= t w/ + * TAP) until the stop-and-copy phase (see vmstate_virtio_net_vhost). + */ + virtio_net_vhost_early_start(n, vdev); + vdev->migration->early_load =3D false; return 0; } @@ -4007,6 +4050,49 @@ static const VMStateDescription vmstate_virtio_net_e= arly =3D { }, }; =20 +static int virtio_net_vhost_post_load(void *opaque, int version_id) +{ + VirtIONet *n =3D opaque; + int r; + + if (!n->vhost_started) { + return 0; + } + + /* Finalize vhost startup */ + r =3D vhost_net_post_load_migration_quickstart(n); + if (r < 0) { + error_report("virtio-net vhost post-load quickstart failed: %d", r= ); + } + return 0; +} + +static bool virtio_net_vhost_needed(void *opaque) +{ + VirtIONet *n =3D opaque; + NetClientState *nc =3D qemu_get_queue(n->nic); + + if (!nc || !nc->peer || !get_vhost_net(nc->peer)) { + return false; + } + + /* Skip vhost quickstart section when a full virtio-net reload is need= ed. */ + return !n->migration->reloaded; +} + +static const VMStateDescription vmstate_virtio_net_vhost =3D { + .name =3D "virtio-net-vhost", + .minimum_version_id =3D 1, + .version_id =3D 1, + /* Set prio low to run after vmstate_virtio_net */ + .priority =3D MIG_PRI_LOW, + .needed =3D virtio_net_vhost_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_END_OF_LIST() + }, + .post_load =3D virtio_net_vhost_post_load, +}; + static void virtio_net_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -4201,9 +4287,10 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) vdev->migration =3D g_new0(VirtIODevMigration, 1); vdev->migration->early_load =3D false; n->migration =3D g_new0(VirtIONetMigration, 1); - vmstate_register_any(VMSTATE_IF(n), &vmstate_virtio_net_early,= n); virtio_delta_vmsd_register(vdev); + vmstate_register_any(VMSTATE_IF(n), &vmstate_virtio_net_vhost, + n); } } } @@ -4271,6 +4358,7 @@ static void virtio_net_device_unrealize(DeviceState *= dev) =20 vmstate_unregister(VMSTATE_IF(n), &vmstate_virtio_net_early, n); virtio_delta_vmsd_unregister(vdev); + vmstate_unregister(VMSTATE_IF(n), &vmstate_virtio_net_vhost, n); } } =20 @@ -4336,6 +4424,37 @@ static int virtio_net_pre_save(void *opaque) return 0; } =20 +static int virtio_net_pre_load(void *opaque) +{ + VirtIONet *n =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + + /* + * If we're migrating with a vhost device and performed an early + * save/load, then reaching here means that something changed and + * we need to reload all of the virtio-net device's state. + */ + if (n->early_mig) { + /* + * Unwind vhost-net before full reload path re-runs startup. This = keeps + * notifier/backend state handling safe. + */ + if (n->vhost_started) { + NetClientState *nc =3D qemu_get_queue(n->nic); + int queue_pairs =3D n->multiqueue ? n->max_queue_pairs : 1; + int cvq =3D virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ= ) ? + n->max_ncs - n->max_queue_pairs : 0; + + if (nc && nc->peer && get_vhost_net(nc->peer)) { + vhost_net_stop(vdev, n->nic->ncs, queue_pairs, cvq); + } + + n->vhost_started =3D 0; + } + } + return 0; +} + static bool primary_unplug_pending(void *opaque) { DeviceState *dev =3D opaque; @@ -4466,12 +4585,15 @@ static bool virtio_net_needed(void *opaque) { VirtIONet *n =3D opaque; VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + bool delta; =20 if (!n->early_mig) { return true; } =20 - return virtio_net_has_delta(n, vdev); + delta =3D virtio_net_has_delta(n, vdev); + n->migration->reloaded =3D delta; + return delta; } =20 static const VMStateDescription vmstate_virtio_net =3D { @@ -4484,6 +4606,7 @@ static const VMStateDescription vmstate_virtio_net = =3D { VMSTATE_END_OF_LIST() }, .pre_save =3D virtio_net_pre_save, + .pre_load =3D virtio_net_pre_load, .dev_unplug_pending =3D dev_unplug_pending, }; =20 diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index dbbacc83bb..d1d7c0b742 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -169,6 +169,7 @@ typedef struct VirtIONetQueue { =20 /** * struct VirtIONetMigration - VirtIONet migration structure + * @reloaded: Flag to indicate the state has been reloaded. * @status_early: VirtIONet status snapshot. * @mac_early: MAC address early migration snapshot. * @mtable_in_use_early: In-use MAC table entries. @@ -191,6 +192,7 @@ typedef struct VirtIONetQueue { * @rss_indirections_table_early: RSS indirections table. */ typedef struct VirtIONetMigration { + bool reloaded; uint16_t status_early; uint8_t mac_early[ETH_ALEN]; uint32_t mtable_in_use_early; diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index 0225207491..a8a1c1005b 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -4,6 +4,7 @@ #include "net/net.h" #include "hw/virtio/virtio-features.h" #include "hw/virtio/vhost-backend.h" +#include "hw/virtio/virtio-net.h" =20 struct vhost_net; typedef struct vhost_net VHostNetState; @@ -88,4 +89,12 @@ int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetC= lientState *nc, int vq_index); =20 void vhost_net_save_acked_features(NetClientState *nc); + +int vhost_net_set_all_vring_bases(struct VirtIONet *n, VirtIODevice *vdev, + NetClientState *ncs, int queue_pairs, + int cvq, int nvhosts); +int vhost_net_start_all_backends(struct VirtIONet *n, VirtIODevice *vdev, + NetClientState *ncs, int queue_pairs, + int cvq, int nvhosts); +int vhost_net_post_load_migration_quickstart(struct VirtIONet *n); #endif --=20 2.51.0