From nobody Sun Sep 28 17:06:24 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1757751221; cv=none; d=zohomail.com; s=zohoarc; b=cnwXbmjEYzoFF3VU708wN2xFl8XgOsh0Dcnz9M+PeD1GLJN5u+ZiI9/UXvSKlGdw6QKIvVR87rCrDb9FvSYEnJeoCCl/2KTarYdsEiaHB7YimbVp3GoRtR0EICS2DrW7UCfAsCyxe5GToS/ckryqdJZb6rQAC8Tq5mj8GifuVEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757751221; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YZRZj3xQEand5ugY5kt3w0beYXz2rYMkRq6Ld6OQVjg=; b=NY9Pv/ZU3cZ8aq71x3Lsmq5ly/81OfCpCMvOzkG0K9UolssOmtJo1XaTlGNXRq22gZJ1MMPWH9EE/zZHyk2FMQ1H2ticpv0xuVbknQKe+asWHAk4VnihJ7qPY8rEQzGYQefDyY6L5R1tzlIP+hBfHv7TqM0uOW58/Z1cN2VxkDE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1757751221390533.130563741792; Sat, 13 Sep 2025 01:13:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uxLM8-0008MB-PJ; Sat, 13 Sep 2025 04:11:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uxLM2-0007ue-4R for qemu-devel@nongnu.org; Sat, 13 Sep 2025 04:11:30 -0400 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 1uxLLy-00055p-Az for qemu-devel@nongnu.org; Sat, 13 Sep 2025 04:11:29 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-465-1uqkIvsMOUe70SSPHGSH6Q-1; Sat, 13 Sep 2025 04:11:22 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-45df7e734e0so16319075e9.0 for ; Sat, 13 Sep 2025 01:11:22 -0700 (PDT) Received: from [192.168.10.48] ([151.95.56.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45e037b91e6sm89445105e9.14.2025.09.13.01.11.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Sep 2025 01:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757751084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YZRZj3xQEand5ugY5kt3w0beYXz2rYMkRq6Ld6OQVjg=; b=hTyAyDyRUySJDtaag/IGkuPboxMZlud1VcJvqiFbW9Y8PIKkIiIjFR7RyhzD9kexGXLYs0 jpcQ/keZaxY7KrSLc3My0Vj35xgALJ1iTz1YO70nEgk0yfHmC7XPFiC3FsGRFopX0mTSYj cxjlA9OvlnvZh4i6HaTcavnjwWHv/3U= X-MC-Unique: 1uqkIvsMOUe70SSPHGSH6Q-1 X-Mimecast-MFC-AGG-ID: 1uqkIvsMOUe70SSPHGSH6Q_1757751082 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757751081; x=1758355881; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YZRZj3xQEand5ugY5kt3w0beYXz2rYMkRq6Ld6OQVjg=; b=KRIaLoX+zVXcjJnYQHPSXVwqRcEt8O4gqL5Hb0CYbh3pI+a45l7vxlzv830tQz93sy eEoRfSlPqT8qaouLLm93pgC0IEhUqwMMR69ijvBxL+azWq4gpTLwCN9/49apcu1IybwY fmnEMvZ5RzLaRTPMBXqekCBz8jZa28JeaQf5vX1VhDsWh7p9knolmX+qnjUcfmzDztKC a0nTTfPtsba8e+7H7zqjNLlHRDvKaXqn4tz6i4ci+G9/pjrvuGQhWyqNc7NBgcWjmn6a BqvvlPkCoEf8li72uvkVMSfGbRzHVWixH4PKMLy1JtviLsdQ2XNzMlLk5uuOwzUiBo1d MnnQ== X-Gm-Message-State: AOJu0YxNrLNjSp0pIgUzdrfxaCzB5fEqVbxhL2Kh6KwG+Vq6R/t3pjDR +qTr4EpG6dbhBRzDuDFDCOhnsNHBxoHoWX/lU4aPXqntd8fUiNEydo87pRuEfPtcXL2jXl33hQp T3kYWOapFOGjhYue6SlccY7llnl1uEsWMJ3OlzlhMU/3NZivbGUjuen9DV+sFMKZmc1FSO9EDMT M9V8r0x7uCizV2MbnTo6UgZfmlWCk92BDzzl/SPc9N X-Gm-Gg: ASbGnctP4b1esAfzNilOpuHuZG/BCDvIpEOnGX/GogYXsS0zbrfHQCsGY/U0rkm1NXN i5DBBek6k9MMBtnh2Obql2EDEStBSXjMW/j5qKKjxQqB7GlF9OPHWwFxL7gVrOeuuhhNZhV2kOG 65z5vIKhoEYaHljIpVMS32WYlwPOVnySBXfsEWflFsH3xIwM4HGqi1EyKRCby9g+0oTTAsRQc/p Tx4WjSXTMtjCJJuVfeyHcVgENmMMXkmUyTk3A7jjgMtc6EkYcoWpWwMq30G2aXJewI+zfvaVUgC mfWacBZUwrCX3q6YTQq4aV8DfTwR+2PPKAbihyCdT8CkPnqPw3q8K0lsvNYoHdC96ZBouFbqVZj zbHen7ojOk6BxEvsD3abxdd/S1JxUY5E4uhRuLbVAVP0= X-Received: by 2002:a05:600c:46ca:b0:458:a992:6f1e with SMTP id 5b1f17b1804b1-45f211c4c8bmr71741885e9.5.1757751080576; Sat, 13 Sep 2025 01:11:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFF2yMpDjIHRJ7Tzz66XWWfm61RCG2asf0x0C1cdih5CEHSeqUFHOZvkZFKUHQjA2YVsiHDAA== X-Received: by 2002:a05:600c:46ca:b0:458:a992:6f1e with SMTP id 5b1f17b1804b1-45f211c4c8bmr71741495e9.5.1757751080047; Sat, 13 Sep 2025 01:11:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Zhao Liu Subject: [PULL 34/61] rust: move Cell vmstate impl Date: Sat, 13 Sep 2025 10:09:15 +0200 Message-ID: <20250913080943.11710-35-pbonzini@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250913080943.11710-1-pbonzini@redhat.com> References: <20250913080943.11710-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1757751223687116600 From: Marc-Andr=C3=A9 Lureau This will allow to split vmstate to a standalone crate next. Signed-off-by: Marc-Andr=C3=A9 Lureau Link: https://lore.kernel.org/r/20250827104147.717203-10-marcandre.lureau@r= edhat.com Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/cell.rs | 6 +++++- rust/qemu-api/src/vmstate.rs | 14 +++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/rust/qemu-api/src/cell.rs b/rust/qemu-api/src/cell.rs index 148a13e3f56..9943d7286b6 100644 --- a/rust/qemu-api/src/cell.rs +++ b/rust/qemu-api/src/cell.rs @@ -221,7 +221,7 @@ ptr::NonNull, }; =20 -use crate::bindings; +use crate::{bindings, impl_vmstate_transparent}; =20 /// An internal function that is used by doctests. pub fn bql_start_test() { @@ -456,6 +456,8 @@ pub fn take(&self) -> T { } } =20 +impl_vmstate_transparent!(crate::cell::BqlCell where T: VMState); + /// A mutable memory location with dynamically checked borrow rules, /// protected by the Big QEMU Lock. /// @@ -764,6 +766,8 @@ fn from(t: T) -> BqlRefCell { } } =20 +impl_vmstate_transparent!(crate::cell::BqlRefCell where T: VMState); + struct BorrowRef<'b> { borrow: &'b Cell, } diff --git a/rust/qemu-api/src/vmstate.rs b/rust/qemu-api/src/vmstate.rs index 4e1086779ac..ce42b031bc1 100644 --- a/rust/qemu-api/src/vmstate.rs +++ b/rust/qemu-api/src/vmstate.rs @@ -124,7 +124,8 @@ pub const fn vmstate_varray_flag(_: Phantom= Data) -> VMStateFlags /// * scalar types (integer and `bool`) /// * the C struct `QEMUTimer` /// * a transparent wrapper for any of the above (`Cell`, `UnsafeCell`, -/// [`BqlCell`], [`BqlRefCell`] +/// [`BqlCell`](crate::cell::BqlCell), +/// [`BqlRefCell`](crate::cell::BqlRefCell)), /// * a raw pointer to any of the above /// * a `NonNull` pointer, a `Box` or an [`Owned`](crate::qom::Owned) for = any of /// the above @@ -254,14 +255,15 @@ unsafe impl $crate::vmstate::VMState for $tuple { =20 // Transparent wrappers: just use the internal type =20 +#[macro_export] macro_rules! impl_vmstate_transparent { ($type:ty where $base:tt: VMState $($where:tt)*) =3D> { - unsafe impl<$base> VMState for $type where $base: VMState $($where= )* { - const BASE: VMStateField =3D VMStateField { + unsafe impl<$base> $crate::vmstate::VMState for $type where $base:= $crate::vmstate::VMState $($where)* { + const BASE: $crate::vmstate::VMStateField =3D $crate::vmstate:= :VMStateField { size: mem::size_of::<$type>(), - ..<$base as VMState>::BASE + ..<$base as $crate::vmstate::VMState>::BASE }; - const VARRAY_FLAG: VMStateFlags =3D <$base as VMState>::VARRAY= _FLAG; + const VARRAY_FLAG: $crate::bindings::VMStateFlags =3D <$base a= s $crate::vmstate::VMState>::VARRAY_FLAG; } }; } @@ -269,8 +271,6 @@ unsafe impl<$base> VMState for $type where $base: VMSta= te $($where)* { impl_vmstate_transparent!(std::cell::Cell where T: VMState); impl_vmstate_transparent!(std::cell::UnsafeCell where T: VMState); impl_vmstate_transparent!(std::pin::Pin where T: VMState); -impl_vmstate_transparent!(crate::cell::BqlCell where T: VMState); -impl_vmstate_transparent!(crate::cell::BqlRefCell where T: VMState); impl_vmstate_transparent!(crate::cell::Opaque where T: VMState); =20 #[macro_export] --=20 2.51.0