From nobody Tue Dec 24 03:08:15 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1734597255; cv=none; d=zohomail.com; s=zohoarc; b=Rrb1aABQOvLDJ/YTJVQfP1prJ5mPNVHfs56QmOk9817FWBiD9ltO0tRVfSz5hMK0TOoWdsVCSlRhcAXZabB1yD/E/w1mIWRUf4Vh38EimtczIEdzDqaNhvS06LwQPJqWGJ3+Nrs0pPTbAEhOgeJ1JWe7DMlC2Le2NhoqicJuZM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734597255; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4JuCYauHZuFnfd9+PJ8lQTIeKVe3Bn39qjIyqWPL2KU=; b=Vwh7PfDokvDIZ9g0OGTy1vsn+FWY0Pznq4kkHbtWXnDNxNFWRNvO6rEIa44EhdzGi6EKkjfAIzOaNSxprN+95Dd3YyyLIn6CVpiX3HUAzeS59T62zgxQoFUwoJBasiXWzhysX4tpWw5ffvZzH1Xv5KGfH9+ckLImjsO9vNw/EkQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734597255970769.6685940296959; Thu, 19 Dec 2024 00:34:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOByU-0005jz-W4; Thu, 19 Dec 2024 03:33:39 -0500 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 1tOByT-0005fO-1N for qemu-devel@nongnu.org; Thu, 19 Dec 2024 03:33:37 -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 1tOByQ-0005Du-Or for qemu-devel@nongnu.org; Thu, 19 Dec 2024 03:33:36 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-CcSkPH6mN1CCV8fSMWx3CQ-1; Thu, 19 Dec 2024 03:33:32 -0500 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-386321c8f4bso302867f8f.0 for ; Thu, 19 Dec 2024 00:33:31 -0800 (PST) Received: from [192.168.10.47] ([151.81.118.45]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8acafesm970774f8f.98.2024.12.19.00.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 00:33:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734597213; 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=4JuCYauHZuFnfd9+PJ8lQTIeKVe3Bn39qjIyqWPL2KU=; b=P/WaJtQn21dp25QQZIBlQDX0tl99P5GxL+NO5GZrLYNJF5qfbNq9DFcpbjTHstiRBKGtg0 dxqGwZyZbkj0rA3fjY5W68pzxGQtg3K4gL25/JS3p9KH53Diwy/mlabbNKfMeFRBpoBt06 53d77LQr/WOvB4tSJRRE/ULh+X+iGzQ= X-MC-Unique: CcSkPH6mN1CCV8fSMWx3CQ-1 X-Mimecast-MFC-AGG-ID: CcSkPH6mN1CCV8fSMWx3CQ X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734597210; x=1735202010; 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=4JuCYauHZuFnfd9+PJ8lQTIeKVe3Bn39qjIyqWPL2KU=; b=jUDK5tptBBn2p/FzWO6XTRPAKtFNaMdA1gdjBY3WbleHwGrOD+PeQsLDpCLFUA4wIn iyAz/559MBndIBKhoAb9aa6VRbRFTYr8FSLle8U12c8gSpTrVQOyXNesDLIZqxpUqg6p ooPjjQ7HVJ3YAwJzm1bkhGztwAaPeU32iAywayeLWpUWO7bSJdZ6sVwzQC2ZyOgudTrC 6dqNkxBYhYyEiM1k+L2/nj8NL2MphFEZj/IePJsUo3C38JjlkDIF2yAcNJEm6Doc+tjD GTs/QZstTrCqQTx/Z89Pnh+m6jf38Rvl2IXXdn1kMiLVn9QMOCMdsZAOa+nP+j7U2V8/ w/gw== X-Gm-Message-State: AOJu0Yxa4G1Z8SZq+ThAwzz/Y905nN1dfoQaanJFaEy+tCwYMdKP5rZX BezWEf+Xjc3pH4LvUQ7xU+HZICo99JN2DZWeM/NRG7XTeb3QdwetszYc2l/Ss11sUz3nFUjjnvA eHGbX0sgTDcOzPa6DxH7L1hKUa3tyu94HUVyw6IoGinppIcYBfUBfM7nXt34uANBQxBn7ALw90j u0ArndOc+dh0Tb5E/I2QvYZhx4BaQi43D7EacF X-Gm-Gg: ASbGncuiX0WxRVRhRfK7d/Gtb6P7uiGWjKFUrlSCPo/jawCcxcrWVlXVnrP2kOPV3fx Mj0skgPrKB6kleiXZ62VKtkIjZeofAd59awRvF+hZTGiG6WbbDV77U6u92dUmVNBVpTwXk5z4My 1Wgna4XtHac32xPXQP/ot5HDEn5oGEQUkN/YLUmHjJ77WPBGMgAsoJWBug7hHutBj0xgUIuAk2s NIhyAsbdbPos6kCnIxZnlCltnE+jXIQga6IDv+3tiMq6AvBR+/hXyUyZ4a2 X-Received: by 2002:a5d:47af:0:b0:385:de8d:c0f5 with SMTP id ffacd0b85a97d-388e4d4b5e8mr4911222f8f.16.1734597210486; Thu, 19 Dec 2024 00:33:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCH2Sctnuu7aGZPs2XpMPyb9Nn96mjbdMPHxCk+jTiB/GWlKVrw6q6pgPd9/vjLKx3a16BlQ== X-Received: by 2002:a5d:47af:0:b0:385:de8d:c0f5 with SMTP id ffacd0b85a97d-388e4d4b5e8mr4911193f8f.16.1734597209981; Thu, 19 Dec 2024 00:33:29 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PULL 28/41] rust: re-export C types from qemu-api submodules Date: Thu, 19 Dec 2024 09:32:15 +0100 Message-ID: <20241219083228.363430-29-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241219083228.363430-1-pbonzini@redhat.com> References: <20241219083228.363430-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 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_H2=-1.116, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1734597257156116600 Content-Type: text/plain; charset="utf-8" Long term we do not want device code to use "bindings" at all, so make it possible to get the relevant types from the other modules of qemu-api. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini --- rust/qemu-api/src/qdev.rs | 7 +++++-- rust/qemu-api/src/qom.rs | 12 +++++++----- rust/qemu-api/src/sysbus.rs | 5 +---- rust/qemu-api/src/vmstate.rs | 9 +++++---- rust/qemu-api/tests/tests.rs | 9 +++++++-- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/rust/qemu-api/src/qdev.rs b/rust/qemu-api/src/qdev.rs index ad4c12d097e..07a502a8371 100644 --- a/rust/qemu-api/src/qdev.rs +++ b/rust/qemu-api/src/qdev.rs @@ -6,10 +6,13 @@ =20 use std::ffi::CStr; =20 +pub use bindings::{DeviceClass, DeviceState, Property}; + use crate::{ - bindings::{self, DeviceClass, DeviceState, Error, ObjectClass, Propert= y, VMStateDescription}, + bindings::{self, Error}, prelude::*, - qom::ClassInitImpl, + qom::{ClassInitImpl, ObjectClass}, + vmstate::VMStateDescription, }; =20 /// Trait providing the contents of [`DeviceClass`]. diff --git a/rust/qemu-api/src/qom.rs b/rust/qemu-api/src/qom.rs index 2222d1a5ab9..a663647ffe5 100644 --- a/rust/qemu-api/src/qom.rs +++ b/rust/qemu-api/src/qom.rs @@ -33,7 +33,9 @@ =20 use std::{ffi::CStr, os::raw::c_void}; =20 -use crate::bindings::{self, Object, ObjectClass, TypeInfo}; +pub use bindings::{Object, ObjectClass}; + +use crate::bindings::{self, TypeInfo}; =20 unsafe extern "C" fn rust_instance_init(obj: *mut Object) { // SAFETY: obj is an instance of T, since rust_instance_init @@ -164,9 +166,9 @@ pub trait ObjectImpl: ObjectType + ClassInitImpl { /// /// Each struct will implement this trait with `T` equal to each /// superclass. For example, a device should implement at least -/// `ClassInitImpl<`[`DeviceClass`](crate::bindings::DeviceClass)`>` and -/// `ClassInitImpl<`[`ObjectClass`](crate::bindings::ObjectClass)`>`. -/// Such implementations are made in one of two ways. +/// `ClassInitImpl<`[`DeviceClass`](crate::qdev::DeviceClass)`>` and +/// `ClassInitImpl<`[`ObjectClass`]`>`. Such implementations are made +/// in one of two ways. /// /// For most superclasses, `ClassInitImpl` is provided by the `qemu-api` /// crate itself. The Rust implementation of methods will come from a @@ -221,7 +223,7 @@ pub trait ClassInitImpl { /// /// The virtual method implementations usually come from another /// trait, for example [`DeviceImpl`](crate::qdev::DeviceImpl) - /// when `T` is [`DeviceClass`](crate::bindings::DeviceClass). + /// when `T` is [`DeviceClass`](crate::qdev::DeviceClass). /// /// On entry, `klass`'s parent class is initialized, while the other f= ields /// are all zero; it is therefore assumed that all fields in `T` can be diff --git a/rust/qemu-api/src/sysbus.rs b/rust/qemu-api/src/sysbus.rs index fa69cadd7c1..9abc687a261 100644 --- a/rust/qemu-api/src/sysbus.rs +++ b/rust/qemu-api/src/sysbus.rs @@ -7,10 +7,7 @@ pub use bindings::{SysBusDevice, SysBusDeviceClass}; =20 use crate::{ - bindings::{self, DeviceClass}, - cell::bql_locked, - irq::InterruptSource, - prelude::*, + bindings, cell::bql_locked, irq::InterruptSource, prelude::*, qdev::De= viceClass, qom::ClassInitImpl, }; =20 diff --git a/rust/qemu-api/src/vmstate.rs b/rust/qemu-api/src/vmstate.rs index bedcf1e8f39..25c68b703ea 100644 --- a/rust/qemu-api/src/vmstate.rs +++ b/rust/qemu-api/src/vmstate.rs @@ -10,6 +10,8 @@ //! [`vmstate_fields`](crate::vmstate_fields) are meant to be used when //! declaring a device model state struct. =20 +pub use crate::bindings::VMStateDescription; + #[doc(alias =3D "VMSTATE_UNUSED_BUFFER")] #[macro_export] macro_rules! vmstate_unused_buffer { @@ -328,7 +330,7 @@ macro_rules! vmstate_fields { } =20 /// A transparent wrapper type for the `subsections` field of -/// [`VMStateDescription`](crate::bindings::VMStateDescription). +/// [`VMStateDescription`]. /// /// This is necessary to be able to declare subsection descriptions as sta= tics, /// because the only way to implement `Sync` for a foreign type (and `*con= st` @@ -342,9 +344,8 @@ macro_rules! vmstate_fields { =20 unsafe impl Sync for VMStateSubsectionsWrapper {} =20 -/// Helper macro to declare a list of subsections -/// ([`VMStateDescription`](`crate::bindings::VMStateDescription`)) into a -/// static and return a pointer to the array of pointers it created. +/// Helper macro to declare a list of subsections ([`VMStateDescription`]) +/// into a static and return a pointer to the array of pointers it created. #[macro_export] macro_rules! vmstate_subsections { ($($subsection:expr),*$(,)*) =3D> {{ diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index 78f7da474b2..68557fb85c7 100644 --- a/rust/qemu-api/tests/tests.rs +++ b/rust/qemu-api/tests/tests.rs @@ -5,8 +5,13 @@ use std::ffi::CStr; =20 use qemu_api::{ - bindings::*, c_str, declare_properties, define_property, prelude::*, q= dev::DeviceImpl, - qom::ObjectImpl, zeroable::Zeroable, + bindings::*, + c_str, declare_properties, define_property, + prelude::*, + qdev::{DeviceImpl, DeviceState, Property}, + qom::ObjectImpl, + vmstate::VMStateDescription, + zeroable::Zeroable, }; =20 #[test] --=20 2.47.1