From nobody Sun Sep 28 16:33:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1758378699; cv=none; d=zohomail.com; s=zohoarc; b=WfslFV6Xw5uXK/kbl4ibcE427xUSxQ7NRPsDRqCHNL3nmKqCZbSz+pZXMoyzVmzwPOJpi01llgpQU1xF1ieg3ZSlJ4HRxRI6aKWSltueh6G9GFANwa/D37myCy1JRdzGyfjyBx/ucL5nM4h95xgO23Zd0mcp8T3MXIonX4ghgH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758378699; 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=l9jcGdX1lSvJdDQcVF4FUrlARni1t0sPnSGCmO+JHDo=; b=KW8wplS491yl3GCAr3XEiex+nf0q+ubsgYREC2C8Ph5wG8TKyCUkaVvi0JuU2+VQNT7bSUGxG1ruYyi4uZ2xImE5WFA08BWrv7eHdl03W+AAX+QR/sUAt/fkVAZpWrTvWjtEaU0M23SDFTudVgLPfF1WrieS/U/JMvv9/FDiNCE= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758378699637313.6642899075158; Sat, 20 Sep 2025 07:31:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uzybf-0007T1-DX; Sat, 20 Sep 2025 10:30:31 -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 1uzybd-0007Rr-Lu for qemu-devel@nongnu.org; Sat, 20 Sep 2025 10:30:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uzybW-0005U1-Iv for qemu-devel@nongnu.org; Sat, 20 Sep 2025 10:30:28 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-126-WEdMH3o4Pf2RjuC79T_biw-1; Sat, 20 Sep 2025 10:30:20 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3ee888281c3so1647070f8f.3 for ; Sat, 20 Sep 2025 07:30:20 -0700 (PDT) Received: from [192.168.10.48] ([151.95.47.123]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3ee07407fa3sm12145305f8f.21.2025.09.20.07.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Sep 2025 07:30:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758378621; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l9jcGdX1lSvJdDQcVF4FUrlARni1t0sPnSGCmO+JHDo=; b=WqDBvlhCakKgem+C+xKH3sFtIcbTbrcmehkRCQq2pLnZtD2VzlFs1AmSLPdJVeQIqnFBrg x3DI42EwGtuMDuWQWbhWFSJo1ue+9ZJS1bMY8XGFwHOrSoFVdyUXXcHV+AbUthy6EVKgW5 YY/walyyT7OiCLlg25jkdXhjb9R022w= X-MC-Unique: WEdMH3o4Pf2RjuC79T_biw-1 X-Mimecast-MFC-AGG-ID: WEdMH3o4Pf2RjuC79T_biw_1758378619 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758378618; x=1758983418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l9jcGdX1lSvJdDQcVF4FUrlARni1t0sPnSGCmO+JHDo=; b=jUhwKZBm7vJyujgQAysNW8OSvPY0XF6jBWWnTyqjlEoScYJhT8kz9tM15yVmeeEwXD WydNtzDVb0YRQjDPOXKtV2YdpqgQyo+R5TmXTW9lHl+3FRCIfE/YpHHf7OtA6vNp7vt3 5qiAELT69Nm8j0Ymod+1jlAtAml7P9agYUG/tWQrHeXo44/+Jb281Rx7Ju8b3S/jxCWX Zn71Ifu/7T3EPSDJUXDG3Q/wBGcUhFZPphJEnpjaPVKioG4sQeXJnt/HRLtkXPPiEMcb DfokpjLoqrrwrCgiKmMswtaAJpc18iloBzFj+1un6UdVK51EIxAvGnoV6FFjbG4yEBQ5 Q7lA== X-Gm-Message-State: AOJu0YyCOmZ7PAVR+cV4rfFw4J+OPprmxhU/Zi+vv7u73Q3hNtAGnXYm TAIxdVzF2bdKXu6uQBfKesuQc/BPFci52h/VINhtLed+XNExhyoBcir2nmovO4xo9/5T4sVbACo IyuBbSu9eRwr1nlRTZ7LfSxv8rvpDHr8e4utwFzr5jn1wwyFGTqCbQ9Om0/ukoOcCQ2DuUQA1CO ciWaolqc5og/+J37Z9PCMVzJp6Jct25Ctc0QmlPL2O X-Gm-Gg: ASbGnct6a1ylUmHv1aNGxOG+WCiZr52Jk40uSWOiqsB4nHh41vBxOARMIQKUTsLmAJy R+0poRyAgmY34FRIcny5hFceAbK2+yBK1DDz0PtEpwc2hRuHByoHTRQN1MMrEMABQwbnvD1kYrn GEUb3D/Wq9mYEM7V3FwxhJdV4/nWljLrCC5Inr27twpvILbza174d60dv7IhsF0qc+Osrj4Zpok JrBVHilAHTXxGzFcd2X5Cj1cSpVYhyxMHd75z18mqPyzaZgvoXg/l8VP06ltXQpDePLTps7x33+ +fNu/mbs6LowzFnFkq/eAlc43Zxb7yB8TjiOH1CkXGh5rt7rg2CMCCPuGx0374UXwgtB1lKnr3O sr+xoS7zFvj8VDjMJTuyhhdkc173pCsf0SASnjbhUbj8= X-Received: by 2002:a05:6000:24c9:b0:3ec:ce37:3a6d with SMTP id ffacd0b85a97d-3ee857699acmr5746400f8f.47.1758378618448; Sat, 20 Sep 2025 07:30:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVsQCkxTEWRDRQztw0Hn3LuLOS8XxwHM2e/j9Mx0kRIkEmI+325YL5RSZSPJLHN5BW03f3fg== X-Received: by 2002:a05:6000:24c9:b0:3ec:ce37:3a6d with SMTP id ffacd0b85a97d-3ee857699acmr5746385f8f.47.1758378617995; Sat, 20 Sep 2025 07:30:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org, zhao1.liu@intel.com, manos.pitsidianakis@linaro.org Subject: [PATCH 7/7] rust: migration: implement ToMigrationState as part of impl_vmstate_bitsized Date: Sat, 20 Sep 2025 16:29:58 +0200 Message-ID: <20250920142958.181910-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250920142958.181910-1-pbonzini@redhat.com> References: <20250920142958.181910-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.045, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1758378701402116601 Content-Type: text/plain; charset="utf-8" This is most likely desirable, and is the easiest way to migrate a bit-sized value without peeking at the innards of the bilge crate. Signed-off-by: Paolo Bonzini --- rust/migration/src/vmstate.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index 421a236194d..882dab746fc 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -295,6 +295,25 @@ unsafe impl $crate::vmstate::VMState for $type { as ::bilge::prelude::Number>::Un= derlyingType as $crate::vmstate::VMState>::VAR= RAY_FLAG; } + + impl $crate::migratable::ToMigrationState for $type { + type Migrated =3D <<$type as ::bilge::prelude::Bitsized>::Arbi= traryInt + as ::bilge::prelude::Number>::Un= derlyingType; + + fn snapshot_migration_state(&self, target: &mut Self::Migrated= ) -> Result<(), $crate::InvalidError> { + *target =3D Self::Migrated::from(*self); + Ok(()) + } + + fn restore_migrated_state_mut( + &mut self, + source: Self::Migrated, + version_id: u8, + ) -> Result<(), $crate::InvalidError> { + *self =3D Self::from(source); + Ok(()) + } + } }; } =20 --=20 2.51.0