From nobody Sun Nov 29 02:11:45 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1795735108; cv=none; d=zohomail.com; s=zohoarc; b=VZ0C1OPRhZjCxL+R5tV2h2kNKRrx9XMLca4IvF+NyRwK+A3Q/kMdO+1ZssfoorVQtlx78BQEFMZG+HiqN9JhhNJHSmq2gB5yaoDKJDG6mqoDRKfiLdi7aO02AcdRtBFNcOEHlDGFqLyuD+I7fpjlvkDIky5dZI67hvg0rgrPFpo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795735108; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XXJ9ypDY2AOxVAmalw6mBL3xjy7VFUMWeYLCvMdaV+U=; b=Oon5MyVToMUeOuqq+VuXGJOu6LIDeHxh2eTclskxZ5x9hfXlsYZUxH+cl61RAxB0y0f6frS6yl9qzgGyUwRwkp9FFbviT4bAVHcZjKEUyGNxKowP7/Grl52p27KPEZvD6PR9FWdavHfonDroVWnFeN212pojXDil+QuxSkjY63I= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795735108006648.634182221427; Thu, 26 Nov 2026 15:18:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xWiht-000874-8H; Thu, 26 Nov 2026 18:16:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihm-00083V-3J for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihj-000617-FE for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:41 -0500 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-675-BM9sezzKNByCf_iBIK9Ihw-1; Thu, 26 Nov 2026 23:16:36 +0000 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-55d2bde4c78so102694141cf.1 for ; Thu, 26 Nov 2026 15:16:36 -0800 (PST) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-55dcdd1a2c6sm4501211cf.20.2026.11.26.15.16.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 15:16:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795734998; 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=XXJ9ypDY2AOxVAmalw6mBL3xjy7VFUMWeYLCvMdaV+U=; b=RLGCcwQHrQ6Ax2IhlFgg86irxmYivePvXOkE/NTSv2HDQbs9kRIAbWHOfdvgMiUmlnC5um Fk75ZTm6mMNjlJrTdZGoX1/1RMjMFpS1B7lSc4IgEczQv/ogE5w81FUg0kOIrnFV2lnFTr /zWJYlvPWIyiLb6FK7qj1o6nnANYOxA= X-MC-Unique: BM9sezzKNByCf_iBIK9Ihw-1 X-Mimecast-MFC-AGG-ID: BM9sezzKNByCf_iBIK9Ihw_1795734996 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1795734996; x=1796339796; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XXJ9ypDY2AOxVAmalw6mBL3xjy7VFUMWeYLCvMdaV+U=; b=KqGrMyNPnH6SL8JgmrVtp8qjwI8i5FaLXWRyQbClsAeMIrm+pddNQY5Y3dTb9G34QE UbF10AgrJ6fHnw9bWanLhHpfMCEV3KxR36ueojRqfgtFaiRsSIcXXMxWsNJPuVq1t2Cc h8ffrEMaIzkYXr6R9vELErIZJPJT9GEEG9b7CLMu1VaMbAoUhCwpQn02rnNyRT3pTa3N 8KDacZ7ip2TVpA46Y38l2Xr13m6hsKfi793wLzx7J5oDIodnjYweEy4keUEOqxYOeH8L 8mhczjFHcHhV6CX+uJWkJHT3y0js3wWeLW8D1XvJg1NEnAke0PLKPLBPrSPBquXxTgmD 0l5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795734996; x=1796339796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=XXJ9ypDY2AOxVAmalw6mBL3xjy7VFUMWeYLCvMdaV+U=; b=TXApR13xkLMTixoGjQASVhcqTJ5Q71PVNT2MXC9Vw6THd2wc3SDjeVhRc7v2D74tJu e3bW2Gv5k3bHcs/K7jS3B0MR+QttrAIxhsCdFBkc6ELiXO8VGk2cmBcNS3mnz296i43C ceyImCnoGDHISWVv4osCLx52yRSZpbiWQWFzXnzZQcrcwkUa7n95sFiqVS+NyBtJIvlK 1ScvgkTvy1i5ZKAicIK1DTPp7P+M0DI0jrMsvjqicD7c/ZeNa03vukU8g689VPX/eJQI 6VDRs+1xLib5UDswc46mNI3W0f9RN4c5XWJbgUtaDh+OWasVXja2aFKoB6/rfmFZzJbG yWQg== X-Gm-Message-State: APuU4Z+JkKrbGqPaWwS8NEsj51A4Lh9JW7tpgUtMKLOVq9Owf0Trwqra xQQs4DS5ZlTBu46dFgLDHGxR8ieG57wZ3quzO5AX3SjpDGKjbUscsUALHWgrBR/LgGV8gm54coC vOW8wbpw+gTfI7t9WbnqJQpVuli0oLK/gIYHJvbEdLF8SgJXj8AA2KbkECv+HJOrvY7fkqHTLlg +JvwU1c+ug6KV2Wr93ugeWH7W92tjBSBgHdBj30Q== X-Gm-Gg: AZFdTZe/SaIZiJ8cBFqYoq4sNi9Kc+c2ocedzxZrFWnE27lUwNs2R5MZW05WGTfwKul mG3RWBif4t3o03Ai5pTwBSKo3pK3Y6Ez0I2clVc9aaAXtFiWL1DL7v+99grf//QVoWYmstPHjhy RTB1aRY3C/BLeHt63TzfejHDZ02KzKiTzdGFJBiOd6FL30yrhNTf8B99BxQ0P7gCZ90E+tkFmMA 5LQ/jU8PulCdM/WHtOCr57V7rC3Vh0UoUrKEDncr9VzCIzx51m0CSXHw/KNFga314LCVfNgsk1x RlG6WffNh9+OroKYnRXGsrQ3tzqa7jqlaE+zXyNc8JU+VGRHIpNqJ2nMSZYVvvoxbSFAR/94eqJ jawzOon5jUHJmo1h5LqgnKBdAlu8w5AQbUwCOYDRSnsJw X-Received: by 2002:a05:622a:313:b0:55d:1944:a2ab with SMTP id d75a77b69052e-55d76a5af8dmr423326741cf.49.1795734996156; Thu, 26 Nov 2026 15:16:36 -0800 (PST) X-Received: by 2002:a05:622a:313:b0:55d:1944:a2ab with SMTP id d75a77b69052e-55d76a5af8dmr423326121cf.49.1795734995529; Thu, 26 Nov 2026 15:16:35 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , Peter Maydell , peterx@redhat.com, Fabiano Rosas , Gavin Shan , Zhao Liu Subject: [PATCH for-12.0 v2 1/9] rust/migration: Allow usize as the length of a varray Date: Thu, 26 Nov 2026 18:16:23 -0500 Message-ID: <20261126231631.3392756-2-peterx@redhat.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261126231631.3392756-1-peterx@redhat.com> References: <20261126231631.3392756-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: 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 @redhat.com) X-ZM-MESSAGEID: 1795735108756158500 Content-Type: text/plain; charset="utf-8" From: Zhao Liu Since commit f9f70b50e3eb ("migration: Introduce VMStateStructMember") and commit 1f0b40dccfe5 ("Rmigration: Remove redundant flags"), the length of a varray is no longer tied to a specific integer type. This makes it possible to use `usize` type for varray length. It's safe since it is used only to resolve varray lengths in the local vmstate code and is not used for migration. Thus, implement a "dummy" VMState for `usize` so that it can provide VARRAY_FLAG, and panic when anyone tries to define VMStateField with `usize` type (including integers, pointers, [usize; N], Box, BqlCell, etc). In addition, add a test case for such case. Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20261124095814.437738-2-zhao1.liu@intel.com Signed-off-by: Peter Xu --- rust/migration/src/vmstate.rs | 16 ++++++++-- rust/tests/tests/vmstate_tests.rs | 49 +++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index 5ed061f2ab..0b05db4e70 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -97,8 +97,8 @@ pub unsafe trait VMState { =20 /// A flag that is added to another field's `VMStateField` to specify = the /// length's type in a variable-sized array. If this is not a support= ed - /// type for the length (i.e. if it is not `u8`, `u16`, `u32`), using = it - /// in a call to [`vmstate_of!`](crate::vmstate_of) will cause a + /// type for the length (i.e. if it is not `u8`, `u16`, `u32`, `usize`= ), + /// using it in a call to [`vmstate_of!`](crate::vmstate_of) will caus= e a /// compile-time error. #[doc(hidden)] // https://github.com/rust-lang/rust/issues/149635 const VARRAY_FLAG: VMStateFlags =3D { @@ -256,6 +256,18 @@ unsafe impl $crate::vmstate::VMState for $type { impl_vmstate_scalar!(vmstate_info_uint64, u64); impl_vmstate_scalar!(vmstate_info_timer, util::timer::Timer); =20 +// SAFETY: BASE is never produced (any use of a usize as migrated data will +// always result in a compile-time error). VARRAY_FLAG only tells the C co= de to +// read `size_of::()` bytes (see `size_of_field_type!`) at the leng= th's +// offset. +unsafe impl VMState for usize { + #[doc(hidden)] // https://github.com/rust-lang/rust/issues/149635 + const BASE: VMStateField =3D { + panic!("usize cannot be migrated, use a fixed-size integer type"); + }; + const VARRAY_FLAG: VMStateFlags =3D VMStateFlags::VMS_VARRAY; +} + #[macro_export] macro_rules! impl_vmstate_c_struct { ($type:ty, $vmsd:expr) =3D> { diff --git a/rust/tests/tests/vmstate_tests.rs b/rust/tests/tests/vmstate_t= ests.rs index 6578d54b37..b680cfd3c7 100644 --- a/rust/tests/tests/vmstate_tests.rs +++ b/rust/tests/tests/vmstate_tests.rs @@ -483,3 +483,52 @@ fn test_vmstate_validate() { // The last VMStateField in VMSTATE_FOOD. assert_eq!(foo_fields[3].flags, VMStateFlags::VMS_END); } + +// =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D Test VMSTATE_FOOE =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +// Test the use cases of the vmstate macro, corresponding to the following= C +// macro variants: +// * VMSTATE_FOOE: +// - VMSTATE_VARRAY with a `usize` length +#[repr(C)] +#[derive(Default)] +struct FooE { + arr: [u8; FOO_ARRAY_MAX], + num: usize, +} + +static VMSTATE_FOOE: VMStateDescription =3D VMStateDescriptionBuilde= r::::new() + .name(c"foo_e") + .version_id(1) + .minimum_version_id(1) + .fields(vmstate_fields! { + vmstate_of!(FooE, arr[0 .. num]), + }) + .build(); + +#[test] +fn test_vmstate_varray_usize() { + let foo_fields: &[VMStateField] =3D + unsafe { slice::from_raw_parts(VMSTATE_FOOE.as_ref().fields, 2) }; + + // 1st VMStateField ("arr") in VMSTATE_FOOE + assert_eq!( + unsafe { CStr::from_ptr(foo_fields[0].name) }.to_bytes_with_nul(), + b"arr\0" + ); + assert_eq!(foo_fields[0].offset, 0); + assert_eq!( + foo_fields[0].num_indirect.offset, + std::mem::offset_of!(FooE, num) as u32 + ); + assert_eq!(foo_fields[0].num_indirect.size, size_of::() as u8); + assert_eq!(foo_fields[0].info, unsafe { &vmstate_info_uint8 }); + assert_eq!(foo_fields[0].version_id, 0); + assert_eq!(foo_fields[0].size, 1); + assert_eq!(foo_fields[0].num, 0); + assert_eq!(foo_fields[0].flags, VMStateFlags::VMS_VARRAY); + assert!(foo_fields[0].vmsd.is_null()); + assert!(foo_fields[0].field_exists.is_none()); + + // The last VMStateField in VMSTATE_FOOE. + assert_eq!(foo_fields[1].flags, VMStateFlags::VMS_END); +} --=20 2.56.0 From nobody Sun Nov 29 02:11:45 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1795735042; cv=none; d=zohomail.com; s=zohoarc; b=ZFB3zWoS5+3dUqU7xEHLnW27Rkj0Dw8KdORiB6y02awYw2IVqxYZtzqxRVyV4kcizYLkPFRQbxCjw/GP55KCJpGYWSBQ8wf3U5vbECz1z8PxTpOPCOluFIXqWw7hm3+vC8ArNR8a42evh3FDtaTajuvv1MIexJXQvu34+hRDGAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795735042; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=l1Qg3LQ3LO7V7dxn17KNCAY8BfJNlf4502KPIAbTvd4=; b=Lz2k8VXvuAfIgHiFO/h+/0ZwgaGVBx0LDuDJNnkEq4XgGUJpV+d1CVTTtR6ySe8GduR028mX+VL88dsaRtTdhT1/Ss6xa6Zv9m2TtNDB+BrXmgcO9WMtOAeR8rDPRZI/MFTKzLZlsx4z6ZpCGnO/cdNdoHh08FBlLBmh02vtA9Q= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795735042464217.12568426886492; Thu, 26 Nov 2026 15:17:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xWihq-00085g-J2; Thu, 26 Nov 2026 18:16:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihn-00083b-IB for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihl-00061O-DR for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:43 -0500 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-387-C4OLeRhyM0WRE2IEJQpZ3w-1; Thu, 26 Nov 2026 23:16:38 +0000 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-9213e04641dso144971926d6.2 for ; Thu, 26 Nov 2026 15:16:38 -0800 (PST) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-92134a08552sm199552756d6.34.2026.11.26.15.16.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 15:16:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795735000; 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=l1Qg3LQ3LO7V7dxn17KNCAY8BfJNlf4502KPIAbTvd4=; b=HgwuYpAfHP2YcA72qrIOHa8lz4aJ0BKIQniCRDPoQvS+OknRaEeZTVqBFzOAs8ttnFUVWd qTi0k+LbFmpDxx8zN5GiHPllAGNDfLBYGbqwXLVpYvDfIdKCScvjopx1Ud/l+bC298ELhk JC2uH108pIRJPFFRiUt/rZfzE9JnPNs= X-MC-Unique: C4OLeRhyM0WRE2IEJQpZ3w-1 X-Mimecast-MFC-AGG-ID: C4OLeRhyM0WRE2IEJQpZ3w_1795734998 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1795734998; x=1796339798; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=l1Qg3LQ3LO7V7dxn17KNCAY8BfJNlf4502KPIAbTvd4=; b=Ztk+BIj8K0G1Glog0vP78jBZVYk3U0Xhoq0jH5A9RteADv//TeT0RgE1+Siyrd5jDB BhUWqXCYQ7mLx0lEdwDgxrw0xvPev1ONgYmXxcLOiDRTMqAydgRla0LGmfZbNke1Pqqm dHqAZfHZXyGgMrj/6o6UJSnwIreA0LJiKcNFOtCKgTZGVM/i8kyEiiwJoDsnTAjuPEPa X5jD/8ceyJpVne5ECEOf/CbMHiXLrTdsIdWnRKpthG2tg0l3IE/2aArBYqsekDyKKfxH lCX76NfV4f433NnqVPwiUiXyT5B/lsRToYA4xl/CmlqaGaUDyp62rmH6jLejygxZhJE5 YHzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795734998; x=1796339798; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=l1Qg3LQ3LO7V7dxn17KNCAY8BfJNlf4502KPIAbTvd4=; b=fwuPA7o6g9Ndy6P2KKZz6fsITbW9NvA6MJDzMQDRYbWOYdRzQP/L6njtrgy9AamyAl 29gTn5Hlyay1f6uEfJCKE1RAPgelFqjKYObp86Q+47Tx5b8t6U5o75k8TdhPO2y6etUb uYyw1RL2Mxr9HTEBYltjzcnMoCVR0wrcYr5kCyGxqKcbPLLkZdI1eNW0Cb/tjV4cd+PP BjxcQ20j+XNPw9/0QJIQCIlOc3qYP/DGIMuXpPEwOwE5JrAiWa4IwiQQ+v4rQOEs6QRc XhphYtqEbJGntMTaOHe7pvK1qALWFHo/qnD4hPAizteFPcWoTrY4ilOMYgANgsyWvNNI ZlEQ== X-Gm-Message-State: APuU4Z+5r9iOnMTZPi7gNNVTjHWaTCIl+ZlMjHal14ieH/ex2WRekR/U gaztuFHX1p/spxDke1uaNzRwWUcvSDygOQmTie/HRgv+x+lHVCrJgsgV8mOrJPx8kkObne8fxix 4kOuW87MigtXGkh67QwSwSD6bDeM2nrC+8J0yxol8U69LDaufUghIUMtFDnfcQCIdN4jJDJ6elE VQMN+43BblGJSIZhZK9DQ2KTtn2ZmwPczxyldjdg== X-Gm-Gg: AZFdTZetkNOxNXVAsxgrWE5azqPccbJTeEO2MaNDW8C90khuoIW/JoakhjgmG0BPWnA J8GarbyoCzvOOrn4RxJoB2Z2FRCKwD2tS4gtK12KHJi4iyi7d9BeBPvQKOpUiy3oKovAW8pTuHI TLY6eTPTnDZptEerli+0P5xukS+Ug7AkFbd3ob2SjoyJENybGMFd5FwUs182SqFzHuSYkuvsLNq 3Lu4uacv2fau/EVlX2qGpP3GHJLo9xpRHjOzFp1rfV6POCGSBvQvw9pO3+1JjNDnznRhQf8mZJi cOOUIQrbjMreKWtHAThUv98deHDm4IdkfmzOKLG7Bg+uPxgENfVGkgwS910QAUbBReDaC50sfnv OnI0BJy18TdqeoKPIOiuihIznDJf7ikI52vjIkkNKT98b X-Received: by 2002:ac8:574e:0:b0:535:8519:6ebb with SMTP id d75a77b69052e-55d769316e0mr434382461cf.4.1795734997737; Thu, 26 Nov 2026 15:16:37 -0800 (PST) X-Received: by 2002:ac8:574e:0:b0:535:8519:6ebb with SMTP id d75a77b69052e-55d769316e0mr434381901cf.4.1795734997093; Thu, 26 Nov 2026 15:16:37 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , Peter Maydell , peterx@redhat.com, Fabiano Rosas , Gavin Shan , Zhao Liu Subject: [PATCH for-12.0 v2 2/9] rust/hpet: Move vmstate_validate!() check into post_load Date: Thu, 26 Nov 2026 18:16:24 -0500 Message-ID: <20261126231631.3392756-3-peterx@redhat.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261126231631.3392756-1-peterx@redhat.com> References: <20261126231631.3392756-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: 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 @redhat.com) X-ZM-MESSAGEID: 1795735044395158500 Content-Type: text/plain; charset="utf-8" From: Zhao Liu To pave way for removing VMSTATE_VALIDATE() (and vmstate_validate!()), move the usage of hpet into post_load. To make it safer, loading the timers with the num_timers, then only check against the wire number at last. In addition, drop the test_fn() in the VMStateField of HPETState.timers - this was duplicated, but now the check in post_load is enough (and test_fn should not be used for validation). Originally-by: Peter Xu Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20261124095814.437738-3-zhao1.liu@intel.com Signed-off-by: Peter Xu --- rust/hw/timer/hpet/src/device.rs | 45 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/rust/hw/timer/hpet/src/device.rs b/rust/hw/timer/hpet/src/devi= ce.rs index 89ba7a5c4d..c7a2b7f6c2 100644 --- a/rust/hw/timer/hpet/src/device.rs +++ b/rust/hw/timer/hpet/src/device.rs @@ -934,10 +934,15 @@ fn pre_save(&self) -> Result<(), migration::Infallibl= e> { Ok(()) } =20 - fn post_load(&self, _version_id: u8) -> Result<(), migration::Infallib= le> { + fn post_load(&self, _version_id: u8) -> Result<(), migration::InvalidE= rror> { let mut regs =3D self.regs.borrow_mut(); let cnt =3D regs.counter; =20 + /* FIXME: use post_load_errp() to print error message. */ + if !self.validate_num_timers() { + return Err(migration::InvalidError); + } + for tn_regs in regs.tn_regs.iter_mut().take(self.num_timers) { tn_regs.update_cmp64(cnt); tn_regs.last =3D CLOCK_VIRTUAL.get_ns() - NANOSECONDS_PER_SECO= ND; @@ -956,7 +961,7 @@ fn is_offset_needed(&self) -> bool { self.regs.borrow().is_hpet_enabled() } =20 - fn validate_num_timers(&self, _version_id: u8) -> bool { + fn validate_num_timers(&self) -> bool { self.num_timers =3D=3D self.num_timers_save.get().into() } } @@ -1082,8 +1087,6 @@ fn restore_migrated_state( =20 impl_vmstate_struct!(HPETTimerMigration, VMSTATE_HPET_TIMER); =20 -const VALIDATE_TIMERS_NAME: &CStr =3D c"num_timers must match"; - // HPETRegistersMigration is generated by ToMigrationState macro. impl_vmstate_struct!( HPETRegistersMigration, @@ -1099,24 +1102,22 @@ fn restore_migrated_state( .build() ); =20 -const VMSTATE_HPET: VMStateDescription =3D - VMStateDescriptionBuilder::::new() - .name(c"hpet") - .version_id(2) - .minimum_version_id(2) - .pre_save(&HPETState::pre_save) - .post_load(&HPETState::post_load) - .fields(vmstate_fields! { - vmstate_of!(HPETState, regs), - vmstate_of!(HPETState, num_timers_save), - vmstate_validate!(HPETState, VALIDATE_TIMERS_NAME, HPETState::= validate_num_timers), - vmstate_of!(HPETState, timers[0 .. num_timers_save], HPETState= ::validate_num_timers).with_version_id(0), - }) - .subsections(vmstate_subsections!( - VMSTATE_HPET_RTC_IRQ_LEVEL, - VMSTATE_HPET_OFFSET, - )) - .build(); +const VMSTATE_HPET: VMStateDescription =3D VMStateDescriptionBu= ilder::::new() + .name(c"hpet") + .version_id(2) + .minimum_version_id(2) + .pre_save(&HPETState::pre_save) + .post_load(&HPETState::post_load) + .fields(vmstate_fields! { + vmstate_of!(HPETState, regs), + vmstate_of!(HPETState, num_timers_save), + vmstate_of!(HPETState, timers[0 .. num_timers]).with_version_id(0), + }) + .subsections(vmstate_subsections!( + VMSTATE_HPET_RTC_IRQ_LEVEL, + VMSTATE_HPET_OFFSET, + )) + .build(); =20 impl DeviceImpl for HPETState { const VMSTATE: Option> =3D Some(VMSTATE_HPET); --=20 2.56.0 From nobody Sun Nov 29 02:11:45 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1795735104; cv=none; d=zohomail.com; s=zohoarc; b=eaXIpeXcoRAluGKbAwlWlYS2jO6Y3Hlt/oliA0pqzojvfw06zLw4p5SkMh5jWAoGhx3Kp1zxXatdK7YB/vPP0xKVNxZTDTBefg0coRPO8ECDr2e47qhJ0kDMT7ceFfVL6nmNNj45YSROyVQo2ndjjh9WeeKPPIqLG9tqr3e/iuI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795735104; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sJvie1o+hdDvsHvqpC1jKetF2TiTISIEGLTx8zoN3dU=; b=IY5jpfXE1mzd8Pur1c2x5q24sdfaEiPYajQZRqSSB6EnLh0nMisrpp8I0tGapPotOV6RQJMV6sEcVyja7W2b0j2p1aE1HPRR8jIWu3obMkPk5g/uDQzx5XMcwXVHaDL3ZkJkTUxWWumq0RDE7hR0ZtyHlOmO+4eHCxdN/W6VWMM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795735104597396.79749338539943; Thu, 26 Nov 2026 15:18:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xWiht-00087Q-Ns; Thu, 26 Nov 2026 18:16:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihp-00085h-PF for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihn-00061x-Oq for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:45 -0500 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-437-m9GeVHMpMIipTrg95OFdhQ-1; Thu, 26 Nov 2026 23:16:40 +0000 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-55d2c49c3d9so98441371cf.3 for ; Thu, 26 Nov 2026 15:16:40 -0800 (PST) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-55dcdd1a2c6sm4502181cf.20.2026.11.26.15.16.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 15:16:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795735003; 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=sJvie1o+hdDvsHvqpC1jKetF2TiTISIEGLTx8zoN3dU=; b=AAWiKwdeDN+etxZ500bU8MLmjenV4OJVP4BwKNkrRXlijqGE9ivTH74GgjTR+0aBGJrRao VoI5IHYONGKDiwoG47nmM8i9aJyDJNM49MV0cfuGRSlwcV64gsOuPCdqwpuf/aLrPCCknf 0qsl6zvfnUFMLpMCmHJ/A+L7Z9X1XCM= X-MC-Unique: m9GeVHMpMIipTrg95OFdhQ-1 X-Mimecast-MFC-AGG-ID: m9GeVHMpMIipTrg95OFdhQ_1795735000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1795735000; x=1796339800; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=sJvie1o+hdDvsHvqpC1jKetF2TiTISIEGLTx8zoN3dU=; b=XxMUi5YKvPEyFUfNGaCOrvELheN8rxWmG+PwQHMhrqF5XLC1BRPokBg2QCQWhYHVhR J4Dmc/whvmd517deay/RNzDgfM7w47sO1aTxfksnuvqRgQXbYf1sVvxJ2u9L6bZqTBlA U1s28JyNRwHDpcFaoM9EuJYFPqF/7R38v97/pFqiDFMshbBQKbacJ37UP+vwlYAelS6f OIdqrEjxAzqljgQlWaTIYYGXkiHx1qNOtUgAToK8WHgptGSPj1VR84K5BrZXYyquYfdf P+WIiijmOryv2wBeMPncoyqOWG4HAWMCz3JQ580ORK0yfdqbMC7NuYssRTKufEhB5bsO Sm7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795735000; x=1796339800; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=sJvie1o+hdDvsHvqpC1jKetF2TiTISIEGLTx8zoN3dU=; b=viC+KqnZjdHb/rPcnixtHSAcCTvsoKj+oGxHgkzVIXRb0jsGUJhKAVmYieOw/9Nqib 5FLWhOOxeHqd02OJBGaUGruElzurPoDqi3zYw74o5lRw1gk0JwsFTrwTEyqynr8V7uFv w6CXtgBdCS8jI800K82BxRjTD6dzEERl+wVzibFl0KCJqCl128FmLf/DpFNRX3BBBK5n dgIipcEYsEjIv5s5R9N54JFBywNeuE+cRqtyw7HxMMOhEb5kJW/L4tpTwDfwlEUswt9I 07/Oo4Jlmxv9y8oRY5FN8b8q3YAaf7iY5KkCUV1/yRyOtpnrn9RVE7vsX6YZCwoBA8bl vuTQ== X-Gm-Message-State: APuU4Z/iNbA2LD4IyReJj23GDH6LZLQfGRqRu8YvMOZwM1C7MUwWimc7 NPgHt6hB/1JjUgUG4XEBbPIYdQKgs67odSs+voI0wVuw/TU4kyyjsXvV4pM5vyPe8QaXRqwHlWd NC90wpylV1DNr5hBYfXPhvR6qd4Aqr5haw02ElEIshCI/MUjoHvF3T/wzl2trGIrYp8I4BAYLz3 nmbXeljT9db0niE+hRuUDXFh08lWAj/CU5irzAUw== X-Gm-Gg: AZFdTZfZIv0DTvc4Xj5FsblRgWJMQDR8+rzPkY7FhXuMN1RAI64+1QOzp1XpoLyatLJ fmGJpI3zNwy+0o7BS5S/jigNXhnaUtdIQY9aBtn0b8ObHihMIByfhEZIyXKAsyOgOqOUJ88Uqdy fmbxg4nuD06UueJZkaHU5ju78OBFj1T2ObtBDcY3p5a44KuiRfY0g5XlJQaghdcYA4C6J/jKyw4 fjURxzcNHI6Wdc+x+vpau290CB7BvNrTYl/C4x/nG8pLJ2NTnYbXq/+tppZDVIIa1dLC0wjyls1 sz/A4ABxheufUOmQQpViNtsJmJQNIQnAQwTiekNzuzmyNByLnQ6zFwhT9RVKMF8FWqrPm2oCoAM bVeNYk08kph0aiKb4jEBG4ti97VnH9U4O4UVgGU1OlM8A X-Received: by 2002:a05:622a:248c:b0:55d:3350:d270 with SMTP id d75a77b69052e-55d769f5705mr453489231cf.35.1795735000110; Thu, 26 Nov 2026 15:16:40 -0800 (PST) X-Received: by 2002:a05:622a:248c:b0:55d:3350:d270 with SMTP id d75a77b69052e-55d769f5705mr453488431cf.35.1795734999400; Thu, 26 Nov 2026 15:16:39 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , Peter Maydell , peterx@redhat.com, Fabiano Rosas , Gavin Shan , Zhao Liu Subject: [PATCH for-12.0 v2 3/9] rust/migration: Remove vmstate_validate!() macro and test Date: Thu, 26 Nov 2026 18:16:25 -0500 Message-ID: <20261126231631.3392756-4-peterx@redhat.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261126231631.3392756-1-peterx@redhat.com> References: <20261126231631.3392756-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: 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 @redhat.com) X-ZM-MESSAGEID: 1795735106729158500 Content-Type: text/plain; charset="utf-8" From: Zhao Liu We have moved all users (in Rust side) to other API, now they're never used. After the related test (originally FOOD) was removed, rename FOOE to new FOOD test. Suggested-by: Peter Xu Signed-off-by: Zhao Liu Link: https://lore.kernel.org/r/20261124095814.437738-4-zhao1.liu@intel.com Signed-off-by: Peter Xu --- rust/migration/src/prelude.rs | 1 - rust/migration/src/vmstate.rs | 17 ------ rust/tests/tests/vmstate_tests.rs | 93 +++---------------------------- 3 files changed, 8 insertions(+), 103 deletions(-) diff --git a/rust/migration/src/prelude.rs b/rust/migration/src/prelude.rs index 797e7ec59d..e2cbbda43e 100644 --- a/rust/migration/src/prelude.rs +++ b/rust/migration/src/prelude.rs @@ -16,4 +16,3 @@ pub use crate::vmstate_of; pub use crate::vmstate_subsections; pub use crate::vmstate_unused; -pub use crate::vmstate_validate; diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index 0b05db4e70..ec8b712cbf 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -384,23 +384,6 @@ macro_rules! vmstate_fields { }} } =20 -#[doc(alias =3D "VMSTATE_VALIDATE")] -#[macro_export] -macro_rules! vmstate_validate { - ($struct_name:ty, $test_name:expr, $test_fn:expr $(,)?) =3D> { - $crate::bindings::VMStateField { - name: ::std::ffi::CStr::as_ptr($test_name), - field_exists: $crate::vmstate_exist_fn!($struct_name, $test_fn= ), - flags: $crate::bindings::VMStateFlags( - $crate::bindings::VMStateFlags::VMS_MUST_EXIST.0 - | $crate::bindings::VMStateFlags::VMS_NO_STATE.0, - ), - num: 0, // 0 elements: no data, only run test_fn callback - ..::common::zeroable::Zeroable::ZERO - } - }; -} - /// Helper macro to allow using a struct in [`vmstate_of!`] /// /// # Safety diff --git a/rust/tests/tests/vmstate_tests.rs b/rust/tests/tests/vmstate_t= ests.rs index b680cfd3c7..9dbbb848b8 100644 --- a/rust/tests/tests/vmstate_tests.rs +++ b/rust/tests/tests/vmstate_tests.rs @@ -411,106 +411,29 @@ fn test_vmstate_macro_array_of_pointer_wrapped() { // Test the use cases of the vmstate macro, corresponding to the following= C // macro variants: // * VMSTATE_FOOD: -// - VMSTATE_VALIDATE - -// Add more member fields when vmstate_of support "test" parameter. -struct FooD; - -impl FooD { - fn validate_food_0(&self, _version_id: u8) -> bool { - true - } - - fn validate_food_1(_state: &FooD, _version_id: u8) -> bool { - false - } -} - -fn validate_food_2(_state: &FooD, _version_id: u8) -> bool { - true -} - -static VMSTATE_FOOD: VMStateDescription =3D VMStateDescriptionBuilde= r::::new() - .name(c"foo_d") - .version_id(3) - .minimum_version_id(1) - .fields(vmstate_fields! { - vmstate_validate!(FooD, c"foo_d_0", FooD::validate_food_0), - vmstate_validate!(FooD, c"foo_d_1", FooD::validate_food_1), - vmstate_validate!(FooD, c"foo_d_2", validate_food_2), - }) - .build(); - -#[test] -fn test_vmstate_validate() { - let foo_fields: &[VMStateField] =3D - unsafe { slice::from_raw_parts(VMSTATE_FOOD.as_ref().fields, 4) }; - let mut foo_d =3D FooD; - let foo_d_p =3D std::ptr::addr_of_mut!(foo_d).cast::(); - - // 1st VMStateField in VMSTATE_FOOD - assert_eq!( - unsafe { CStr::from_ptr(foo_fields[0].name) }.to_bytes_with_nul(), - b"foo_d_0\0" - ); - assert_eq!(foo_fields[0].offset, 0); - assert_eq!(foo_fields[0].num_indirect.size, 0); - assert!(foo_fields[0].info.is_null()); - assert_eq!(foo_fields[0].version_id, 0); - assert_eq!(foo_fields[0].size, 0); - assert_eq!(foo_fields[0].num, 0); - assert_eq!( - foo_fields[0].flags.0, - VMStateFlags::VMS_NO_STATE.0 | VMStateFlags::VMS_MUST_EXIST.0 - ); - assert!(foo_fields[0].vmsd.is_null()); - assert!(unsafe { foo_fields[0].field_exists.unwrap()(foo_d_p, 0) }); - - // 2nd VMStateField in VMSTATE_FOOD - assert_eq!( - unsafe { CStr::from_ptr(foo_fields[1].name) }.to_bytes_with_nul(), - b"foo_d_1\0" - ); - assert!(!unsafe { foo_fields[1].field_exists.unwrap()(foo_d_p, 1) }); - - // 3rd VMStateField in VMSTATE_FOOD - assert_eq!( - unsafe { CStr::from_ptr(foo_fields[2].name) }.to_bytes_with_nul(), - b"foo_d_2\0" - ); - assert!(unsafe { foo_fields[2].field_exists.unwrap()(foo_d_p, 2) }); - - // The last VMStateField in VMSTATE_FOOD. - assert_eq!(foo_fields[3].flags, VMStateFlags::VMS_END); -} - -// =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D Test VMSTATE_FOOE =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -// Test the use cases of the vmstate macro, corresponding to the following= C -// macro variants: -// * VMSTATE_FOOE: // - VMSTATE_VARRAY with a `usize` length #[repr(C)] #[derive(Default)] -struct FooE { +struct FooD { arr: [u8; FOO_ARRAY_MAX], num: usize, } =20 -static VMSTATE_FOOE: VMStateDescription =3D VMStateDescriptionBuilde= r::::new() - .name(c"foo_e") +static VMSTATE_FOOD: VMStateDescription =3D VMStateDescriptionBuilde= r::::new() + .name(c"foo_d") .version_id(1) .minimum_version_id(1) .fields(vmstate_fields! { - vmstate_of!(FooE, arr[0 .. num]), + vmstate_of!(FooD, arr[0 .. num]), }) .build(); =20 #[test] fn test_vmstate_varray_usize() { let foo_fields: &[VMStateField] =3D - unsafe { slice::from_raw_parts(VMSTATE_FOOE.as_ref().fields, 2) }; + unsafe { slice::from_raw_parts(VMSTATE_FOOD.as_ref().fields, 2) }; =20 - // 1st VMStateField ("arr") in VMSTATE_FOOE + // 1st VMStateField ("arr") in VMSTATE_FOOD assert_eq!( unsafe { CStr::from_ptr(foo_fields[0].name) }.to_bytes_with_nul(), b"arr\0" @@ -518,7 +441,7 @@ fn test_vmstate_varray_usize() { assert_eq!(foo_fields[0].offset, 0); assert_eq!( foo_fields[0].num_indirect.offset, - std::mem::offset_of!(FooE, num) as u32 + std::mem::offset_of!(FooD, num) as u32 ); assert_eq!(foo_fields[0].num_indirect.size, size_of::() as u8); assert_eq!(foo_fields[0].info, unsafe { &vmstate_info_uint8 }); @@ -529,6 +452,6 @@ fn test_vmstate_varray_usize() { assert!(foo_fields[0].vmsd.is_null()); assert!(foo_fields[0].field_exists.is_none()); =20 - // The last VMStateField in VMSTATE_FOOE. + // The last VMStateField in VMSTATE_FOOD. assert_eq!(foo_fields[1].flags, VMStateFlags::VMS_END); } --=20 2.56.0 From nobody Sun Nov 29 02:11:45 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1795735063; cv=none; d=zohomail.com; s=zohoarc; b=CrntqefX63PgpDeLn04D1R13XVhjwW6R9vk1erphUZMpmJrgWjGOIaHC7FR48LxLS3EhOXJm0+KIcJ+P3xEMSodxekYltrhnHhue1Z/kDgQEgkgK3+12UK8UUtvta6NdG7/jfqPBP3lF7/JSUtQpHr8pJPnBtyu+ANIj3NPs3fY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795735063; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TPBdbWhRH+ndA7WfjTIrEZ1e2jC4NB4OMmjiegGEePI=; b=NoWIKtHEQUcgiyyIhceuXN7xWjIGwLgBDEx6ydR6D4y9ATsRFY9xPdicgB3yzWbOUD2fQ2MINTGoRqcKCBDCoGcaBooh3RD82TuEk3lDt4sXQAimF/D1Up95O/gg+UJ1kphgoxW+NPsgGKvps2seEtZdh0UOLlEh7DyIlHe0XmA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795735063378972.2816728734222; Thu, 26 Nov 2026 15:17:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xWii0-0008DN-Mq; Thu, 26 Nov 2026 18:16:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihs-00086g-Qk for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:48 -0500 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 1xWihr-00062f-5G for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:48 -0500 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-tufI0Z05ObyfgbcOcYxfng-1; Thu, 26 Nov 2026 23:16:42 +0000 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-544019b1831so146436461cf.0 for ; Thu, 26 Nov 2026 15:16:42 -0800 (PST) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id af79cd13be357-94a0c18267esm431130785a.4.2026.11.26.15.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 15:16:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795735006; 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=TPBdbWhRH+ndA7WfjTIrEZ1e2jC4NB4OMmjiegGEePI=; b=OX7shb2vno5Vk1ZRXiG4v1r2UfX/uInf16vE1lSAWVErOpwvVWbCWgnGtLMZfvp16zjsmD rSvbYjLYDpdvhi2LfBrwGIjbH13ejhObeXgv+Pmnx99v4pcBrJOCO8qtXwwklOfBIZBf6A GR9R1uqSpzKul9VBPLI5e78RPD5Ezpg= X-MC-Unique: tufI0Z05ObyfgbcOcYxfng-1 X-Mimecast-MFC-AGG-ID: tufI0Z05ObyfgbcOcYxfng_1795735002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1795735002; x=1796339802; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TPBdbWhRH+ndA7WfjTIrEZ1e2jC4NB4OMmjiegGEePI=; b=VFQaqjPz/i58IrimKy4RHh9FIoxCy7ZB9tGByvZ69asEY2cj8GZJzdBKxRfGnvFg+l 0bG79cOjUE5tyzJHd32Mw6iNSiSaYDRbzCrnXSuNnEoYJP0AUpFzQH6RlZ88QbO0rx1d vmA7/vng7MGR7CaX1KNszKFv+iE09Mlvq0lxvLvSajcbtUAawQueE4XWfEm4iZGjcZ/5 rw7szVpDfQQ66g06n3BJnKaTWye0xzobeFfDnAD7wQv3QozFhcHEpIVfkxsFEIfoyO74 vv3h7yzvZ5tpOw3cbsTYnZ7nZ5kA7N1zMUzmgxZ2Wx9Z3e9be/VI4RyH07udHHWs10Ey D6Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795735002; x=1796339802; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=TPBdbWhRH+ndA7WfjTIrEZ1e2jC4NB4OMmjiegGEePI=; b=KPtVGsL8Dm7gu/NT5pnvhrGYgahHdHfHYiKVfE87/3fOC7eXTD7RcKUlw/YA0Xf70w 3t+O1vuArziIv4kB0VWkweTO7y5COyNd5jQWoGWCTiriU7HWimQ3KtfkpqO2CZ33duk7 3Fa/7Sfcia5Wu5r8hmZh+GXW5s7u0DO6zTZIhMs18HcVkz5c58lQyQPnQ9yeNG1ocSEo 2pqt4TLO5PDFlhV1GluZrrcirxMVxohGZh85gq5y2N0PoHbWeucROJX1ZXGaWUj45E/z RwgcAPPwlQXkpHnjJXwoFsyPoZdiXjELDv0/2b0bnqB11vFrbLr6LL04PYbGrzKkZaYz RpAg== X-Gm-Message-State: APuU4Z9OrdyAYr4hApl/+5SFrfYN4QwW7nCmmrmsYSNpc1dBDTwG5jgz q0lwhwTG1LVgEBMK5BbJlueVLjqSMDuJHlMMszQlJgMjpW5yaQB9j9++DehWkhKflCxJyu8bkv5 XSiCxYVXigq1tW4Dxk9oG+FdpTIcJQd3AUrYc9rAiWGajplJMfIVklAAYPtK1t514xYbW6WA41l +WXM2wFJoQiFILEXzIcsvZqn7zYTXS8oKMg56/mQ== X-Gm-Gg: AZFdTZeTb4FHBoD9TUMnmZHHzXdGfM/I05SPWiv6DScTpKay4iAbnMk1tVbqNKMcV7B TMxJ+D3maQsOu5uCECi+DPuLh1eKlqU3Uy+kRxlgfrH7q01qqdbCvky/C2tKAeADI0dGymQOeeo OuL5KAiCsXomawpGaXyI0VivZvXQzFcCI8hxjBSCjpGfqzDoK2UHMXBXH7fzQsvvuTn5iQvDPWy E16RARh0Sfio3yb5MTOu480UbwUxDIjgkEhHXpUB40IzO0GnpUPr4JbJabTWm83AxyjqzaltY7r JbnPsMmkNsj4WOJAAVzxYf5lXTihkE+D0Dj6G2OmWaxCOg9WBVquV4ACk1EknUEaZ28mf2UQ9pk QpMu2sNlvWLE90zvtCabX8cF5srJIAUG3JoSgaiomxLmg X-Received: by 2002:a05:620a:45a4:b0:944:110b:d824 with SMTP id af79cd13be357-949ba8237f7mr4170134885a.5.1795735001928; Thu, 26 Nov 2026 15:16:41 -0800 (PST) X-Received: by 2002:a05:620a:45a4:b0:944:110b:d824 with SMTP id af79cd13be357-949ba8237f7mr4170127785a.5.1795735001111; Thu, 26 Nov 2026 15:16:41 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , Peter Maydell , peterx@redhat.com, Fabiano Rosas , Gavin Shan , "Michael S. Tsirkin" Subject: [PATCH for-12.0 v2 4/9] pcie/aer: Remove the usage of VMSTATE_VALIDATE() Date: Thu, 26 Nov 2026 18:16:26 -0500 Message-ID: <20261126231631.3392756-5-peterx@redhat.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261126231631.3392756-1-peterx@redhat.com> References: <20261126231631.3392756-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: 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 @redhat.com) X-ZM-MESSAGEID: 1795735064432158500 Content-Type: text/plain; charset="utf-8" Paving way removing it. We can replace it with a post_load_errp() instead. Tested with migration with "-device ioh3420,id=3Drp0" against pre-patch, which means migration compatibility is unaffected. Cc: "Michael S. Tsirkin" Signed-off-by: Peter Xu --- hw/pci/pcie_aer.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c index 43b14c1f22..87248556d4 100644 --- a/hw/pci/pcie_aer.c +++ b/hw/pci/pcie_aer.c @@ -807,21 +807,51 @@ static const VMStateDescription vmstate_pcie_aer_err = =3D { } }; =20 -static bool pcie_aer_state_log_num_valid(void *opaque, int version_id) -{ - PCIEAERLog *s =3D opaque; +typedef struct { + uint16_t v; +} tmp_u16; =20 +static bool pcie_aer_state_log_num_valid(PCIEAERLog *s) +{ return s->log_num <=3D s->log_max; } =20 +static bool pcie_aer_state_log_num_post_load(void *opaque, int version, + Error **errp) +{ + PCIEAERLog *s =3D container_of(opaque, PCIEAERLog, log_num); + + if (!pcie_aer_state_log_num_valid(s)) { + error_setg(errp, "PCIe AER log num too big: log_num > log_max"); + return false; + } + + return true; +} + +static const VMStateDescription vmstate_pcie_aer_log_num =3D { + .name =3D "PCIE_AER_ERROR_LOG/NUM", + .version_id =3D 1, + .minimum_version_id =3D 1, + .post_load_errp =3D pcie_aer_state_log_num_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT16(v, tmp_u16), + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_pcie_aer_log =3D { .name =3D "PCIE_AER_ERROR_LOG", .version_id =3D 1, .minimum_version_id =3D 1, .fields =3D (const VMStateField[]) { - VMSTATE_UINT16(log_num, PCIEAERLog), + /* + * Only to use STRUCT for a post_load_errp(). New code should try + * to use something look better, e.g. subsections in order. + */ + VMSTATE_STRUCT(log_num, PCIEAERLog, 1, + vmstate_pcie_aer_log_num, uint16_t), VMSTATE_UINT16_EQUAL(log_max, PCIEAERLog), - VMSTATE_VALIDATE("log_num <=3D log_max", pcie_aer_state_log_num_va= lid), VMSTATE_STRUCT_VARRAY_POINTER_UINT16(log, PCIEAERLog, log_num, vmstate_pcie_aer_err, PCIEAERErr), VMSTATE_END_OF_LIST() --=20 2.56.0 From nobody Sun Nov 29 02:11:45 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1795735096; cv=none; d=zohomail.com; s=zohoarc; b=Q4GTns0XJe5vwdKj3ZGVBKQKi5eprV8A0dMtTgSIvbOFA7ho5571dxK3HS11bAl+sQ/nRsuhlqB+mZjii30efX4t+7bAZ0D2m8RpIHCbFYzonaGwJ5OOrffE195NZYLZrtzz+vOjarT/JaeO0xBwQLVp6gycPYhYlij4CN/ECug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795735096; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5msL5Y3whH1wyPAcimr4/6A5hkAEK5pqKOOOJceBdzM=; b=WB+/+RVhClRYJOv3wds2HcK6++XoMmaXqrcoCcY5cuYmEcUEcZuY3UlgQuaGNrAEZ3ie36PWK9RqXqwvVOSn/dWbgy9k35AeOk9cwemEK6LOrAr7lp2m4wgIHMK5aEkK7d/HljkQOMX/u9PSUtqN9r7L7/4cAvEdKQSDqkgUGd8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795735095998233.891916013451; Thu, 26 Nov 2026 15:18:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xWii1-0008DO-3R; Thu, 26 Nov 2026 18:16:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihu-00087Z-0a for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:50 -0500 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 1xWihr-00062c-9q for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:49 -0500 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-nLK-QanwPKeoj5QG92JTAQ-1; Thu, 26 Nov 2026 23:16:43 +0000 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-94960bd17b5so1172210985a.0 for ; Thu, 26 Nov 2026 15:16:43 -0800 (PST) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id af79cd13be357-949bb3a646fsm1697088985a.22.2026.11.26.15.16.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 15:16:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795735006; 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=5msL5Y3whH1wyPAcimr4/6A5hkAEK5pqKOOOJceBdzM=; b=HUDM7B9slrzDC4Fy6fRGdSbksPF9Q7/kuj/gDdMb2zNWBm7XA6hsl/ehmQ8v5JnBJLeBf9 P+qUg4ofQWEwKLgDh56JXrsuithQrS2LinVL284JHM1jJyp5SLi2iRTBwGvuIkGBkEkUyW qkAY+tLdRhzsZ1rJ1NImgCN30A1ATJ8= X-MC-Unique: nLK-QanwPKeoj5QG92JTAQ-1 X-Mimecast-MFC-AGG-ID: nLK-QanwPKeoj5QG92JTAQ_1795735003 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1795735003; x=1796339803; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=5msL5Y3whH1wyPAcimr4/6A5hkAEK5pqKOOOJceBdzM=; b=EzRlySgEDQ6uewkJBi4Je4wObsHdCoaaeR2zmdspZpfvyf34yts6yleVPuPPHGZlH/ LkpDkFPlNJw1gXJ13KVuF5mLrH/yRGhKO7TP/UzK2VmyzhtpaFtguNNqZNtwJgxL7kUQ JcsSflOVQNfEONdGJ8BsOigdVXHOuA3dcmM1qzciqTSEkxvoPjk52r7feXQ1Tuc1L76Y 9+CjxOlhB2gdPyok8+OLUbIUvF4Wx4pkoMoEWsfvX1ImuXZSk2bTfX/xKE/+ZIvjWS/Z QwmpLQCtoSVCyz0Ej1CCdF82J3LTRjDqjsWMXXQFR7MkyCu8EaMDTnCTPODIQr497Mlw s1VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795735003; x=1796339803; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=5msL5Y3whH1wyPAcimr4/6A5hkAEK5pqKOOOJceBdzM=; b=SzjRO881pWAIU6xgvcYvHG/CDWJMit61maa46IS6xnt98ZbSajpiwbahQ4UDan+8LJ kkdw3VBvdn875KXroueuxHxYwanDruN+FTEz7vZreQBNwNAuYL06hHPYDoRZAJgcHg7d SwDp+E+bobiWGLZcjNBF0mXSui2aAQ89RPyzQGYyi4I/b40d14P/qOlx+Ux5PVd3fSPP Zb+8eKIi760C3AoPd/vENTsBuGXDTxAG+IZj1x247WyfyDrHaP3RIF/a/E/WwTdSAm9a fOc56EAl5PPN+SiPjMQ4hOpv5+OMR5Zv8jjuSWeTlMdhS1CAfzf3g79KDzaYkKRFnRJP cx6Q== X-Gm-Message-State: APuU4Z96pQqi9zzbA0UypaXhLs4LIBNo21AEhlcTfwe0hHC3/dDsCvRI u9GEsuxkgwqG8XiCnxoV8y+PijRh1nf1TDeBdCvkFAgMpZ61sQ/uyc2kBlAAkLTKvWoSDGJ4Bdj ItIxh1fGqTxn3C3/1sSgAs89pqKge3mmmt0v2qYnvqTToDT7HZWJkxZYLPzXkFrPcbuVfM7RmeS sK1/Kwet5zkjy0W8dhvUCHUThYTKYH1qzBvoo3Pw== X-Gm-Gg: AZFdTZcH7KC+sJa3G5NFmNmiF78WguLCmJYE2wPwczIe9qtEqfOZAKFpajF4T2ObSAY kh3mOthmvUaYYzTtsDyGZs2TVN6xYmjvWK2ZIrxdq7seDTVWJcnHwXSju44mOPnZKBzRIHjMU2h bzgno1/bKPmYKmdASSFMCC6sKv1UIexILPat2ZQfhFqRy4ZON9Qo+eS+Ru/3gDz3b2r+jNu8F5Z sagN78iM1lTMa+Nlv9Vj4Sl47OdGJB7Cp1x4zEkj12i+hqkwmM5R7P7yA7Rm5JL9023gNcHsGrP +Rk+16xL2vJH+c45vGbN/iQg7St6wswxxma2Skw4fc82L8gBGsEB8wPVRmxkGjPAq0/YnCeUV15 pzgdbiZ0c2fcYPmgvuufdgd5P2ClDVI2IFbbMegQkJfE2 X-Received: by 2002:a05:620a:1d0b:b0:949:75f1:e5fe with SMTP id af79cd13be357-949bab1719cmr3745580385a.73.1795735003157; Thu, 26 Nov 2026 15:16:43 -0800 (PST) X-Received: by 2002:a05:620a:1d0b:b0:949:75f1:e5fe with SMTP id af79cd13be357-949bab1719cmr3745575685a.73.1795735002525; Thu, 26 Nov 2026 15:16:42 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , Peter Maydell , peterx@redhat.com, Fabiano Rosas , Gavin Shan , qemu-arm@nongnu.org Subject: [PATCH for-12.0 v2 5/9] hw/gpio/zaurus: Move VMSTATE_VALIDATE() check into post_load_errp() Date: Thu, 26 Nov 2026 18:16:27 -0500 Message-ID: <20261126231631.3392756-6-peterx@redhat.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261126231631.3392756-1-peterx@redhat.com> References: <20261126231631.3392756-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-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_H3=0.001, RCVD_IN_MSPIKE_WL=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: 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 @redhat.com) X-ZM-MESSAGEID: 1795735096568158500 Content-Type: text/plain; charset="utf-8" To pave way for removing VMSTATE_VALIDATE(), remove the use in this file by moving it into the post_load_errp(). Cc: Peter Maydell Cc: qemu-arm@nongnu.org Signed-off-by: Peter Xu --- hw/gpio/zaurus.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/hw/gpio/zaurus.c b/hw/gpio/zaurus.c index 3cf626a550..ede28f0929 100644 --- a/hw/gpio/zaurus.c +++ b/hw/gpio/zaurus.c @@ -23,6 +23,7 @@ #include "qemu/module.h" #include "qemu/log.h" #include "qom/object.h" +#include "qapi/error.h" =20 /* SCOOP devices */ =20 @@ -188,12 +189,19 @@ static void scoop_init(Object *obj) sysbus_init_mmio(sbd, &s->iomem); } =20 -static int scoop_post_load(void *opaque, int version_id) +static bool scoop_post_load(void *opaque, int version_id, Error **errp) { ScoopInfo *s =3D (ScoopInfo *) opaque; int i; uint32_t level; =20 + if (s->prev_level & 0xffff0000 || + s->gpio_level & 0xffff0000 || + s->gpio_dir & 0xffff0000) { + error_setg(errp, "irq levels are not 16-bits"); + return false; + } + level =3D s->gpio_level & s->gpio_dir; =20 for (i =3D 0; i < 16; i++) { @@ -202,7 +210,7 @@ static int scoop_post_load(void *opaque, int version_id) =20 s->prev_level =3D level; =20 - return 0; + return true; } =20 static bool is_version_0(void *opaque, int version_id) @@ -210,27 +218,17 @@ static bool is_version_0(void *opaque, int version_id) return version_id =3D=3D 0; } =20 -static bool vmstate_scoop_validate(void *opaque, int version_id) -{ - ScoopInfo *s =3D opaque; - - return !(s->prev_level & 0xffff0000) && - !(s->gpio_level & 0xffff0000) && - !(s->gpio_dir & 0xffff0000); -} - static const VMStateDescription vmstate_scoop_regs =3D { .name =3D "scoop", .version_id =3D 1, .minimum_version_id =3D 0, - .post_load =3D scoop_post_load, + .post_load_errp =3D scoop_post_load, .fields =3D (const VMStateField[]) { VMSTATE_UINT16(status, ScoopInfo), VMSTATE_UINT16(power, ScoopInfo), VMSTATE_UINT32(gpio_level, ScoopInfo), VMSTATE_UINT32(gpio_dir, ScoopInfo), VMSTATE_UINT32(prev_level, ScoopInfo), - VMSTATE_VALIDATE("irq levels are 16 bit", vmstate_scoop_validate), VMSTATE_UINT16(mcr, ScoopInfo), VMSTATE_UINT16(cdr, ScoopInfo), VMSTATE_UINT16(ccr, ScoopInfo), --=20 2.56.0 From nobody Sun Nov 29 02:11:45 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1795735106; cv=none; d=zohomail.com; s=zohoarc; b=JPyqeeqSUpavNQ+4pedhioXOMuhbngWt3ZVevVKgSZBYMGgIoZbYALxUkywQvqnrOggMYghSxsn99rWVKLP6ckQH5+Rj2Clw2502cAzVR+1CJUfiTil9JkPmhkcMblaxd7TLzsfPwOdhvlyvR9zeUU9ekgIuWBeTclG6hJtzAq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795735106; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SWXrbqJoIWI67nNPfPVrmoK5FoKi8MMDx293CLAjU/U=; b=dI2pAZJi+GVf9E0498tmqqYPrk5ujrcAuayHzaoqPc6gA+/2S8cTnSMCfNC/QwnptRh+0qMjdmbLhLiqeqt89/ekZI3RdqcCx1tZMH2eHQfizJBRf7VmpmzaS6t+VypAkGivPB5YVF7EC6FQLhDvpLS/gm8YZtgCM+uj7w4SAl8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179573510601811.16218617509628; Thu, 26 Nov 2026 15:18:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xWihy-0008CV-Is; Thu, 26 Nov 2026 18:16:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihu-00088R-Ie for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihs-00063T-AR for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:49 -0500 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-245-44b_zG4jOwSscQWwHckwsw-1; Thu, 26 Nov 2026 23:16:45 +0000 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-55d846fd50aso52227771cf.0 for ; Thu, 26 Nov 2026 15:16:45 -0800 (PST) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-921347a0b6bsm197783836d6.1.2026.11.26.15.16.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 15:16:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795735007; 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=SWXrbqJoIWI67nNPfPVrmoK5FoKi8MMDx293CLAjU/U=; b=Ampg6iFIGNBMKPVqiRMl5nyrUO5n8Lnj/QJBoyLK27BTLFdjhcbUtbP2SbB2TI2k7y7VvJ PPzmZl7zMTcFC2uO4790GUACyVczNOwO+PMXw50d41cptL3Mc5K1/IV72WXfYJ6xbiOuQT iPBTcWMckgoa9XSExnpQfH2CK44Z/A8= X-MC-Unique: 44b_zG4jOwSscQWwHckwsw-1 X-Mimecast-MFC-AGG-ID: 44b_zG4jOwSscQWwHckwsw_1795735005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1795735005; x=1796339805; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SWXrbqJoIWI67nNPfPVrmoK5FoKi8MMDx293CLAjU/U=; b=IrJ7joHkINXHjLAU/tRCXoztIOGeF2wFCBCGwHY18xvPpHxf4jzDIZengBaUcB2I7t NeMeQAlipDOlrgybfQbAGrEee2rBfGkmR3EIRoWzBoopg+9zchkG9NuZy/qaDqZsHhop zudq00zfhLC94vEUu8jXeusRrhOAdGXM3aI9NH8kNz/oQLNt7fkmBNTRD/r2c/IrObG9 TpfUlq8equHS/fT8gKb/NQGEvdxMCL+zLIWUaax+1WsrEsPVjiJi6WOtlhRR7/b6AAT0 xq7e3Uy9wCVquc6FdfOU+SmuiztII723KCBTCYSJFTNM813eaTMlZxvNazkeUah1JsDI 36SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795735005; x=1796339805; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=SWXrbqJoIWI67nNPfPVrmoK5FoKi8MMDx293CLAjU/U=; b=yFaPmgVEC52fLF8UXkFSp/fvGS2zemDdzcZCOSw2zSBus8vG07VDV74LT5PCb8SiN8 fV3IT5FcIr2t/uAWlD94WuhlLRGVH7yaAIgJxy9RZRPFKh1Lx7qwCrasrGO22JPPjE6G FJA4MrMZgPZepDbE+00cVskclIQJ35eStv9RfyzFdDdoFi2UVs1XRd7E51aSfSskZ+u6 7TTV8eoWO7ReC+gR8NZNlEXjedKXEAaVdYJee9145lZGGbbDKxvrFdZ+FoZ1E+QDaX7K 7GOHGtxW4i5gyJvjfGW/1oVCcAO3E5xB9t7v55oF7YcGCskA3ASkHzP/E1jinGamCAG2 RmJA== X-Gm-Message-State: APuU4Z/7CgkRPeScEgk9T1gNFI3NaBYz81d/YppWxN0fUs+GVKsp/Neo zyo4efZAr0fs30fbuTAzG00uQiBZI1pfgJKxOtrB+kq+SfmDmcBSgAeA6ZUMyQ6twXapR5HTvzq TVy3Fptjw+upaxIHc2SBOYoa2jDCj5Vq6GHGYQ6roBCF/vOC4wqNHX4sG1qcSWpJz0D0nvi0UWD M082pj35qOROpi9f1brnioeqxpYo/j8yNwIoVIbg== X-Gm-Gg: AZFdTZdVFE2O3QLB3DVv0b1hc3RfMOlBo0fPj5Ni6BFq8TmYXZb3m8r6Xb4yVyFxS5C 7XywinNg65qcP5Tu/mEsi0IEmMkUm+FofikkiY379zsonCGxy2yUsiRHYJS8lNWeF10U9WT6gjc vEaXDrBBaID/uCx0MH1rPEUPeS7BcV/g0qTmEQSeTRQRBPJnmO22sos1ApuCpptzghC3V5ozGiS 3T6o+QyxfRTkNM55DD4WR5qyWK7O5FtIXwgYHGZmJ6zS6eicVt3Ep8r3tlSz/FsJLB7H3YxOosW waIoSeoBr8ufPNGxZKRnPwLlGHzc71GHJyNZbFOyIvuur1vslBh4NsuEGpkDRk7ezHtlOFOaMSr FKBlSVsCAZkbUVqk5ptOYppQKCspkF6cULPo7/9piwITO X-Received: by 2002:ac8:6545:0:b0:537:b9f5:cd69 with SMTP id d75a77b69052e-55d76aa8ef9mr406133241cf.75.1795735005101; Thu, 26 Nov 2026 15:16:45 -0800 (PST) X-Received: by 2002:ac8:6545:0:b0:537:b9f5:cd69 with SMTP id d75a77b69052e-55d76aa8ef9mr406132781cf.75.1795735004640; Thu, 26 Nov 2026 15:16:44 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , Peter Maydell , peterx@redhat.com, Fabiano Rosas , Gavin Shan , "Michael S. Tsirkin" , Paolo Bonzini Subject: [PATCH for-12.0 v2 6/9] hpet: Move VMSTATE_VALIDATE() check into post_load Date: Thu, 26 Nov 2026 18:16:28 -0500 Message-ID: <20261126231631.3392756-7-peterx@redhat.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261126231631.3392756-1-peterx@redhat.com> References: <20261126231631.3392756-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: 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 @redhat.com) X-ZM-MESSAGEID: 1795735106667158500 Content-Type: text/plain; charset="utf-8" To pave way for removing VMSTATE_VALIDATE(), move the usage of hpet into post_load. To make it safer, loading the timers with the num_timers, then only check against the wire number at last. Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Signed-off-by: Peter Xu --- hw/timer/hpet.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 42285cff76..85cd26a454 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -254,25 +254,28 @@ static int hpet_pre_save(void *opaque) return 0; } =20 -static bool hpet_validate_num_timers(void *opaque, int version_id) +static bool hpet_validate_num_timers(HPETState *s) { - HPETState *s =3D opaque; - return s->num_timers =3D=3D s->num_timers_save; } =20 -static int hpet_post_load(void *opaque, int version_id) +static bool hpet_post_load(void *opaque, int version_id, Error **errp) { HPETState *s =3D opaque; int i; =20 + if (!hpet_validate_num_timers(s)) { + error_setg(errp, "num_timers must match"); + return false; + } + for (i =3D 0; i < s->num_timers; i++) { HPETTimer *t =3D &s->timer[i]; t->cmp64 =3D hpet_calculate_cmp64(t, s->hpet_counter, t->cmp); t->last =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - NANOSECONDS_PE= R_SECOND; } =20 - return 0; + return true; } =20 static bool hpet_offset_needed(void *opaque) @@ -332,14 +335,13 @@ static const VMStateDescription vmstate_hpet =3D { .version_id =3D 2, .minimum_version_id =3D 2, .pre_save =3D hpet_pre_save, - .post_load =3D hpet_post_load, + .post_load_errp =3D hpet_post_load, .fields =3D (const VMStateField[]) { VMSTATE_UINT64(config, HPETState), VMSTATE_UINT64(isr, HPETState), VMSTATE_UINT64(hpet_counter, HPETState), VMSTATE_UINT8(num_timers_save, HPETState), - VMSTATE_VALIDATE("num_timers must match", hpet_validate_num_timers= ), - VMSTATE_STRUCT_VARRAY_UINT8(timer, HPETState, num_timers_save, 0, + VMSTATE_STRUCT_VARRAY_UINT8(timer, HPETState, num_timers, 0, vmstate_hpet_timer, HPETTimer), VMSTATE_END_OF_LIST() }, --=20 2.56.0 From nobody Sun Nov 29 02:11:45 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1795735049; cv=none; d=zohomail.com; s=zohoarc; b=d3v9X+RxJQ4prWnQnp/eu2oE4AsSex5VjpF6jww+01sJxI1GHH3Xch7d/TY87HVXSSt5BZbz3z10mqVBkTzVrddx4tiSvUHinQYKyYCdlrQnQWMOUkvqlKt8n2dUdNbhgwOIzQ+UCpQj5rtFU0Ol5/WY0tXbCjIK7ubmn+FibmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795735049; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Pb8QZnFZ6i9u1K+5wyRDecRf7PdJuD3xkUw7sIQNU1A=; b=l7Y4be/FipubJENzqv2jQ/1BwdxiRzcRj9tvczQVcXPCRS/KuE6Xl3J+KBBhBZzbgd0clhVH+6u7InBmLNMaBl703aJHLaQq8S3nJ6k+0L787jYFYvCt3ScVqm1oar2bIZ9nVJIQsiBLsFyJaS+r7/+ZeezahSQd9lrFxGo2qaU= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795735049636200.99433058105183; Thu, 26 Nov 2026 15:17:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xWii1-0008FW-DT; Thu, 26 Nov 2026 18:16:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihw-0008Ap-6b for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihu-00063y-53 for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:51 -0500 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-681-XN8QBFQNPM-ZdZ4rTjEm7Q-1; Thu, 26 Nov 2026 23:16:47 +0000 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-9495af07676so1123224485a.2 for ; Thu, 26 Nov 2026 15:16:47 -0800 (PST) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id af79cd13be357-949bb031601sm1678969385a.6.2026.11.26.15.16.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 15:16:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795735009; 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=Pb8QZnFZ6i9u1K+5wyRDecRf7PdJuD3xkUw7sIQNU1A=; b=ZrJXj7XiZV9BOT1PiNCfksmANiYJAudz1FvCV3Iy33OP3ILcon0lnczA14lMlk9nDf/+HG S0K/JuTPiqqiIK/0i+rARHtMIsBRciQAVTzycF7Ty9DCMaIoUpawMxN+Kz9RtJtkaYm1pf QdVKo1ZOg/ne/T61jf4O16v2+3vN/Ts= X-MC-Unique: XN8QBFQNPM-ZdZ4rTjEm7Q-1 X-Mimecast-MFC-AGG-ID: XN8QBFQNPM-ZdZ4rTjEm7Q_1795735007 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1795735007; x=1796339807; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Pb8QZnFZ6i9u1K+5wyRDecRf7PdJuD3xkUw7sIQNU1A=; b=M2MBgfuCEKuGhMoqjL0IwwekMu9NSXsSFFTIhQnfzKvNV107ulQj7zq5fC7m4Yk1HD 3F8TWkgYmyh4kJrhI81ZcG0dwO9MnRxoMa7+XL0b/Tqj6vOZ1bvymRxnsSfbd8btLd7p gXGPeCKuTfyyJR1ZcwNesoFeU2RYrs7nvqPEfj6hA+e4lplxa3gJZUOtgsKd3P07dv4D u5JUvGcTSYV5NAJ0+yd6/CzvFWBn8pVRklWwzhAM4prPZtEJPe6X7llzS4VoBMC1wRzA /V90QsPartReKmdkUpCh1gKSNexTO0zN6rIuIOiEHwrZh4G4enfgG+prig+PXHyq+i/w 69fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795735007; x=1796339807; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Pb8QZnFZ6i9u1K+5wyRDecRf7PdJuD3xkUw7sIQNU1A=; b=B/pnQhKRSzPOy04q9EEDY5iid5DFoT4CMPQ/OdnPfEV6pgObIID5Sl3n/nWjDIZmnU l/fyBpVDh+FevFicuxY6nN/Vo4jlvyHDXvZKwAAYwaNT38MBQvrxbuuXJPk2JQ33/tmy S9kQxQXpfsU+33/NiMXR6NYAK9oviG4fAbDRZt/o2TM/rZ6hh3dI77WOPtfTDBLAHeHz 8QLh55jwl/rvIYSGks1fW/Y/tXXDnjeomSiOrf8usZLn2p/ldBzOJFNLV+liIG3dZRJA VEW5Zv+cy99qHqRORJFWpOSngkArMAkqy0WvLBSgi0FdRkqpDK/+CAoFDheNNFWOWW9N nsqQ== X-Gm-Message-State: APuU4Z/kLoeqfjsq3mCh/2GscgmzBhrYrHcwmnxnh4b4ZEQkMY9YajG+ VkRNywMg+tziOF2UUVb8sKL+OOGr3moR0cw4RO5XQpaIHAPhr5mc5Fzaso8ISUILQg7+JENfKyv yO8UzVIdROIpN3ZwRJgm8OBbV9Fj0/h/LHoMiKdQ+2R8+L54cU2GRETW4XRytyQF5dHjX2fjnGL x5SkHCaqjkuhr/o2/KxNXONogSzfr58jOl1xvyrw== X-Gm-Gg: AZFdTZfskCBvMgHBwlMBbS29fGLKCxcOTCoZrEzX/FDZZAJV+DAH5T0n/FRa7NArV7X c9D1fLovYUHeMGKkPdg+rL1BtN26J/sulwHN+nLwktDl0ES15+ofmUFrVMTO35gvAICU3PsXMPu s4ew1aIx9D96qXUuGxPfaDHpKgGBlBg3cFuSXXa8LxazzxaFNvbRMajO6VwU40ucGVwMESB1Bki 4PLc+dtYrbLf/dCvzpJbFzisRJLyMXMwOrsBNb6tmYq7AHV5sGi0CwvHUUfFLXIurmjcvSr3gMz lqSzz6X/PCaLOoCbNKE9Tjz9tPXQLevQ2uKhUmccfEHjb4m2vsdq7XiZ/3HcRwcFgKjTUWvVAV5 MkYed9kfJ4krUldFrolstz2yXF8hCcHActsJWiE5QYpLu X-Received: by 2002:a05:620a:4404:b0:93f:19fe:e6ca with SMTP id af79cd13be357-949ba9aedf8mr4129887985a.43.1795735006661; Thu, 26 Nov 2026 15:16:46 -0800 (PST) X-Received: by 2002:a05:620a:4404:b0:93f:19fe:e6ca with SMTP id af79cd13be357-949ba9aedf8mr4129882285a.43.1795735006087; Thu, 26 Nov 2026 15:16:46 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , Peter Maydell , peterx@redhat.com, Fabiano Rosas , Gavin Shan Subject: [PATCH for-12.0 v2 7/9] arm/machine: Convert cpu_post_load() to take Error** Date: Thu, 26 Nov 2026 18:16:29 -0500 Message-ID: <20261126231631.3392756-8-peterx@redhat.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261126231631.3392756-1-peterx@redhat.com> References: <20261126231631.3392756-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: 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 @redhat.com) X-ZM-MESSAGEID: 1795735050515158500 Content-Type: text/plain; charset="utf-8" Convert it to post_load_errp() version, so as to be able to report verbose errors when hit. A few things to mention: - The old "fail" count won't work with Error**, switch to fail and return immediately, assuming we should stop migration immediately hitting the 1st error. - Alone the way, handle_cpreg_only_in_incoming_stream() return value is flipped to make it match QEMU's normal coding style (return true for success, false for error, not vice versa). - Provide simple error strings for the cases where the lower function doesn't yet take an Error**. Signed-off-by: Peter Xu --- target/arm/machine.c | 52 ++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/target/arm/machine.c b/target/arm/machine.c index 02a2b78506..e86fa85a9b 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -11,6 +11,7 @@ #include "migration/qemu-file-types.h" #include "migration/vmstate.h" #include "target/arm/gtimer.h" +#include "qapi/error.h" =20 static bool vfp_needed(void *opaque) { @@ -1151,10 +1152,11 @@ static void handle_cpreg_missing_in_incoming_stream= (ARMCPU *cpu, uint64_t kvmidx * Handle the situation where @kvmidx is in the incoming * stream but not on destination. This fails the migration if * no cpreg mig tolerance is matched for this @kvmidx - * Return true if the migration should eventually fail + * Return true if success, false otherwise. */ static bool -handle_cpreg_only_in_incoming_stream(ARMCPU *cpu, uint64_t kvmidx, uint64_= t value) +handle_cpreg_only_in_incoming_stream(ARMCPU *cpu, uint64_t kvmidx, uint64_= t value, + Error **errp) { g_autofree gchar *name =3D print_register_name(kvmidx); =20 @@ -1163,18 +1165,17 @@ handle_cpreg_only_in_incoming_stream(ARMCPU *cpu, u= int64_t kvmidx, uint64_t valu arm_cpu_match_cpreg_mig_tolerance(cpu, kvmidx, value, 0, ToleranceOnlySrcTestVa= lue)) { trace_tolerate_cpreg_only_in_incoming_stream(name); - return false; + return true; } - error_report("%s: %s in the incoming stream but unknown on the " - "destination: fail migration", __func__, name); - return true; + error_setg(errp, "cpreg %s in the incoming stream but unknown on the " + "destination", name); + return false; } =20 -static int cpu_post_load(void *opaque, int version_id) +static bool cpu_post_load(void *opaque, int version_id, Error **errp) { ARMCPU *cpu =3D opaque; CPUARMState *env =3D &cpu->env; - bool fail =3D false; bool ignore_s_regs; int i, v; =20 @@ -1229,9 +1230,11 @@ static int cpu_post_load(void *opaque, int version_i= d) continue; } if (cpu->cpreg_vmstate_indexes[v] < cpu->cpreg_indexes[i]) { - fail =3D handle_cpreg_only_in_incoming_stream(cpu, - cpu->cpreg_vmstate= _indexes[v], - cpu->cpreg_vmstate= _values[v]); + if (!handle_cpreg_only_in_incoming_stream( + cpu, cpu->cpreg_vmstate_indexes[v], + cpu->cpreg_vmstate_values[v], errp)) { + return false; + } v++; continue; } @@ -1278,21 +1281,22 @@ static int cpu_post_load(void *opaque, int version_= id) * still regs in the input stream, continue parsing the vmstate array */ for ( ; v < cpu->cpreg_vmstate_array_len; v++) { - fail =3D handle_cpreg_only_in_incoming_stream(cpu, - cpu->cpreg_vmstate_ind= exes[v], - cpu->cpreg_vmstate_val= ues[v]); - } - if (fail) { - return -1; + if (!handle_cpreg_only_in_incoming_stream( + cpu, cpu->cpreg_vmstate_indexes[v], + cpu->cpreg_vmstate_values[v], errp)) { + return false; + } } =20 if (kvm_enabled()) { if (!kvm_arm_cpu_post_load(cpu)) { - return -1; + error_setg(errp, "kvm_arm_cpu_post_load() failed"); + return false; } } else { if (!write_list_to_cpustate(cpu)) { - return -1; + error_setg(errp, "write_list_to_cpustate() failed"); + return false; } } =20 @@ -1307,7 +1311,8 @@ static int cpu_post_load(void *opaque, int version_id) * thumb_tr_translate_insn(). */ if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) { - return -1; + error_setg(errp, "Misaligned thumb pc"); + return false; } =20 if (tcg_enabled()) { @@ -1325,7 +1330,8 @@ static int cpu_post_load(void *opaque, int version_id) FPCR_LTPSIZE_SHIFT, FPCR_LTPSIZE_LENGTH) !=3D 4 || extract32(env->v7m.fpdscr[M_REG_S], FPCR_LTPSIZE_SHIFT, FPCR_LTPSIZE_LENGTH) !=3D 4) { - return -1; + error_setg(errp, "Bogus fpdscr[] values"); + return false; } } =20 @@ -1337,7 +1343,7 @@ static int cpu_post_load(void *opaque, int version_id) arm_rebuild_hflags(env); } =20 - return 0; + return true; } =20 const VMStateDescription vmstate_arm_cpu =3D { @@ -1347,7 +1353,7 @@ const VMStateDescription vmstate_arm_cpu =3D { .pre_save =3D cpu_pre_save, .post_save =3D cpu_post_save, .pre_load =3D cpu_pre_load, - .post_load =3D cpu_post_load, + .post_load_errp =3D cpu_post_load, .fields =3D (const VMStateField[]) { VMSTATE_UINT32_ARRAY(env.regs, ARMCPU, 16), VMSTATE_UINT64_ARRAY(env.xregs, ARMCPU, 32), --=20 2.56.0 From nobody Sun Nov 29 02:11:45 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1795735092; cv=none; d=zohomail.com; s=zohoarc; b=MUlPVRST1rSXmMyPy7WoMP2EZ7/99Grivbf5dLUbIbCblsPIPIPXbeqsi/No8dsHM0nx/VDoeCHOcI1dwTaONQQaaykpTw10nUsfPzL+kYhH8Leoa3Cj39s8Np2UBze3oKaQUfDCIVsWx54E9Sb8fdDN5R/kz/1qIhVJR1oxKB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795735092; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Pemxv6+p2jbO1Ze6odVJgmKdnHXIU402L1Ae0wQ+2iw=; b=l81G0kBDYmhIZUVfTMeSjQG2u2YfPfYhZXHd+NNMt1YdBCo/OEtenk5gSDPy34cuik1Pt2GufXE7X+ME/X0ZZ9KSCx/VdT1t/v9MFRrKxtT4Lbnr2yosTS08aN/xp1A8pMtKjCNA2S3WKCvkcjhbSZLmwV+1AIqtNuWCh3Kn2sI= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795735092514101.9026040037761; Thu, 26 Nov 2026 15:18:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xWii0-0008Ca-Ba; Thu, 26 Nov 2026 18:16:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihx-0008As-K9 for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:53 -0500 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 1xWihv-00064S-RD for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:53 -0500 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-vM2iziIlPCmTZtxjqaNYQw-1; Thu, 26 Nov 2026 23:16:49 +0000 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-91256a7b7b3so107504776d6.2 for ; Thu, 26 Nov 2026 15:16:49 -0800 (PST) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id af79cd13be357-949bb3c2abesm1675207385a.26.2026.11.26.15.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 15:16:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795735011; 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=Pemxv6+p2jbO1Ze6odVJgmKdnHXIU402L1Ae0wQ+2iw=; b=QP7aqOHHkLUnxeU0bGfnLRbntNbL1SVZuK//n61XzEa+Z2Kmbl6pRbCw+3aZn56TLTO6xx HPoiFy+CEb1ShFLRy9VtgEXd6OQylO9VhiKyM0h5G05FVZw7KhhVPgb7FaeXpNk9adYJnl youqVfI/Ay9eOOvafZoQUcCtG3pRWO4= X-MC-Unique: vM2iziIlPCmTZtxjqaNYQw-1 X-Mimecast-MFC-AGG-ID: vM2iziIlPCmTZtxjqaNYQw_1795735009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1795735009; x=1796339809; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Pemxv6+p2jbO1Ze6odVJgmKdnHXIU402L1Ae0wQ+2iw=; b=dHWtemTohXmeKdN7r9pKVZczDbUaaQKqvxlh+c70F+2i8RLsfNqM4uFUt0R/SOErzR UfGhd3+HZtYXhuZxPWMjb+wf6TYU8wwgEyTlTsp4mrouf/IFXxHrH2+ISw4l3HR/0cG+ N35JOHu9H3skILkjt3T4+GKssRSuuY7gII3KyEYMufj41sR6b8QPf9+xAEgDNEgdbh89 8iQkC7162pIXLSgQTeILPyDFE4tZeJNC6G7pbAnmchYn2wjGHJ2eIfxjqyCCy1mJkzzH wdGCP4yOOu236FUyNvb2sjOKkKnDdtYoUqiOQwwOV2tBbLOfpx6QhWp/2GOWDezIaJbv H5vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795735009; x=1796339809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Pemxv6+p2jbO1Ze6odVJgmKdnHXIU402L1Ae0wQ+2iw=; b=xLOiaHw6z9Gr0b5L19za9WUB5J5l7VnFOJvqLboEpuaTv+UjYuQ0uqGuNk41RL9AiF tNbQEQNZfnMqDMK1bHpjt09D6tY9qYqRu+d4BkLJ7fhnN+yosBOfCAidqC2TEbwge6WM TzrXcqgmHwyWwY8Q0bG6sbttVUU2AYSX/ddnJQx99Cw36HOzOa5vSvXUePqUDkD2dpJB K+8RGfnmOodIQ5MTgZfqfaA4JOK9pYvSw3r+GryMihZ+Z2Zgq7VuvDVSZ3v7GWptcWLz vUhE8sJHmPW7md4GOn19Ti/ctAzuWzuWbK9fBdy2WIuz1YPE1kES1QIlgqyLgFiSoU/H 92AA== X-Gm-Message-State: APuU4Z/ic7AauuKFmGO/pMke9xYMs1leRjGULJTeIkEZ0xXfjbxQIYqq C/Kv51qfIgd0UrO7dY9RMGTOfkorp0LSDMQ6Gpwor1kuyqnr6512T6JvNQcFZfnUU+Wv/4wg4aN Xw5qZoIhKnmhAUp6cj5wO5D7kIivNfNxlr6eRIYLgSCa96up3mTuvcaIjZl+M/QziBtHDFp9+cI vt38MRXdmvhwaohKn3HY5nlMUN9X40O9lgbpJF5A== X-Gm-Gg: AZFdTZcSqzO4cheLZ5iNVfGiJJ3tVxYvw1x/qni6ttW6j9IbhlsqVLLzb7LrG7Oeis/ tASke4ZT1cOQT8NaR5cfQU65+B3iqvzD4knHg/MGUOWG88KZFdYPfPKHYD2TIMyPfGIgmQCfZ1V 3VV87fthkpXkkZHAeeip5WKHAb+h8wOdGMgGLx2sgizloGjltJOJ18Iot20ferZG0bu7zOoLfgf BLJVrB1ZIc1Rqr0I+VttJ9BCro1Ef+7/tTseMRIWc+eOxj41ilZuw8f9oMQoF8BCjOS7Yv3iJNg irhxkLAyeZ1HOenMYriTbUkyU3kxNCS5J39WK+jKdcPUmdXBGNXFcAGVuc5aNnx4ZJmB10QHZVT xapGn0DxuVCblsW5DeI/eQRIsxyW5C5zzjbdW/QmklLQW X-Received: by 2002:a05:620a:2417:10b0:949:7bf4:3b47 with SMTP id af79cd13be357-949bbb8d5b2mr3048262385a.27.1795735008606; Thu, 26 Nov 2026 15:16:48 -0800 (PST) X-Received: by 2002:a05:620a:2417:10b0:949:7bf4:3b47 with SMTP id af79cd13be357-949bbb8d5b2mr3048257685a.27.1795735007991; Thu, 26 Nov 2026 15:16:47 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , Peter Maydell , peterx@redhat.com, Fabiano Rosas , Gavin Shan , qemu-arm@nongnu.org Subject: [PATCH for-12.0 v2 8/9] arm/machine: Move all VMSTATE_VALIDATE() usages into post_load Date: Thu, 26 Nov 2026 18:16:30 -0500 Message-ID: <20261126231631.3392756-9-peterx@redhat.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261126231631.3392756-1-peterx@redhat.com> References: <20261126231631.3392756-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-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_H3=0.001, RCVD_IN_MSPIKE_WL=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: 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 @redhat.com) X-ZM-MESSAGEID: 1795735094689158500 Content-Type: text/plain; charset="utf-8" To pave way removing VMSTATE_VALIDATE(), move all four such uses into a post_load hook instead. Cc: Peter Maydell Cc: qemu-arm@nongnu.org Signed-off-by: Peter Xu --- target/arm/machine.c | 90 ++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 53 deletions(-) diff --git a/target/arm/machine.c b/target/arm/machine.c index e86fa85a9b..b401593496 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -407,14 +407,6 @@ static const VMStateDescription vmstate_m_faultmask_pr= imask =3D { * just non-secure, we transfer both banks here rather than putting * the secure banked version in the m-security subsection. */ -static bool csselr_vmstate_validate(void *opaque, int version_id) -{ - ARMCPU *cpu =3D opaque; - - return cpu->env.v7m.csselr[M_REG_NS] <=3D R_V7M_CSSELR_INDEX_MASK - && cpu->env.v7m.csselr[M_REG_S] <=3D R_V7M_CSSELR_INDEX_MASK; -} - static bool m_csselr_needed(void *opaque) { ARMCPU *cpu =3D opaque; @@ -429,7 +421,6 @@ static const VMStateDescription vmstate_m_csselr =3D { .needed =3D m_csselr_needed, .fields =3D (const VMStateField[]) { VMSTATE_UINT32_ARRAY(env.v7m.csselr, ARMCPU, M_REG_NUM_BANKS), - VMSTATE_VALIDATE("CSSELR is valid", csselr_vmstate_validate), VMSTATE_END_OF_LIST() } }; @@ -590,18 +581,6 @@ static bool pmsav7_needed(void *opaque) !arm_feature(env, ARM_FEATURE_V8); } =20 -static bool pmsav7_rgnr_vmstate_validate(void *opaque, int version_id) -{ - ARMCPU *cpu =3D opaque; - - /* - * Check MPU_RNR in-bounds. If no MPU, we still migrate this field - * but number of regions =3D=3D 0 and MPU_RNR is RAZ/WI so also 0 - */ - return cpu->env.pmsav7.rnr[M_REG_NS] < cpu->pmsav7_dregion || - (cpu->pmsav7_dregion =3D=3D 0 && cpu->env.pmsav7.rnr[M_REG_NS] =3D= =3D 0); -} - static const VMStateDescription vmstate_pmsav7 =3D { .name =3D "cpu/pmsav7", .version_id =3D 1, @@ -614,7 +593,6 @@ static const VMStateDescription vmstate_pmsav7 =3D { vmstate_info_uint32, uint32_t), VMSTATE_VARRAY_UINT32(env.pmsav7.dracr, ARMCPU, pmsav7_dregion, 0, vmstate_info_uint32, uint32_t), - VMSTATE_VALIDATE("rgnr is valid", pmsav7_rgnr_vmstate_validate), VMSTATE_END_OF_LIST() } }; @@ -695,31 +673,6 @@ static const VMStateDescription vmstate_pmsav8 =3D { } }; =20 -static bool s_rnr_vmstate_validate(void *opaque, int version_id) -{ - ARMCPU *cpu =3D opaque; - - /* - * Check MPU_RNR in-bounds. If no MPU, we still migrate this field - * but number of regions =3D=3D 0 and MPU_RNR is RAZ/WI so also 0 - */ - return cpu->env.pmsav7.rnr[M_REG_S] < cpu->pmsav7_dregion || - (cpu->pmsav7_dregion =3D=3D 0 && cpu->env.pmsav7.rnr[M_REG_S] =3D= =3D 0); -} - -static bool sau_rnr_vmstate_validate(void *opaque, int version_id) -{ - ARMCPU *cpu =3D opaque; - - /* - * Check SAU_RNR in-bounds. If no SAU regions are implemented, - * we still migrate this field, but number of regions =3D=3D 0 and - * SAU_RNR is RAZ/WI so also 0 - */ - return cpu->env.sau.rnr < cpu->sau_sregion || - (cpu->sau_sregion =3D=3D 0 && cpu->env.sau.rnr =3D=3D 0); -} - static bool m_security_needed(void *opaque) { ARMCPU *cpu =3D opaque; @@ -749,7 +702,6 @@ static const VMStateDescription vmstate_m_security =3D { VMSTATE_VARRAY_UINT32(env.pmsav8.rlar[M_REG_S], ARMCPU, pmsav7_dre= gion, 0, vmstate_info_uint32, uint32_t), VMSTATE_UINT32(env.pmsav7.rnr[M_REG_S], ARMCPU), - VMSTATE_VALIDATE("secure MPU_RNR is valid", s_rnr_vmstate_validate= ), VMSTATE_UINT32(env.v7m.mpu_ctrl[M_REG_S], ARMCPU), VMSTATE_UINT32(env.v7m.ccr[M_REG_S], ARMCPU), VMSTATE_UINT32(env.v7m.mmfar[M_REG_S], ARMCPU), @@ -761,7 +713,6 @@ static const VMStateDescription vmstate_m_security =3D { VMSTATE_VARRAY_UINT32(env.sau.rlar, ARMCPU, sau_sregion, 0, vmstate_info_uint32, uint32_t), VMSTATE_UINT32(env.sau.rnr, ARMCPU), - VMSTATE_VALIDATE("SAU_RNR is valid", sau_rnr_vmstate_validate), VMSTATE_UINT32(env.sau.ctrl, ARMCPU), VMSTATE_UINT32(env.v7m.scr[M_REG_S], ARMCPU), /* AIRCR is not secure-only, but our implementation is R/O if the @@ -1177,11 +1128,48 @@ static bool cpu_post_load(void *opaque, int version= _id, Error **errp) ARMCPU *cpu =3D opaque; CPUARMState *env =3D &cpu->env; bool ignore_s_regs; + bool valid; int i, v; =20 trace_cpu_post_load(cpu->cpreg_vmstate_array_len, cpu->cpreg_array_len); =20 + if (env->v7m.csselr[M_REG_NS] > R_V7M_CSSELR_INDEX_MASK || + env->v7m.csselr[M_REG_S] > R_V7M_CSSELR_INDEX_MASK) { + error_setg(errp, "CSSELR is invalid"); + return false; + } + + /* + * Check MPU_RNR in-bounds. If no MPU, we still migrate these fields + * but number of regions =3D=3D 0 and MPU_RNR is RAZ/WI so also 0 + */ + valid =3D env->pmsav7.rnr[M_REG_NS] < cpu->pmsav7_dregion || + (cpu->pmsav7_dregion =3D=3D 0 && env->pmsav7.rnr[M_REG_NS] =3D=3D = 0); + if (!valid) { + error_setg(errp, "rgnr is invalid"); + return false; + } + + valid =3D env->pmsav7.rnr[M_REG_S] < cpu->pmsav7_dregion || + (cpu->pmsav7_dregion =3D=3D 0 && env->pmsav7.rnr[M_REG_S] =3D=3D 0= ); + if (!valid) { + error_setg(errp, "secure MPU_RNR is invalid"); + return false; + } + + /* + * Check SAU_RNR in-bounds. If no SAU regions are implemented, + * we still migrate this field, but number of regions =3D=3D 0 and + * SAU_RNR is RAZ/WI so also 0 + */ + valid =3D env->sau.rnr < cpu->sau_sregion || + (cpu->sau_sregion =3D=3D 0 && env->sau.rnr =3D=3D 0); + if (!valid) { + error_setg(errp, "SAU_RNR is invalid"); + return false; + } + /* * Handle migration compatibility from old QEMU which didn't * send the irq-line-state subsection. A QEMU without it did not @@ -1426,10 +1414,6 @@ const VMStateDescription vmstate_arm_cpu =3D { &vmstate_vfp, &vmstate_m, &vmstate_thumb2ee, - /* pmsav7_rnr must come before pmsav7 so that we have the - * region number before we test it in the VMSTATE_VALIDATE - * in vmstate_pmsav7. - */ &vmstate_pmsav7_rnr, &vmstate_pmsav7, &vmstate_pmsav8, --=20 2.56.0 From nobody Sun Nov 29 02:11:45 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1795735076; cv=none; d=zohomail.com; s=zohoarc; b=QaxvlsX0iwIS7W4tAYaH5nRT8byxKjxLFZiAnu8PnEuM0KyEtOVeX3MAInjFohNCWXBl05Ek+ysLbG6mH7yRA8pwIrOX/URH1pQ4Ko/mma3jhmPyBlUBavXDdjrsQN73SiUxdO4twxvWNc/nn3xjvSaIf0AmmQ5EOZy4v9uL/QY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795735076; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TEp351wB5GQySx79Zc08YPzzjN27Sn3CHKUChdROs60=; b=Q0HngfdPi+f1ZXxF896nImc0muMFudRhtdJwRYQhpdD/wd9n+P6zl2ANEbxVv0+PUTmJO2Ci+tXdm4DW2Fta1RXdXfjrL3FGIzFUA3XuunaZQj6h7RjQf05O2RaQHTsiwcmBBAYst6D/GBwjWszC8unOrN5ZsE7Fnd1NR5e4qYc= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795735076268585.3391633501858; Thu, 26 Nov 2026 15:17:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xWii5-0008IE-Go; Thu, 26 Nov 2026 18:17:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihz-0008Cg-U4 for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xWihy-00064t-B8 for qemu-devel@nongnu.org; Thu, 26 Nov 2026 18:16:55 -0500 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-395-7ywXZxCeN32fp6kOYojRsg-1; Thu, 26 Nov 2026 23:16:51 +0000 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-537548d4bc0so169118861cf.2 for ; Thu, 26 Nov 2026 15:16:51 -0800 (PST) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-55d7889ea4csm193940131cf.26.2026.11.26.15.16.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2026 15:16:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795735013; 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=TEp351wB5GQySx79Zc08YPzzjN27Sn3CHKUChdROs60=; b=Su5DJC7wonJSuS5TPVAPhiAl+QYpO+z6gLUc5g/zv/VZGOiM5Gk8o/Gaq6lrqfSKvqOhDu vHEv2BpeqgnDANRC3844Dh/0A058rr0uoeC+0bonpBJmRJH1egzRh5S3LSK/5XMm8s3LFn goEqWcCb+OXwuBZ9IxmU0bybr7jNLwE= X-MC-Unique: 7ywXZxCeN32fp6kOYojRsg-1 X-Mimecast-MFC-AGG-ID: 7ywXZxCeN32fp6kOYojRsg_1795735011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1795735011; x=1796339811; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TEp351wB5GQySx79Zc08YPzzjN27Sn3CHKUChdROs60=; b=pyHbIOF1tu5Tqkq6lMmJTtLqp3PzahwdO087ck8gC6C5GgpUFo0YqhoAMVn737JHLN WEZrsSfCZlJ20yNMB4JhzX0Qi/nygweijzTEUpTZlqJL/nDjgge5ClN9+9gn/Eq/EN5V o5xA+I5LHM9WpvH7zSpimfprj0+xqVIoSUqr3MMBVH3xi79fMpk9ofc/rZV6a9fQMVk2 lNj1OkQBB7NzWzQsrq0vFasC8nDwdxqIYaPc9cZNQDhFQbJD+kRaVqUwb0Tde8mAfklo hC1unYkGTNnZ2AJfD7xNxWwuIcOp/VrJNqOTvb2EGIlOS+/Ivh+WI9rbOhhOhrIWgwgq 5wEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795735011; x=1796339811; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=TEp351wB5GQySx79Zc08YPzzjN27Sn3CHKUChdROs60=; b=WsMrY3bvQiZOsWpf4Wk7WeLvhaGPM2Xn/C7e/iDFlQFc44TX4kIx8DCHiEBoD8Lo3z yvUmRG8C/mlTzgTs40oHvDXhNALxjk8UOHBhHVB0ur9euVqg+BQPna0ez8zEQZrNlm33 +E8CZwcKb4tZV02wt2uw/Ebq+kba2+2bdJpqCUY8C0WmQxSkhog/sUHbUuA0qO4HKQLb tdrH6RU5b9B840Qow7PD3er5cjNXzNY/4jfPcH9Or1iybR/z8xVwvx3bBPjiG4AbzGlK 27ARiuaF6Zfafe9Z9b69nO3daG4pLLpgXVx3pQVH8dklL808dFAoO7lYaHwWw081baDz CDJw== X-Gm-Message-State: APuU4Z8iMKxS5bOZRKuR1HRcidL8jbsVtIyxp12QJH80BQoF2a3PmP9H TydTCvkicX2QoNmSlcTshDPMN/0iz5ixubi8HoMFgcr/W6ehMnDpxXYeUe7Ex+ulH2FPaNn2Ds+ JNnn27fEf+ITTOUlX44rm9jsS2Mdnfl96cN4Cgt7/38el+ppyZL3xRMKkofcZOJnqiA3o2XOALY w5WW2v/QY2R252gZqT3R3TG0q3ykVY65XTq/bkOQ== X-Gm-Gg: AZFdTZctW+O4P36kToOVvmSMSEJRgFScuEby3gHR6dUPF7DcA539klI902BXPAsPib5 jM4mesqJnkqcOJWkPhiTJO/3VUuNSQnikvpuz2YoJLPW3VYXBCthDTGA2vs7w3xIzlT2KEyBpku Oua767GdtTLjW0Lc5T0aw+jF9MMfLy/7uT8Z9GSh1cM6GMe6pwzpDP+zV98kwmb4oKM80HEqtTN zw2FrrLIYtaLcg10jsyny6c1vnq84DrlYo1IdRCzyrdTGG6hcZi9dXlknZEIbmDMv1RCRuPPzJM 2WVosaeVLOwr9ax1J54o2mzzZenQe8ZYbHzC12fELg/0cvK7GjQuczn2l3wbLjtd0Fdl8JxY0xg cWVY8CBbQZ9nskLPvwc4xiKhQkgQl4/L7nauaYM8AMfWS X-Received: by 2002:a05:622a:412:b0:55c:9b4f:f362 with SMTP id d75a77b69052e-55d76a5af9dmr409044721cf.34.1795735010926; Thu, 26 Nov 2026 15:16:50 -0800 (PST) X-Received: by 2002:a05:622a:412:b0:55c:9b4f:f362 with SMTP id d75a77b69052e-55d76a5af9dmr409044341cf.34.1795735010315; Thu, 26 Nov 2026 15:16:50 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Juraj Marcin , Peter Maydell , peterx@redhat.com, Fabiano Rosas , Gavin Shan Subject: [PATCH for-12.0 v2 9/9] migration: Drop VMSTATE_VALIDATE() and VMS_MUST_EXIST Date: Thu, 26 Nov 2026 18:16:31 -0500 Message-ID: <20261126231631.3392756-10-peterx@redhat.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261126231631.3392756-1-peterx@redhat.com> References: <20261126231631.3392756-1-peterx@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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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: 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 @redhat.com) X-ZM-MESSAGEID: 1795735078509158500 Content-Type: text/plain; charset="utf-8" We have moved all users to other API, now they're never used. Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas --- include/migration/vmstate.h | 11 ----------- migration/savevm.c | 5 ----- migration/vmstate.c | 12 ------------ 3 files changed, 28 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 2901877308..de7a957140 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -130,10 +130,6 @@ enum VMStateFlags { * allocated. Only valid in combination with VMS_VBUFFER. */ VMS_MULTIPLY =3D 0x200, =20 - /* Fail loading the serialised VM state if this field is missing - * from the input. */ - VMS_MUST_EXIST =3D 0x1000, - /* When loading serialised VM state, allocate memory for the * (entire) field. Only valid in combination with * VMS_POINTER. Note: Not all combinations with other flags are @@ -458,13 +454,6 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_value(_state, _field, _type), \ } =20 -/* Validate state using a boolean predicate. */ -#define VMSTATE_VALIDATE(_name, _test) { \ - .name =3D (_name), \ - .field_exists =3D (_test), \ - .flags =3D VMS_MUST_EXIST | VMS_NO_STATE, \ -} - #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ diff --git a/migration/savevm.c b/migration/savevm.c index fe94ba96e4..e4f614cc86 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -622,11 +622,6 @@ static void dump_vmstate_vmsd(FILE *out_file, fprintf(out_file, ",\n%*s\"Fields\": [\n", indent, ""); first =3D true; while (field->name !=3D NULL) { - if (field->flags & VMS_MUST_EXIST) { - /* Ignore VMSTATE_VALIDATE bits; these don't get migrated = */ - field++; - continue; - } if (!first) { fprintf(out_file, ",\n"); } diff --git a/migration/vmstate.c b/migration/vmstate.c index 24004565bf..7734caab06 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -116,8 +116,6 @@ static uint64_t vmstate_n_elems(void *opaque, const VMS= tateField *field) n_elems =3D field->num; } else if (field->flags & VMS_VARRAY) { n_elems =3D vmstate_read_from_offset(&field->num_indirect, opaque); - } else if (field->flags & VMS_MUST_EXIST && field->flags & VMS_NO_STAT= E) { - n_elems =3D 0; } else { n_elems =3D 1; } @@ -430,10 +428,6 @@ bool vmstate_load_vmsd(QEMUFile *f, const VMStateDescr= iption *vmsd, return false; } } - } else if (field->flags & VMS_MUST_EXIST) { - error_setg(errp, "Input validation failed: %s/%s version_id: %= d", - vmsd->name, field->name, vmsd->version_id); - return false; } field++; } @@ -810,12 +804,6 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMS= tateDescription *vmsd, vmdesc_loop =3D NULL; } } - } else { - if (field->flags & VMS_MUST_EXIST) { - error_report("Output state validation failed: %s/%s", - vmsd->name, field->name); - assert(!(field->flags & VMS_MUST_EXIST)); - } } field++; } --=20 2.56.0