From nobody Sat Nov 15 10:42:25 2025 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=1753188244; cv=none; d=zohomail.com; s=zohoarc; b=GrOYfErNg31CSx5a/rH2RzvTYbszg4S55cdc+F/dXjwlFsZ4ULhiJkgfnRAUn1M8OHTqoKN0fL3dQWegn6+C/yXyA5vNoDHxp74IVEKRYLfMmkjPYsyHCFWS6FYdwIffrHjuyTQWI71wHRzilelYQpHwDKCz44KBa42d/xXexTw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753188244; 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=IsLv/76PdAm9fyknh/wENGfwWc4cVutv2fWza08LdOQ=; b=eT8DSiYJfzqSg2tS2TbzVJSU25ML0dxPDwdu2ALJ807x+tJAoaIVfXSqkimFxRMrJY+h5TKyIE4gTlmCe5Ili0B0hcG5DJF8Ty/q86uIz71qA+ENWajHVc69VBzsS30ka8G1LyCIZ/B7uXFPLEhZenfFTssegV77YCKjKJYcC5A= 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 1753188243994424.5729935718442; Tue, 22 Jul 2025 05:44:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ueCKq-0003cK-QM; Tue, 22 Jul 2025 08:43: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 1ueCJQ-0002Lh-Ge for qemu-devel@nongnu.org; Tue, 22 Jul 2025 08:41:45 -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 1ueCJL-0006KE-O1 for qemu-devel@nongnu.org; Tue, 22 Jul 2025 08:41:40 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56M5TAKD024432; Tue, 22 Jul 2025 12:41:33 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48057qw70s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jul 2025 12:41:32 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 56MC5xQE010475; Tue, 22 Jul 2025 12:41:31 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4801t99gah-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jul 2025 12:41:31 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 56MCfT3p039536; Tue, 22 Jul 2025 12:41:30 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4801t99g9h-2; Tue, 22 Jul 2025 12:41:30 +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=IsLv/ 76PdAm9fyknh/wENGfwWc4cVutv2fWza08LdOQ=; b=T62OvdVeBU01GH5Ts4TbB Wta9et7yTHl585jkXz09lBrHkgDNBxvhigHZsFacL600e8svk5E3HEQqAKeJLmur 8xWmyvFwb1E+Lj2McHnovbKpeIl4qy3iQ5ntnT8o5foxrru0CUccnVtEV/kt6i2Z i1gJOC6FhWx8OHhhtyOPWeOUE8gejl8niB7ohjBlX3tIAvt7+9D3ekvF43r0xFQy v9uz1Nb2G2Q/wsFZnOgrRS9piVh6HCvZ0N160KS9dw/0+yX75GEgkrRW26lyyhEQ qJCd6Qa+NdPq9x3crQ+/9d+VrcgWIwNcdocxK5Eg1DvnqF1cBScIl6b8a42Jdtmf Q== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, eblake@redhat.com, armbru@redhat.com, jasowang@redhat.com, mst@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Subject: [RFC 1/6] migration: Add virtio-iterative capability Date: Tue, 22 Jul 2025 12:41:22 +0000 Message-ID: <20250722124127.2497406-2-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250722124127.2497406-1-jonah.palmer@oracle.com> References: <20250722124127.2497406-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.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-22_02,2025-07-21_02,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2505160000 definitions=main-2507220104 X-Authority-Analysis: v=2.4 cv=MNRgmNZl c=1 sm=1 tr=0 ts=687f86fc cx=c_pps a=OOZaFjgC48PWsiFpTAqLcw==:117 a=OOZaFjgC48PWsiFpTAqLcw==:17 a=Wb1JkmetP80A:10 a=yPCof4ZbAAAA:8 a=ipTBKrNiw92s7om4A18A:9 X-Proofpoint-ORIG-GUID: vYjqTppBd9-jBcwyS9McPHnwNLoDS2Nf X-Proofpoint-GUID: vYjqTppBd9-jBcwyS9McPHnwNLoDS2Nf X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzIyMDEwNCBTYWx0ZWRfX5/tbHfIJfJ7R XJUy+eMzoL/A2KRzmYWT+CWMDCr7bNAc2MTBT6Xh3qFbZ1JLheIaQRBLLun/lP+Rk/M4mtfTfbP 1CXWTGjGq1dF1a2ZcL+gcxY0aKPCMps5Mvd2051f5cGWm5BlYhjQDC6Wly3idJhTP/ul1m1crel lVIh+7jbCN5WcfnH9sJ/rET/hPUMKZGRGUOuAQgwL7UXsx+TI/Fs9YAF+Dn0ra1h7DgzCR0QONU USM4bSa6wiOX1n91jXfz2NN3NZWD2D2mCbi4PXdnw9knhNMVACLgPglkseT6d9a3r2gnqUEzqqM rfjGTYsbifk6iGpLRJcjsFstQ92aHPtcDSdnnVVMtAibx99YXaxa/qnYZ8bepnV4yjVKAyFMmf9 dDYx4nvXcbztcddX4pU4wnduR4d9JkgriO0ILAs8GCo/Qe0TVHR2fol/+XnsKOkICdiH1t3B 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1753188247232116600 Content-Type: text/plain; charset="utf-8" Adds a new migration capability 'virtio-iterative' that will allow virtio devices, where supported, to iteratively migrate configuration changes that occur during the migration process. This capability is added to the validated capabilities list to ensure both the source and destination support it before enabling. The capability defaults to off to maintain backward compatibility. To enable the capability via HMP: (qemu) migrate_set_capability virtio-iterative on To enable the capability via QMP: {"execute": "migrate-set-capabilities", "arguments": { "capabilities": [ { "capability": "virtio-iterative", "state": true } ] } } Signed-off-by: Jonah Palmer Tested-by: Lei Yang --- migration/savevm.c | 1 + qapi/migration.json | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/migration/savevm.c b/migration/savevm.c index bb04a4520d..40a2189866 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -279,6 +279,7 @@ static bool should_validate_capability(int capability) switch (capability) { case MIGRATION_CAPABILITY_X_IGNORE_SHARED: case MIGRATION_CAPABILITY_MAPPED_RAM: + case MIGRATION_CAPABILITY_VIRTIO_ITERATIVE: return true; default: return false; diff --git a/qapi/migration.json b/qapi/migration.json index 4963f6ca12..8f042c3ba5 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -479,6 +479,11 @@ # each RAM page. Requires a migration URI that supports seeking, # such as a file. (since 9.0) # +# @virtio-iterative: Enable iterative migration for virtio devices, if +# the device supports it. When enabled, and where supported, virtio +# devices will track and migrate configuration changes that may +# occur during the migration process. (Since 10.1) +# # Features: # # @unstable: Members @x-colo and @x-ignore-shared are experimental. @@ -498,7 +503,7 @@ { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] }, 'validate-uuid', 'background-snapshot', 'zero-copy-send', 'postcopy-preempt', 'switchover-ack', - 'dirty-limit', 'mapped-ram'] } + 'dirty-limit', 'mapped-ram', 'virtio-iterative'] } =20 ## # @MigrationCapabilityStatus: --=20 2.47.1 From nobody Sat Nov 15 10:42:25 2025 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=1753188246; cv=none; d=zohomail.com; s=zohoarc; b=k7DTsMguKVPSJCY/h7wI1KyKqMVuZvrxhIBsLOXmLDBy7rk6H/XddnF2K+d2pDtwO7F8zogJ9g3U0ScryvWX94T5IYHXmayMXs8nR6CrGfA4rcWKNJTnYfv3hRgAIs0Sp+xvaPV9zRWL/kh0rE2q4B7MKuXDUQ7I71RcNJiCYNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753188246; 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=mTAkCkg5NAr+U2BQKhXP4vrQ5SSm+w/ZkB8cpu8ucqg=; b=E5rbishCXUyJbujw7/JBoEu2nI/vXMPFsTWBW7qO+fQU9S+nh1Y6gSoqMDlowdV3cESyuLqaHZpGLYOYAGft+I1mbfWpMUG7OZphyM78Trn2ZHQyI2Nv/qIoGAyuz/uAmhU2hKrL1sd23Bhk7+5d8sHF57Za7OaRmkXE44B/gis= 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 1753188246761548.922170262826; Tue, 22 Jul 2025 05:44:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ueCKl-0003V9-Io; Tue, 22 Jul 2025 08:43:04 -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 1ueCJQ-0002Ld-8A for qemu-devel@nongnu.org; Tue, 22 Jul 2025 08:41:45 -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 1ueCJL-0006KK-Fo for qemu-devel@nongnu.org; Tue, 22 Jul 2025 08:41:39 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56M5TCVY006880; Tue, 22 Jul 2025 12:41:34 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4805e2d2p8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jul 2025 12:41:33 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 56MBf90X010337; Tue, 22 Jul 2025 12:41:32 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4801t99gb4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jul 2025 12:41:32 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 56MCfT3r039536; Tue, 22 Jul 2025 12:41:32 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4801t99g9h-3; Tue, 22 Jul 2025 12:41:32 +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=mTAkC kg5NAr+U2BQKhXP4vrQ5SSm+w/ZkB8cpu8ucqg=; b=Sr1yqCfpxA+8tmpIoa+M+ ci/wx/UOLEB9E9mxgrsAAQnGfjBKJWWLxqvfk8h/dNN3hmP6104kC6E22YZkzgvA oz04QjLQJ57otU047clRhBMZecp5lCUZuKrGCTKJxdWafmwbsNdJo07ChdWno3io +J/s84cCuJL7MliCgpc6gQuffOAF7buNjn85kf99dE0d2jZO5lgW4WtpOuZMAWzu ptoc3Ppu0fdb70/IdSNAlWQwiq18uAVV1lNYrVDfysh/aD4ZIIMD/VJqzEVxUASR +wziQTDajmKAzN8lLvxv1STvP8b8auuQGNjqk3aWGpMAfFzalDm6BS08IH+rgBVb w== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, eblake@redhat.com, armbru@redhat.com, jasowang@redhat.com, mst@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Subject: [RFC 2/6] virtio-net: Reorder vmstate_virtio_net and helpers Date: Tue, 22 Jul 2025 12:41:23 +0000 Message-ID: <20250722124127.2497406-3-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250722124127.2497406-1-jonah.palmer@oracle.com> References: <20250722124127.2497406-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.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-22_02,2025-07-21_02,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2505160000 definitions=main-2507220104 X-Authority-Analysis: v=2.4 cv=WaYMa1hX c=1 sm=1 tr=0 ts=687f86fd cx=c_pps a=OOZaFjgC48PWsiFpTAqLcw==:117 a=OOZaFjgC48PWsiFpTAqLcw==:17 a=Wb1JkmetP80A:10 a=yPCof4ZbAAAA:8 a=Su2gMDwvtMPhgmBzyZ4A:9 X-Proofpoint-GUID: xUTt2it9AJpkryHbhhZzSjwf3L0gGEq_ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzIyMDEwNCBTYWx0ZWRfX4bhky5bqli0E bS429T/LqkVW9q/wgc4y8CkbV17MHl34sg34hU9uiaFx9JetLDIJgJIM6qb9Whp7fvYnUgSnmjx c9VQXePx6IVD45aHI6q1GQH1P9FDGZH5vzCE9IOvh36TOYLiaD46hktkUcSMpLqKznbOvpSgllm KaP0OA+flBsKRlOFYPtRgdMpUlVNmqoZMB9PpncQGlRe0sIBm4JZr0x+Pg++wN7gVNLipkt3a1v 3oALySrMeJMqeumhCHO4pCt5H4Y81I8N3ByJTLTkvimF6gchv4B6xhyh5qqRK30KmMB+MV2WShx WenYmjbdYKlKVVp+hueUpyNqFCOcLwIHQDAI6hImbwO6Ko5pEGhw3y5of5NZEpSmM/w01oVZ6Gl heBya98Zi7DWawlFMDVsRI9c6Bh+EH05yQcfgSRbRLsy0cdnzmAb1PtICQlTAO7T+JS4+Pt4 X-Proofpoint-ORIG-GUID: xUTt2it9AJpkryHbhhZzSjwf3L0gGEq_ 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1753188247150116600 Content-Type: text/plain; charset="utf-8" This reordering makes the vmstate_virtio_net available for use by future virtio-net SaveVMHandlers hooks that will need to be placed before virtio_net_device_realize. Signed-off-by: Jonah Palmer Tested-by: Lei Yang --- hw/net/virtio-net.c | 90 ++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 221252e00a..93029104b3 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3746,6 +3746,51 @@ static bool failover_hide_primary_device(DeviceListe= ner *listener, return qatomic_read(&n->failover_primary_hidden); } =20 +static int virtio_net_pre_save(void *opaque) +{ + VirtIONet *n =3D opaque; + + /* At this point, backend must be stopped, otherwise + * it might keep writing to memory. */ + assert(!n->vhost_started); + + return 0; +} + +static bool primary_unplug_pending(void *opaque) +{ + DeviceState *dev =3D opaque; + DeviceState *primary; + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VirtIONet *n =3D VIRTIO_NET(vdev); + + if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_STANDBY)) { + return false; + } + primary =3D failover_find_primary_device(n); + return primary ? primary->pending_deleted_event : false; +} + +static bool dev_unplug_pending(void *opaque) +{ + DeviceState *dev =3D opaque; + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(dev); + + return vdc->primary_unplug_pending(dev); +} + +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, + .fields =3D (const VMStateField[]) { + VMSTATE_VIRTIO_DEVICE, + VMSTATE_END_OF_LIST() + }, + .pre_save =3D virtio_net_pre_save, + .dev_unplug_pending =3D dev_unplug_pending, +}; + static void virtio_net_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -4016,51 +4061,6 @@ static void virtio_net_instance_init(Object *obj) ebpf_rss_init(&n->ebpf_rss); } =20 -static int virtio_net_pre_save(void *opaque) -{ - VirtIONet *n =3D opaque; - - /* At this point, backend must be stopped, otherwise - * it might keep writing to memory. */ - assert(!n->vhost_started); - - return 0; -} - -static bool primary_unplug_pending(void *opaque) -{ - DeviceState *dev =3D opaque; - DeviceState *primary; - VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); - VirtIONet *n =3D VIRTIO_NET(vdev); - - if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_STANDBY)) { - return false; - } - primary =3D failover_find_primary_device(n); - return primary ? primary->pending_deleted_event : false; -} - -static bool dev_unplug_pending(void *opaque) -{ - DeviceState *dev =3D opaque; - VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(dev); - - return vdc->primary_unplug_pending(dev); -} - -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, - .fields =3D (const VMStateField[]) { - VMSTATE_VIRTIO_DEVICE, - VMSTATE_END_OF_LIST() - }, - .pre_save =3D virtio_net_pre_save, - .dev_unplug_pending =3D dev_unplug_pending, -}; - static const Property virtio_net_properties[] =3D { DEFINE_PROP_BIT64("csum", VirtIONet, host_features, VIRTIO_NET_F_CSUM, true), --=20 2.47.1 From nobody Sat Nov 15 10:42:25 2025 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=1753188323; cv=none; d=zohomail.com; s=zohoarc; b=WPMJ57CLvvx9qOC5/z21W/OU2yDaVynGoncKQYP3lrFvIieTjffzhE0zOg62xpopf5cBBv6Iyu4Z7qAmjPG8t9o6aLqiifST4Cwi5rQx0sRaZwJFoCnIDBurln/96+V0wHvpXercnLl/ANuGZ51aTYW3MPOMqOLyFbMUJamiDjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753188323; 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=T7tNIDru02PeriUSzz8aBkyb9Tz6kpEvzGllNy4b8Ow=; b=Pgh0ZXuXNQ0K+vr7zVSjVrzJP0Xh8UexgSmASsO/yfLUCk6+6aCQ95Ml850nMW/V0tHUKZiFDmuEbmfBOP6k6yqCSAtDfg+zebF+nI5Sy7HRBcFscW3mri0TG1iUZ2ztq93kHil+hxCafxyud5bWnTKlvdW4se9tYkTlmOIot6o= 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 1753188323701639.8848100617917; Tue, 22 Jul 2025 05:45:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ueCKV-00030A-7j; Tue, 22 Jul 2025 08:42:47 -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 1ueCJU-0002O6-3g for qemu-devel@nongnu.org; Tue, 22 Jul 2025 08:41:48 -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 1ueCJN-0006Kd-HH for qemu-devel@nongnu.org; Tue, 22 Jul 2025 08:41:41 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56M5TAKE024432; Tue, 22 Jul 2025 12:41:35 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48057qw70u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jul 2025 12:41:34 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 56MBU3m0010414; Tue, 22 Jul 2025 12:41:34 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4801t99gbh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jul 2025 12:41:33 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 56MCfT3t039536; Tue, 22 Jul 2025 12:41:33 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4801t99g9h-4; Tue, 22 Jul 2025 12:41: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=T7tNI Dru02PeriUSzz8aBkyb9Tz6kpEvzGllNy4b8Ow=; b=nEwUWOnvAD0HMvVxUF0Ut 2qA6LO2CPSwbfk7VWbRhInMylUoUplIzaWoe2MWQRhoACry2Q/ce9BEiuvu0idUt KKCR21LtoDPylL/yLgQRogbz67YfvkLpxnNGYe3eO1pPyxb+LNnLsEUmoEadUD9w 7EZE8JuiV0CnQrr8r0UbioB4KrIBuGRnendUOXCq7Qd3HDIQBGGzbY/dCdqxuKDL gHmFTWo9KDiLXT3lFwtFXJoqGYZQNd97Iemab08SI35hXBDSXRQcKiLhfgkBAF30 9WXI1Xu6dsX4cuRIkQk913sSg077PpgD+lpgmcvff/6koY8sAQA1YjD8qSK+2kpX w== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, eblake@redhat.com, armbru@redhat.com, jasowang@redhat.com, mst@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Subject: [RFC 3/6] virtio-net: Add SaveVMHandlers for iterative migration Date: Tue, 22 Jul 2025 12:41:24 +0000 Message-ID: <20250722124127.2497406-4-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250722124127.2497406-1-jonah.palmer@oracle.com> References: <20250722124127.2497406-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.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-22_02,2025-07-21_02,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2505160000 definitions=main-2507220104 X-Authority-Analysis: v=2.4 cv=MNRgmNZl c=1 sm=1 tr=0 ts=687f86fe cx=c_pps a=OOZaFjgC48PWsiFpTAqLcw==:117 a=OOZaFjgC48PWsiFpTAqLcw==:17 a=Wb1JkmetP80A:10 a=yPCof4ZbAAAA:8 a=EcWnT0cij3RzOpli2RYA:9 X-Proofpoint-ORIG-GUID: eGsc5JN3OklBUXGlRewXEwdXWNmDAS1Q X-Proofpoint-GUID: eGsc5JN3OklBUXGlRewXEwdXWNmDAS1Q X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzIyMDEwNCBTYWx0ZWRfX7JZIK4xHQpwi TuujY955QsZMMR0N6Hp27FqYfsAZ3+vqgv6WztiEj3a3s632tTAgKprmI70en6Ulw0trrzo2fBD 4RQ0FMZyWANhdzDHId/X2RTGCo2m6RA6ua8Kk/I/mWTC3FLkXdZ3VplOZ00lE7RUhpX4ZuTq6CQ vmJIBMvYNxQznbHLHAyiGlc1tWsn+HIEozF9wjwkAMdil4dZ8WRJNgXEGECDi2wOhzaE9Y4G6fj Kzh39fZfQIkDuYpncSK1jYp7TE90fWNZ78VO/kCDXQLAY8TD5w/YIx1dLPXXPwM/cojta5PopF5 of0UdeU1rvG2qix1fWPpx5CVZpPNjjdC5ioBklHYfM8apD9C2E6PjG41+QWhsjU1HXWzw0s3jOQ 7m5LBvJMoSqiWyIjZKFiEyHMBOfKx5AvT3jx8aU0zyCdGg7bc0NiouINcFSgI4mbhG3lLkVf 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1753188324442116600 Content-Type: text/plain; charset="utf-8" Add SaveVMHandlers struct for virtio-net iterative migration support. The handlers are registered but only contain no-op implementations. This provides the framework for iterative migration without changing any actual migration behavior when the capability is disabled. A BFD representation is used when registering a virtio-net device's SaveVMHandlers hooks. This is to create unique IDs in the case of multiple virtio-net devices. Signed-off-by: Jonah Palmer Tested-by: Lei Yang --- hw/net/virtio-net.c | 85 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 93029104b3..19aa5b5936 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -17,6 +17,7 @@ #include "qemu/log.h" #include "qemu/main-loop.h" #include "qemu/module.h" +#include "qemu/cutils.h" #include "hw/virtio/virtio.h" #include "net/net.h" #include "net/checksum.h" @@ -38,6 +39,9 @@ #include "qapi/qapi-events-migration.h" #include "hw/virtio/virtio-access.h" #include "migration/misc.h" +#include "migration/register.h" +#include "migration/qemu-file.h" +#include "migration/migration.h" #include "standard-headers/linux/ethtool.h" #include "system/system.h" #include "system/replay.h" @@ -3791,11 +3795,77 @@ static const VMStateDescription vmstate_virtio_net = =3D { .dev_unplug_pending =3D dev_unplug_pending, }; =20 +static bool virtio_net_iterative_migration_enabled(void) +{ + MigrationState *s =3D migrate_get_current(); + return s->capabilities[MIGRATION_CAPABILITY_VIRTIO_ITERATIVE]; +} + +static bool virtio_net_is_active(void *opaque) +{ + return virtio_net_iterative_migration_enabled(); +} + +static int virtio_net_save_setup(QEMUFile *f, void *opaque, Error **errp) +{ + return 0; +} + +static int virtio_net_save_live_iterate(QEMUFile *f, void *opaque) +{ + return 1; +} + +static int virtio_net_save_live_complete_precopy(QEMUFile *f, void *opaque) +{ + return 0; +} + +static void virtio_net_save_cleanup(void *opaque) +{ + +} + +static int virtio_net_load_setup(QEMUFile *f, void *opaque, Error **errp) +{ + return 0; +} + +static int virtio_net_load_state(QEMUFile *f, void *opaque, int version_id) +{ + return 0; +} + +static int virtio_net_load_cleanup(void *opaque) +{ + return 0; +} + +static void virtio_net_state_pending_exact(void *opaque, uint64_t *must_pr= ecopy, + uint64_t *can_postcopy) +{ + +} + +static const SaveVMHandlers savevm_virtio_net_handlers =3D { + .is_active =3D virtio_net_is_active, + .save_setup =3D virtio_net_save_setup, + .save_live_iterate =3D virtio_net_save_live_iterate, + .save_live_complete_precopy =3D virtio_net_save_live_complete_precopy, + .save_cleanup =3D virtio_net_save_cleanup, + .load_setup =3D virtio_net_load_setup, + .load_state =3D virtio_net_load_state, + .load_cleanup =3D virtio_net_load_cleanup, + .state_pending_exact =3D virtio_net_state_pending_exact, +}; + static void virtio_net_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIONet *n =3D VIRTIO_NET(dev); NetClientState *nc; + g_autofree char *path =3D NULL; + char id[256] =3D ""; int i; =20 if (n->net_conf.mtu) { @@ -3963,12 +4033,21 @@ static void virtio_net_device_realize(DeviceState *= dev, Error **errp) if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) { virtio_net_load_ebpf(n, errp); } + + /* Register handlers for iterative migration */ + path =3D qdev_get_dev_path(DEVICE(&n->parent_obj)); + path =3D g_strdup_printf("%s/virtio-net-iterative", path); + strpadcpy(id, sizeof(id), path, '\0'); + register_savevm_live(id, VMSTATE_INSTANCE_ID_ANY, 1, + &savevm_virtio_net_handlers, n); } =20 static void virtio_net_device_unrealize(DeviceState *dev) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIONet *n =3D VIRTIO_NET(dev); + g_autofree char *path =3D NULL; + char id[256] =3D ""; int i, max_queue_pairs; =20 if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) { @@ -4007,6 +4086,12 @@ 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); + + /* Unregister migration handlers */ + path =3D qdev_get_dev_path(DEVICE(&n->parent_obj)); + path =3D g_strdup_printf("%s/virtio-net-iterative", path); + strpadcpy(id, sizeof(id), path, '\0'); + unregister_savevm(VMSTATE_IF(dev), id, n); } =20 static void virtio_net_reset(VirtIODevice *vdev) --=20 2.47.1 From nobody Sat Nov 15 10:42:25 2025 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=1753188206; cv=none; d=zohomail.com; s=zohoarc; b=dXmVQBK2oWVd2WEt0bj4d2xTFhbTb08AXqOjBCcxjwGuLqNdawD702jKY1VXWr02vzMuDrZsdA7tySiiMYv4P18Rn0yREDvNerEGXaq89CF7VkKKUBByiZhc27YBJXrk1ZSAz9nc3WPST3sU+5a6b8v8n61kpDDZpbUqNOR2ocI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753188206; 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=ogUusNb8abplo4/L0tdtqGz4oTrmEgBVtp4/Ei2IsC4=; b=kotHJztZBQZs50HI/FCAXRATbmJUhvHQZBZC4f3VCxwqEHuQ/MkcBUbqOvy3jMsfOMEVcgxp/QxMwkzSWkGL/uFzXi5HN5TTw05tT+WLy+cOp/c8Gs3bQ6LC82ybMqe3qsBwn/5qyTIfI0jhBShgFpnsHgSiROBd46m0BQN60oE= 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 1753188206459754.5212868295367; Tue, 22 Jul 2025 05:43:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ueCKY-000392-S8; Tue, 22 Jul 2025 08:42:50 -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 1ueCJU-0002O7-3g for qemu-devel@nongnu.org; Tue, 22 Jul 2025 08:41:48 -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 1ueCJN-0006L2-VG for qemu-devel@nongnu.org; Tue, 22 Jul 2025 08:41:42 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56M5TAwT024411; Tue, 22 Jul 2025 12:41:36 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 48057qw70x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jul 2025 12:41:36 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 56MBJr7g010262; Tue, 22 Jul 2025 12:41:35 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4801t99gc3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jul 2025 12:41:35 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 56MCfT3v039536; Tue, 22 Jul 2025 12:41:34 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4801t99g9h-5; Tue, 22 Jul 2025 12:41: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=ogUus Nb8abplo4/L0tdtqGz4oTrmEgBVtp4/Ei2IsC4=; b=ifLfv4BarK5GBAQVdLcPZ 3NmJkpgWEK7lnRVGWFWqLe7Qfoj1gayYwMnXyXUhSwfODJClEmv683eVliv9THYl CPSAHABfD3hpj4/bEBYjsQbsHw6IsLjrOuD17S2Jb/GtIQXJQyQXy+SH8j9apF1r tKyQ3bxLV+XotWr1wXHcDRcEb3SqkBj2gtWNqqn1FlFomLux6J8HSHkWpYx+buJk pAMzv/UmKOh3FyhqeKUk31/JQT+ykmLFxpSDhfCX10cGfGa86QbxpeQj0F0V3KJS p+uFbNPG7fY0IGLeyUfpZbGS9X1lRwpqm/SagwrhciTon0Ay5BWSqU9wZOu9s06I Q== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, eblake@redhat.com, armbru@redhat.com, jasowang@redhat.com, mst@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Subject: [RFC 4/6] virtio-net: iter live migration - migrate vmstate Date: Tue, 22 Jul 2025 12:41:25 +0000 Message-ID: <20250722124127.2497406-5-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250722124127.2497406-1-jonah.palmer@oracle.com> References: <20250722124127.2497406-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.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-22_02,2025-07-21_02,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2505160000 definitions=main-2507220104 X-Authority-Analysis: v=2.4 cv=MNRgmNZl c=1 sm=1 tr=0 ts=687f8700 cx=c_pps a=OOZaFjgC48PWsiFpTAqLcw==:117 a=OOZaFjgC48PWsiFpTAqLcw==:17 a=Wb1JkmetP80A:10 a=yPCof4ZbAAAA:8 a=sg1MOQW8EVPkchQJ_ukA:9 X-Proofpoint-ORIG-GUID: 3npKTO5TyU8r6hxB6GtgL0lawjxwGUWC X-Proofpoint-GUID: 3npKTO5TyU8r6hxB6GtgL0lawjxwGUWC X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzIyMDEwNCBTYWx0ZWRfX6e7mD6CalmPb 1nnEy+r6LjZLk1AgytXyrd7W23J1NZiJeYLke6j1ZHl6yg+Sm4VWJfsfEDXpgamDvfiM0fGp+f5 yN2bqDV4f+9/VRnRkNyTVlOE+bIXstHqZ70qzHOJPe698yYLcogApA5aHKtEzc60QP22aPZQ/Kw XdUjZ66MAZKLcOTbibOhAkf2gdVA+oDNDtzPE1GbRtFcPyDmfzQz85Hk+yZEhtSENCLr6mlwwEI ncw8XmGHuH3strrqcGKK5gNMFpZvdyI/rlJ3cCslpFiExs/ZQiSmhbZZss87NG4nl4nWUht1ZGn 6L43GGaBHSZurqxsl8SdcSUbjMWh6sC4o5NXKM5XnCbTXNu+tlihRcF7mgVOrhXuh6z3oe1hFX+ YXWZPPiUFKSDO3tQ49eZCXmga5XwAZesDaUghmYDZmK+Z5wkXP81zp0VnZBWP9LoSjNSeshq 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1753188208866116600 Content-Type: text/plain; charset="utf-8" Lays out the initial groundwork for iteratively migrating the state of a virtio-net device, starting with its vmstate (via vmstate_save_state & vmstate_load_state). The original non-iterative vmstate framework still runs during the stop-and-copy phase when the guest is paused, which is still necessary to migrate over the final state of the virtqueues once the sourced has been paused. Although the vmstate framework is used twice (once during the iterative portion and once during the stop-and-copy phase), it appears that there's some modest improvement in guest-visible downtime when using a virtio-net device. When tracing the vmstate_downtime_save and vmstate_downtime_load tracepoints, for a virtio-net device using iterative live migration, the non-iterative downtime portion improved modestly, going from ~3.2ms to ~1.4ms: Before: Tested-by: Lei Yang ------- vmstate_downtime_load type=3Dnon-iterable idstr=3D0000:00:03.0/virtio-net instance_id=3D0 downtime=3D3594 After: ------ vmstate_downtime_load type=3Dnon-iterable idstr=3D0000:00:03.0/virtio-net instance_id=3D0 downtime=3D1607 This improvement is likely due to the initial vmstate_load_state call (while the guest is still running) "warming up" all related pages and structures on the destination. In other words, by the time the final stop-and-copy phase starts, the heavy allocations and page-fault latencies are reduced, making the device re-loads slightly faster and the guest-visible downtime window slightly smaller. Future patches could improve upon this by skipping the second vmstate_save/load_state calls (during the stop-and-copy phase) and instead only send deltas right before/after the source is stopped. Signed-off-by: Jonah Palmer --- hw/net/virtio-net.c | 37 ++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio-net.h | 8 ++++++++ 2 files changed, 45 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 19aa5b5936..86a6fe5b91 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3808,16 +3808,31 @@ static bool virtio_net_is_active(void *opaque) =20 static int virtio_net_save_setup(QEMUFile *f, void *opaque, Error **errp) { + VirtIONet *n =3D opaque; + + qemu_put_be64(f, VNET_MIG_F_INIT_STATE); + vmstate_save_state(f, &vmstate_virtio_net, n, NULL); + qemu_put_be64(f, VNET_MIG_F_END_DATA); + return 0; } =20 static int virtio_net_save_live_iterate(QEMUFile *f, void *opaque) { + bool new_data =3D false; + + if (!new_data) { + qemu_put_be64(f, VNET_MIG_F_NO_DATA); + return 1; + } + + qemu_put_be64(f, VNET_MIG_F_END_DATA); return 1; } =20 static int virtio_net_save_live_complete_precopy(QEMUFile *f, void *opaque) { + qemu_put_be64(f, VNET_MIG_F_NO_DATA); return 0; } =20 @@ -3833,6 +3848,28 @@ static int virtio_net_load_setup(QEMUFile *f, void *= opaque, Error **errp) =20 static int virtio_net_load_state(QEMUFile *f, void *opaque, int version_id) { + VirtIONet *n =3D opaque; + uint64_t flag; + + flag =3D qemu_get_be64(f); + if (flag =3D=3D VNET_MIG_F_NO_DATA) { + return 0; + } + + while (flag !=3D VNET_MIG_F_END_DATA) { + switch (flag) { + case VNET_MIG_F_INIT_STATE: + { + vmstate_load_state(f, &vmstate_virtio_net, n, VIRTIO_NET_VM_VE= RSION); + break; + } + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s: Uknown flag 0x%"PRIx64, __= func__, flag); + return -EINVAL; + } + + flag =3D qemu_get_be64(f); + } return 0; } =20 diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index b9ea9e824e..d6c7619053 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -163,6 +163,14 @@ typedef struct VirtIONetQueue { struct VirtIONet *n; } VirtIONetQueue; =20 +/* + * Flags to be used as unique delimiters for virtio-net devices in the + * migration stream. + */ +#define VNET_MIG_F_INIT_STATE (0xffffffffef200000ULL) +#define VNET_MIG_F_END_DATA (0xffffffffef200001ULL) +#define VNET_MIG_F_NO_DATA (0xffffffffef200002ULL) + struct VirtIONet { VirtIODevice parent_obj; uint8_t mac[ETH_ALEN]; --=20 2.47.1 From nobody Sat Nov 15 10:42:25 2025 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=1753188206; cv=none; d=zohomail.com; s=zohoarc; b=nU3xNDkxVQzeSg983Dgh0b9ACzkYyFUr/lxv+JcnzfJYIeHGRRbQMmm8lUiwmO2lHrnaaxjywMgy/uDekaBeQcN4JZGF4+L0cCJgfHDSjauo2Z9MMRR513BfNQSNBnok5UjUwuitP9fLueZXmCv89hhXB9hFzJo8/oP+BnFS5U4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753188206; 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=udCm3rQJ9v1mNX6dwFqc4R9vJOWnpGCGOSOWjfUFE1Q=; b=YhY90I2Zl2bMALDZOawDnuAMjEwbi6uALVYmKienxHDaQ1LE0/j7vV8P75rgWUC89NWvd63wa2ccsvtzAf+A2sktiE0Fx0/iUD1JorxY3/FjoWQJPgtcg5Z8NdI3x3u/IhFZWjFrHJLabgQEr5TvTGakUAJ5KWtBaR75ycnvnEM= 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 1753188206572943.7212619259146; Tue, 22 Jul 2025 05:43:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ueCKV-00032f-FS; Tue, 22 Jul 2025 08:42:47 -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 1ueCJV-0002Oy-9W for qemu-devel@nongnu.org; Tue, 22 Jul 2025 08:41:48 -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 1ueCJQ-0006LR-2t for qemu-devel@nongnu.org; Tue, 22 Jul 2025 08:41:43 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56M5TAZb002504; Tue, 22 Jul 2025 12:41:37 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4805hpd580-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jul 2025 12:41:37 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 56MCHZTZ010356; Tue, 22 Jul 2025 12:41:36 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4801t99gcw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jul 2025 12:41:36 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 56MCfT3x039536; Tue, 22 Jul 2025 12:41:35 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4801t99g9h-6; Tue, 22 Jul 2025 12:41:35 +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=udCm3 rQJ9v1mNX6dwFqc4R9vJOWnpGCGOSOWjfUFE1Q=; b=g2Uu8W9iEbUZ6NuYZASUv tIlWHoybJjY4+OgoU9UWRqGaJHeIG1UbhTUJEpitP7MdG8HZCubl708RqJhCnoPd uooB8/rweZNZKJdu89RYuz+7WoKsmOaWZXTshRP4cHxtisuk2KWQLHzJPBqsSqz8 /u6l/quD6Hzrt4Zp/nMCvrBOFJ7q3FLpqIStb0ipVPEGF7mHK3SKCGef3q2hUpE1 iBYSftPffDLeukI/GobyikQ2RGJEHck0heXjvR4e5vF7dXXDFGD3X3+hd9Uuct2u iLp8NCd6V8imUWDFxT7zcltwQIzRWxOHLKfW2M1jf3g9nmKqOygd9DFMIJ3RzOB3 w== To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, eblake@redhat.com, armbru@redhat.com, jasowang@redhat.com, mst@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Subject: [RFC 5/6] virtio, virtio-net: skip consistency check in virtio_load for iterative migration Date: Tue, 22 Jul 2025 12:41:26 +0000 Message-ID: <20250722124127.2497406-6-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250722124127.2497406-1-jonah.palmer@oracle.com> References: <20250722124127.2497406-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.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-22_02,2025-07-21_02,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2505160000 definitions=main-2507220104 X-Proofpoint-ORIG-GUID: _COdjGfAkEcheAkQqFVhqtdxyTzAtyDj X-Authority-Analysis: v=2.4 cv=YY+95xRf c=1 sm=1 tr=0 ts=687f8701 cx=c_pps a=OOZaFjgC48PWsiFpTAqLcw==:117 a=OOZaFjgC48PWsiFpTAqLcw==:17 a=Wb1JkmetP80A:10 a=yPCof4ZbAAAA:8 a=ncbDbCRbhD_Ka3aqogoA:9 X-Proofpoint-GUID: _COdjGfAkEcheAkQqFVhqtdxyTzAtyDj X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzIyMDEwNCBTYWx0ZWRfXxRrh7JVNjT/U GZDyMg5+GarRZduLMBrYMOb85rkDSwQbSlUyNCPAUdD9ktdEJjwZBg2SnO4UEQzwaPBYxw7mJ/c vgNkhNVQ8T8WTgYS7d8V6ac63IzzHOWGmiohp0PsMAEiH5b3WdWz1oV8prAFt8+3aWtrh9JG/TE a6/sCDNFka8qFwLow9lSkPEEXgFv9T2ooW2XBcqd9RzsrMe24zaX9+1pMhFDFMmdxcGYLNTODQY IACUa3VuRUoqrw45Hu/2yf5utCwMy3pdibUKCshS1Dp6HZT98WVDNgBCalk0oj/XHaytLXLLYJK QoKCfUowlzzxedsgVu6hJRW/Rj6y4re3Y1fUiMQUmo2CRiLiQLAgET19U9DjosqdtWUSjEwmbDn DPQI6xmfpYP0KNOg28dLfpDvqchF37/Ex2yQP3iSQu+MjvuRlAHcphNTG3S4eTbDCqxuarbV 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Jonah Palmer From: Jonah Palmer via 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: 1753188208878116600 Content-Type: text/plain; charset="utf-8" Iterative live migration for virtio-net sends an initial VMStateDescription while the source is still active. Because data continues to flow for virtio-net, the guest's avail index continues to increment after last_avail_idx had already been sent. This causes the destination to often see something like this from virtio_error(): VQ 0 size 0x100 Guest index 0x0 inconsistent with Host index 0xc: delta 0xf= ff4 This patch suppresses this consistency check if we're loading the initial VMStateDescriptions via iterative migration and unsuppresses it for the stop-and-copy phase when the final VMStateDescriptions (carrying the correct indices) are loaded. A temporary VirtIODevMigration migration data structure is introduced here = to represent the iterative migration process for a VirtIODevice. For now it just holds a flag to indicate whether or not the initial VMStateDescription was sent during the iterative live migration process. Signed-off-by: Jonah Palmer Tested-by: Lei Yang --- hw/net/virtio-net.c | 13 +++++++++++++ hw/virtio/virtio.c | 32 ++++++++++++++++++++++++-------- include/hw/virtio/virtio.h | 6 ++++++ 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 86a6fe5b91..b7ac5e8278 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3843,12 +3843,19 @@ static void virtio_net_save_cleanup(void *opaque) =20 static int virtio_net_load_setup(QEMUFile *f, void *opaque, Error **errp) { + VirtIONet *n =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + vdev->migration =3D g_new0(VirtIODevMigration, 1); + vdev->migration->iterative_vmstate_loaded =3D false; + return 0; } =20 static int virtio_net_load_state(QEMUFile *f, void *opaque, int version_id) { VirtIONet *n =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + VirtIODevMigration *mig =3D vdev->migration; uint64_t flag; =20 flag =3D qemu_get_be64(f); @@ -3861,6 +3868,7 @@ static int virtio_net_load_state(QEMUFile *f, void *o= paque, int version_id) case VNET_MIG_F_INIT_STATE: { vmstate_load_state(f, &vmstate_virtio_net, n, VIRTIO_NET_VM_VE= RSION); + mig->iterative_vmstate_loaded =3D true; break; } default: @@ -3875,6 +3883,11 @@ static int virtio_net_load_state(QEMUFile *f, void *= opaque, int version_id) =20 static int virtio_net_load_cleanup(void *opaque) { + VirtIONet *n =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + g_free(vdev->migration); + vdev->migration =3D NULL; + return 0; } =20 diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 5534251e01..68957ee7d1 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3222,6 +3222,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); @@ -3365,6 +3366,16 @@ 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 during iterative migration= . The actual + * indices will be sent later during the stop-and-copy phase. + */ + if (vdev->migration) { + inconsistent_indices =3D !vdev->migration->iterative_vmsta= te_loaded; + } else { + inconsistent_indices =3D false; + } + /* * 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 @@ -3384,14 +3395,19 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int ve= rsion_id) continue; } =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) { - 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); + if (!inconsistent_indices) { + nheads =3D vring_avail_idx(&vdev->vq[i]) - vdev->vq[i].las= t_avail_idx; + /* Check it isn't doing strange things with descriptor num= bers. */ + if (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 214d4a77e9..06b6e6ba65 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -98,6 +98,11 @@ enum virtio_device_endian { VIRTIO_DEVICE_ENDIAN_BIG, }; =20 +/* VirtIODevice iterative live migration data structure */ +typedef struct VirtIODevMigration { + bool iterative_vmstate_loaded; +} VirtIODevMigration; + /** * struct VirtIODevice - common VirtIO structure * @name: name of the device @@ -151,6 +156,7 @@ struct VirtIODevice bool disable_legacy_check; bool vhost_started; VMChangeStateEntry *vmstate; + VirtIODevMigration *migration; char *bus_name; uint8_t device_endian; /** --=20 2.47.1 From nobody Sat Nov 15 10:42:25 2025 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=1753188263; cv=none; d=zohomail.com; s=zohoarc; b=UDx0XsjaG97o5dyQAWcfm4J959ZiSPCwE3d3PScNpp1r95oseqGLvHijoRp1cCA1DOmDhseT5D3IMbN8TCyGTauKbUPQSwaQy+ly9NLWSjMN298knGI7nY6/36EHrSLCY+sKKbxIloUWCw97OJ7Pj7NIo1I8B68DsbruqUqFmEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753188263; 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=Rl49krj7ViSaTPPGMRA6RmJFt6EEl+djuAVv29tgwhw=; b=M3zccCmzacNVlGQB8XkgqGthhviR9c8n3W1F2RB3FpFO7z9GUgnH5XEZMb+IQfF2HdCYnnO6lXlBB9IB/f+w4d49AgI09KfHzmqOeikMY7t8v87HNUPmCmG2qndZmEnoFPmbo075cU0FgjPi4EXpRR4x2FxuqyU+o/eFkvERZBA= 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 17531882638371012.620681808635; Tue, 22 Jul 2025 05:44:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ueCKX-000367-C0; Tue, 22 Jul 2025 08:42: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 1ueCJV-0002P2-Ap for qemu-devel@nongnu.org; Tue, 22 Jul 2025 08:41:48 -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 1ueCJQ-0006Lg-FU for qemu-devel@nongnu.org; Tue, 22 Jul 2025 08:41:44 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 56M5TAYZ002494; Tue, 22 Jul 2025 12:41:38 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4805hpd584-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jul 2025 12:41:38 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 56MBf90b010337; Tue, 22 Jul 2025 12:41:37 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4801t99gdk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jul 2025 12:41:37 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 56MCfT41039536; Tue, 22 Jul 2025 12:41:37 GMT Received: from jonah-amd-ol9-bm.osdevelopmeniad.oraclevcn.com (jonah-amd-ol9-bm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.252.67]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4801t99g9h-7; Tue, 22 Jul 2025 12:41:37 +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=Rl49k rj7ViSaTPPGMRA6RmJFt6EEl+djuAVv29tgwhw=; b=oNz7sp0LQr+4lGlyZeGs3 o+IF9y+RZ+vQL/6XLMgIr98ORCt7/l2TYEm6LbgU/ifgiMQw8M+I5/fzxPknlotM iVcZbrpvVxI8ptLG9kOfdGovCK7LNK7KN7HOshi/RXu8Q6txt6n6LlVzFsV9vFXe FmNdJlv14/HpwaGwMG2SP8/RXWQOSxTNMJj18W9adHpk8Eu+N00wZdz3Kx6OQ6YT Grwpta1lh4zABundQytBDpLa750cuZ/M8phb9fKIzW7JJVv7Lxgc6X/CHfI5iL5J ZZgn5axseqFKtJeQLsrO2DDyLqwLyQV+gPHmfWSUDXhsPd3xqk48vFXQZ9wRYM4u g== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, eblake@redhat.com, armbru@redhat.com, jasowang@redhat.com, mst@redhat.com, si-wei.liu@oracle.com, eperezma@redhat.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Subject: [RFC 6/6] virtio-net: skip vhost_started assertion during iterative migration Date: Tue, 22 Jul 2025 12:41:27 +0000 Message-ID: <20250722124127.2497406-7-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250722124127.2497406-1-jonah.palmer@oracle.com> References: <20250722124127.2497406-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.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-22_02,2025-07-21_02,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2505160000 definitions=main-2507220104 X-Proofpoint-ORIG-GUID: NMkobAYHwjzZ4RjayJK_EdtlBXcSPSJh X-Authority-Analysis: v=2.4 cv=YY+95xRf c=1 sm=1 tr=0 ts=687f8702 cx=c_pps a=OOZaFjgC48PWsiFpTAqLcw==:117 a=OOZaFjgC48PWsiFpTAqLcw==:17 a=Wb1JkmetP80A:10 a=yPCof4ZbAAAA:8 a=9V0WdlfnHfHVK-SkIusA:9 X-Proofpoint-GUID: NMkobAYHwjzZ4RjayJK_EdtlBXcSPSJh X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzIyMDEwNCBTYWx0ZWRfX/6SVOmdGDsLQ QOBemMUWsXM5ZbIwT/F66I0UMZCLjSd6VY04i0gaij+rLJWmdAyPpdpgijEXnD8nzPj4o3XHcav 9Q4fhuXfTmG2YphFYf1zn5vjRAd4fdf4EapRfP983viCM5yYw29judLhUGCRDoKTJI5dgsnWFDE u9X6ujA7JFSd52fK4x5ZEuBFozz7TiK9+CwWK/Ffde24Da00MP1k/MEBvzcJVpkJ/FHmNJL5H0y 6GowUQN01hq7GH8mG8snlyp537V5QNTlSx7Kpfzia683tNY+g+PNvDCfRcAyqa8nEg1VHaCMjc2 JIrcsqKoILc4Gj8x95XnWcP9GCjooS2zXVnOpJRrCEUtbQ7nGqNz74v4+Uyblq9/TbZADZFORdN DlurALeds5FPR/Mz80wa6xsQz0T6iIU/xUhZ9pefLF+zM3nyJLDVAj6ICnyXqriWAAKjLJIH 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1753188265414116600 Content-Type: text/plain; charset="utf-8" Initializes vhost-net support for iterative live migration by avoiding the assertion that vhost needs to be stopped before proceeding with sending the initial VMStateDescription for virtio-net. This should be okay to do since we only care about the static device state and not the dynamic ring states for the initial sending of the device state. After the iterative migration portion is finished and the source is stopped, we still assert that vhost is also stopped. Signed-off-by: Jonah Palmer Tested-by: Lei Yang --- hw/net/virtio-net.c | 23 ++++++++++++++++++++++- include/hw/virtio/virtio.h | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index b7ac5e8278..07941f991e 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3753,6 +3753,19 @@ static bool failover_hide_primary_device(DeviceListe= ner *listener, static int virtio_net_pre_save(void *opaque) { VirtIONet *n =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + + /* + * During iterative migration, vhost will still be active. However, + * this shouldn't be an issue since we don't care about the dynamic + * ring states at this point. + * + * The final migration at the end will still occur with vhost stopped + * and any inconsistencies will be overwritten. + */ + if (vdev->migration && !vdev->migration->iterative_vmstate_sent) { + return 0; + } =20 /* At this point, backend must be stopped, otherwise * it might keep writing to memory. */ @@ -3809,11 +3822,16 @@ static bool virtio_net_is_active(void *opaque) static int virtio_net_save_setup(QEMUFile *f, void *opaque, Error **errp) { VirtIONet *n =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + vdev->migration =3D g_new0(VirtIODevMigration, 1); + vdev->migration->iterative_vmstate_sent =3D false; =20 qemu_put_be64(f, VNET_MIG_F_INIT_STATE); vmstate_save_state(f, &vmstate_virtio_net, n, NULL); qemu_put_be64(f, VNET_MIG_F_END_DATA); =20 + vdev->migration->iterative_vmstate_sent =3D true; + return 0; } =20 @@ -3838,7 +3856,10 @@ static int virtio_net_save_live_complete_precopy(QEM= UFile *f, void *opaque) =20 static void virtio_net_save_cleanup(void *opaque) { - + VirtIONet *n =3D opaque; + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + g_free(vdev->migration); + vdev->migration =3D NULL; } =20 static int virtio_net_load_setup(QEMUFile *f, void *opaque, Error **errp) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 06b6e6ba65..aa3f60cb7b 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -101,6 +101,7 @@ enum virtio_device_endian { /* VirtIODevice iterative live migration data structure */ typedef struct VirtIODevMigration { bool iterative_vmstate_loaded; + bool iterative_vmstate_sent; } VirtIODevMigration; =20 /** --=20 2.47.1