From nobody Sat Nov 23 18:11:20 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=1729872525; cv=none; d=zohomail.com; s=zohoarc; b=TIrb9PGfsOpgO+c9+M8u9nt0J5618m9egfn32Boi1/tV3io1Y7PeP1ZtOEVpOHQCXRC0C0xgDFZ0PlFyUCpDiSGyc2iD1hT6G53YpjU2caixM6Ubp4zAyPuRXs1N8lBR9VImJyLrAY2YRKpAl3wIzJmhVl1gy3UZW0OoODE6MPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872525; 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=bR3ljwoua+BmkjVrnec06qs6BRRUBdBk6Ij0MIixeNc=; b=hxBakBj4h17lgD/QlNCHcQHeracWiN3k/wXwZfY5GaWCXx+nEQpW8Qh/1i/H9Zq/3zdlYOWYyVEEGdSWAmm3vbLdWWKrUiT2dDtG+2EwmITLfB1bbfRm69hz4K/GpVS6xrnjiKV7DTMGgFmJspSG6SQ17nNktyYANF/2WM3dYn0= 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 1729872525542139.09608504745006; Fri, 25 Oct 2024 09:08:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mll-0001JZ-Ee; Fri, 25 Oct 2024 12:02:33 -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 1t4Mlf-0000zf-Nq for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:02:27 -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 1t4Mlc-0004lD-RZ for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:02:27 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-421-3pET7ECnM9yEWLJnkkZeNQ-1; Fri, 25 Oct 2024 12:02:21 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a99cb787d2cso165895366b.2 for ; Fri, 25 Oct 2024 09:02:21 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f0679bdsm84671866b.91.2024.10.25.09.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872143; 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=bR3ljwoua+BmkjVrnec06qs6BRRUBdBk6Ij0MIixeNc=; b=dSSOgSF1zq+vMLLd0wCAIZH2WwGknqdbeFTYVRbOSV2Twr4t4J9yzZhM4we23gqa3jrgDz a3asLCyTZn4AAK73uE+Y7eqi1OgSlbbaKWijW/emDANDf5Cw4weB8ANzb2EX3iOsirZ3EJ QdaYHhDNQi8nFKEjgq6krpFZQ0grzH4= X-MC-Unique: 3pET7ECnM9yEWLJnkkZeNQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872139; x=1730476939; 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=bR3ljwoua+BmkjVrnec06qs6BRRUBdBk6Ij0MIixeNc=; b=hi0gjEltD6pxDbl688v9zLgZUdazGOH9wVCPMXdNsmn6ENKS6FKuw6H/opFYDwGLZA hwEBj56G8f7nPNbAqw22AP87TcaN9oKWGeVhqR/ZVT4HgbLfXiItkxtCly4STmeXwLdV UkO7GFEKbTuY55UnG5eFFvQWgeYIYfBtR2OycoGx2azD92/JphGle4U3SG8qyKmrfiJH Ql0hgDPZdqEVNKMbdV3P68Emz7bze1mXQtE270ydIaiY6VY60hqVCqErIS2G8MSDabo9 dtSl2g2TAeZmE/OQegu+bYf+wyD/+MmTbEnlOuozBabWR8PZZdev8Et7NX/Euv0qBXe3 Ixpw== X-Gm-Message-State: AOJu0YxWM/RXgo+vEeiPFe7ISAjvJn67t7vhAH0o6O2auMPn51/QxTj2 NNCSm9IbrgcD5VjnHyaOUMrtl5BiDd9UVJsdHod3KoPrMNXn8bwYVEgxDHei0pbHWetH3uxgUTn HrGm71YXiKPqzI1VcdoN+p0l3AFzBV5ZlSZ/kaljIX7OFbDbLHEDIGSt1jp+Q17KVa6Fe3Mqc4A Mg/4NCCVO4QyDUKG4ZwJHzIMsdYKveJCyDp9+/yLk= X-Received: by 2002:a17:907:1ca1:b0:a9a:2afc:e4ed with SMTP id a640c23a62f3a-a9abf8a4105mr976874666b.32.1729872139075; Fri, 25 Oct 2024 09:02:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYGrx1hoaoeoy6HB/4SSFDSdFrbU7s91fwNzSiAxIOAoTNpQkdUuucJ/eh8K/GWhgUsVgNrw== X-Received: by 2002:a17:907:1ca1:b0:a9a:2afc:e4ed with SMTP id a640c23a62f3a-a9abf8a4105mr976866466b.32.1729872138349; Fri, 25 Oct 2024 09:02:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 01/23] rust: add definitions for vmstate Date: Fri, 25 Oct 2024 18:01:46 +0200 Message-ID: <20241025160209.194307-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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.697, 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: 1729872527797116600 Content-Type: text/plain; charset="utf-8" From: Manos Pitsidianakis Add a new qemu_api module, `vmstate`. Declare a bunch of Rust macros declared that are equivalent in spirit to the C macros in include/migration/vmstate.h. For example the Rust of equivalent of the C macro: VMSTATE_UINT32(field_name, struct_name) is: vmstate_uint32!(field_name, StructName) This breathtaking development will allow us to reach feature parity between the Rust and C pl011 implementations. Extracted from a patch by Manos Pitsidianakis. Signed-off-by: Manos Pitsidianakis Signed-off-by: Paolo Bonzini Tested-by: Zhao Liu --- rust/qemu-api/meson.build | 1 + rust/qemu-api/src/device_class.rs | 21 -- rust/qemu-api/src/lib.rs | 3 + rust/qemu-api/src/vmstate.rs | 358 ++++++++++++++++++++++++++++++ rust/qemu-api/tests/tests.rs | 11 +- 5 files changed, 368 insertions(+), 26 deletions(-) create mode 100644 rust/qemu-api/src/vmstate.rs diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 1b0fd406378..3b849f7c413 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -5,6 +5,7 @@ _qemu_api_rs =3D static_library( 'src/lib.rs', 'src/definitions.rs', 'src/device_class.rs', + 'src/vmstate.rs', 'src/zeroable.rs', ], {'.' : bindings_rs}, diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index aa6088d9d3d..3d40256f60f 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -62,24 +62,3 @@ macro_rules! declare_properties { ]; }; } - -#[macro_export] -macro_rules! vm_state_description { - ($(#[$outer:meta])* - $name:ident, - $(name: $vname:expr,)* - $(unmigratable: $um_val:expr,)* - ) =3D> { - #[used] - $(#[$outer])* - pub static $name: $crate::bindings::VMStateDescription =3D $crate:= :bindings::VMStateDescription { - $(name: { - #[used] - static VMSTATE_NAME: &::core::ffi::CStr =3D $vname; - $vname.as_ptr() - },)* - unmigratable: true, - ..$crate::zeroable::Zeroable::ZERO - }; - } -} diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index e94a15bb823..10ab3d7e639 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -26,9 +26,12 @@ unsafe impl Send for bindings::Property {} unsafe impl Sync for bindings::Property {} unsafe impl Sync for bindings::TypeInfo {} unsafe impl Sync for bindings::VMStateDescription {} +unsafe impl Sync for bindings::VMStateField {} +unsafe impl Sync for bindings::VMStateInfo {} =20 pub mod definitions; pub mod device_class; +pub mod vmstate; pub mod zeroable; =20 use std::alloc::{GlobalAlloc, Layout}; diff --git a/rust/qemu-api/src/vmstate.rs b/rust/qemu-api/src/vmstate.rs new file mode 100644 index 00000000000..3aa6ed2a781 --- /dev/null +++ b/rust/qemu-api/src/vmstate.rs @@ -0,0 +1,358 @@ +// Copyright 2024, Linaro Limited +// Author(s): Manos Pitsidianakis +// SPDX-License-Identifier: GPL-2.0-or-later + +//! Helper macros to declare migration state for device models. +//! +//! Some macros are direct equivalents to the C macros declared in +//! `include/migration/vmstate.h` while [`vmstate_subsections`] and +//! [`vmstate_fields`] are meant to be used when declaring a device model = state +//! struct. + +#[doc(alias =3D "VMSTATE_UNUSED_BUFFER")] +#[macro_export] +macro_rules! vmstate_unused_buffer { + ($field_exists_fn:expr, $version_id:expr, $size:expr) =3D> {{ + $crate::bindings::VMStateField { + name: c"unused".as_ptr(), + err_hint: ::core::ptr::null(), + offset: 0, + size: $size, + start: 0, + num: 0, + num_offset: 0, + size_offset: 0, + info: unsafe { ::core::ptr::addr_of!($crate::bindings::vmstate= _info_unused_buffer) }, + flags: VMStateFlags::VMS_BUFFER, + vmsd: ::core::ptr::null(), + version_id: $version_id, + struct_version_id: 0, + field_exists: $field_exists_fn, + } + }}; +} + +#[doc(alias =3D "VMSTATE_UNUSED_V")] +#[macro_export] +macro_rules! vmstate_unused_v { + ($version_id:expr, $size:expr) =3D> {{ + $crate::vmstate_unused_buffer!(None, $version_id, $size) + }}; +} + +#[doc(alias =3D "VMSTATE_UNUSED")] +#[macro_export] +macro_rules! vmstate_unused { + ($size:expr) =3D> {{ + $crate::vmstate_unused_v!(0, $size) + }}; +} + +#[doc(alias =3D "VMSTATE_SINGLE_TEST")] +#[macro_export] +macro_rules! vmstate_single_test { + ($field_name:ident, $struct_name:ty, $field_exists_fn:expr, $version_i= d:expr, $info:block, $size:expr) =3D> {{ + $crate::bindings::VMStateField { + name: ::core::concat!(::core::stringify!($field_name), 0) + .as_bytes() + .as_ptr() as *const ::core::ffi::c_char, + err_hint: ::core::ptr::null(), + offset: ::core::mem::offset_of!($struct_name, $field_name), + size: $size, + start: 0, + num: 0, + num_offset: 0, + size_offset: 0, + info: $info, + flags: VMStateFlags::VMS_SINGLE, + vmsd: ::core::ptr::null(), + version_id: $version_id, + struct_version_id: 0, + field_exists: $field_exists_fn, + } + }}; +} + +#[doc(alias =3D "VMSTATE_SINGLE")] +#[macro_export] +macro_rules! vmstate_single { + ($field_name:ident, $struct_name:ty, $version_id:expr, $info:block, $s= ize:expr) =3D> {{ + $crate::vmstate_single_test!($field_name, $struct_name, None, $ver= sion_id, $info, $size) + }}; +} + +#[doc(alias =3D "VMSTATE_UINT32_V")] +#[macro_export] +macro_rules! vmstate_uint32_v { + ($field_name:ident, $struct_name:ty, $version_id:expr) =3D> {{ + $crate::vmstate_single!( + $field_name, + $struct_name, + $version_id, + { unsafe { ::core::ptr::addr_of!($crate::bindings::vmstate_inf= o_uint32) } }, + ::core::mem::size_of::() + ) + }}; +} + +#[doc(alias =3D "VMSTATE_UINT32")] +#[macro_export] +macro_rules! vmstate_uint32 { + ($field_name:ident, $struct_name:ty) =3D> {{ + $crate::vmstate_uint32_v!($field_name, $struct_name, 0) + }}; +} + +#[doc(alias =3D "VMSTATE_INT32_V")] +#[macro_export] +macro_rules! vmstate_int32_v { + ($field_name:ident, $struct_name:ty, $version_id:expr) =3D> {{ + $crate::vmstate_single!( + $field_name, + $struct_name, + $version_id, + { unsafe { ::core::ptr::addr_of!($crate::bindings::vmstate_inf= o_int32) } }, + ::core::mem::size_of::() + ) + }}; +} + +#[doc(alias =3D "VMSTATE_INT32")] +#[macro_export] +macro_rules! vmstate_int32 { + ($field_name:ident, $struct_name:ty) =3D> {{ + $crate::vmstate_int32_v!($field_name, $struct_name, 0) + }}; +} + +#[doc(alias =3D "VMSTATE_ARRAY")] +#[macro_export] +macro_rules! vmstate_array { + ($field_name:ident, $struct_name:ty, $length:expr, $version_id:expr, $= info:block, $size:expr) =3D> {{ + $crate::bindings::VMStateField { + name: ::core::concat!(::core::stringify!($field_name), 0) + .as_bytes() + .as_ptr() as *const ::core::ffi::c_char, + err_hint: ::core::ptr::null(), + offset: ::core::mem::offset_of!($struct_name, $field_name), + size: $size, + start: 0, + num: $length as _, + num_offset: 0, + size_offset: 0, + info: $info, + flags: VMStateFlags::VMS_ARRAY, + vmsd: ::core::ptr::null(), + version_id: $version_id, + struct_version_id: 0, + field_exists: None, + } + }}; +} + +#[doc(alias =3D "VMSTATE_UINT32_ARRAY_V")] +#[macro_export] +macro_rules! vmstate_uint32_array_v { + ($field_name:ident, $struct_name:ty, $length:expr, $version_id:expr) = =3D> {{ + $crate::vmstate_array!( + $field_name, + $struct_name, + $length, + $version_id, + { unsafe { ::core::ptr::addr_of!($crate::bindings::vmstate_inf= o_uint32) } }, + ::core::mem::size_of::() + ) + }}; +} + +#[doc(alias =3D "VMSTATE_UINT32_ARRAY")] +#[macro_export] +macro_rules! vmstate_uint32_array { + ($field_name:ident, $struct_name:ty, $length:expr) =3D> {{ + $crate::vmstate_uint32_array_v!($field_name, $struct_name, $length= , 0) + }}; +} + +#[doc(alias =3D "VMSTATE_STRUCT_POINTER_V")] +#[macro_export] +macro_rules! vmstate_struct_pointer_v { + ($field_name:ident, $struct_name:ty, $version_id:expr, $vmsd:expr, $ty= pe:ty) =3D> {{ + $crate::bindings::VMStateField { + name: ::core::concat!(::core::stringify!($field_name), 0) + .as_bytes() + .as_ptr() as *const ::core::ffi::c_char, + err_hint: ::core::ptr::null(), + offset: ::core::mem::offset_of!($struct_name, $field_name), + size: ::core::mem::size_of::<*const $type>(), + start: 0, + num: 0, + num_offset: 0, + size_offset: 0, + info: ::core::ptr::null(), + flags: VMStateFlags(VMStateFlags::VMS_STRUCT.0 | VMStateFlags:= :VMS_POINTER.0), + vmsd: $vmsd, + version_id: $version_id, + struct_version_id: 0, + field_exists: None, + } + }}; +} + +#[doc(alias =3D "VMSTATE_ARRAY_OF_POINTER")] +#[macro_export] +macro_rules! vmstate_array_of_pointer { + ($field_name:ident, $struct_name:ty, $num:expr, $version_id:expr, $inf= o:expr, $type:ty) =3D> {{ + $crate::bindings::VMStateField { + name: ::core::concat!(::core::stringify!($field_name), 0) + .as_bytes() + .as_ptr() as *const ::core::ffi::c_char, + version_id: $version_id, + num: $num as _, + info: $info, + size: ::core::mem::size_of::<*const $type>(), + flags: VMStateFlags(VMStateFlags::VMS_ARRAY.0 | VMStateFlags::= VMS_ARRAY_OF_POINTER.0), + offset: ::core::mem::offset_of!($struct_name, $field_name), + err_hint: ::core::ptr::null(), + start: 0, + num_offset: 0, + size_offset: 0, + vmsd: ::core::ptr::null(), + struct_version_id: 0, + field_exists: None, + } + }}; +} + +#[doc(alias =3D "VMSTATE_ARRAY_OF_POINTER_TO_STRUCT")] +#[macro_export] +macro_rules! vmstate_array_of_pointer_to_struct { + ($field_name:ident, $struct_name:ty, $num:expr, $version_id:expr, $vms= d:expr, $type:ty) =3D> {{ + $crate::bindings::VMStateField { + name: ::core::concat!(::core::stringify!($field_name), 0) + .as_bytes() + .as_ptr() as *const ::core::ffi::c_char, + version_id: $version_id, + num: $num as _, + vmsd: $vmsd, + size: ::core::mem::size_of::<*const $type>(), + flags: VMStateFlags( + VMStateFlags::VMS_ARRAY.0 + | VMStateFlags::VMS_STRUCT.0 + | VMStateFlags::VMS_ARRAY_OF_POINTER.0, + ), + offset: ::core::mem::offset_of!($struct_name, $field_name), + err_hint: ::core::ptr::null(), + start: 0, + num_offset: 0, + size_offset: 0, + vmsd: ::core::ptr::null(), + struct_version_id: 0, + field_exists: None, + } + }}; +} + +#[doc(alias =3D "VMSTATE_CLOCK_V")] +#[macro_export] +macro_rules! vmstate_clock_v { + ($field_name:ident, $struct_name:ty, $version_id:expr) =3D> {{ + $crate::vmstate_struct_pointer_v!( + $field_name, + $struct_name, + $version_id, + { unsafe { ::core::ptr::addr_of!($crate::bindings::vmstate_clo= ck) } }, + $crate::bindings::Clock + ) + }}; +} + +#[doc(alias =3D "VMSTATE_CLOCK")] +#[macro_export] +macro_rules! vmstate_clock { + ($field_name:ident, $struct_name:ty) =3D> {{ + $crate::vmstate_clock_v!($field_name, $struct_name, 0) + }}; +} + +#[doc(alias =3D "VMSTATE_ARRAY_CLOCK_V")] +#[macro_export] +macro_rules! vmstate_array_clock_v { + ($field_name:ident, $struct_name:ty, $num:expr, $version_id:expr) =3D>= {{ + $crate::vmstate_array_of_pointer_to_struct!( + $field_name, + $struct_name, + $num, + $version_id, + { unsafe { ::core::ptr::addr_of!($crate::bindings::vmstate_clo= ck) } }, + $crate::bindings::Clock + ) + }}; +} + +#[doc(alias =3D "VMSTATE_ARRAY_CLOCK")] +#[macro_export] +macro_rules! vmstate_array_clock { + ($field_name:ident, $struct_name:ty, $num:expr) =3D> {{ + $crate::vmstate_array_clock_v!($field_name, $struct_name, $name, 0) + }}; +} + +/// Helper macro to declare a list of +/// ([`VMStateField`](`crate::bindings::VMStateField`)) into a static and = return +/// a pointer to the array of values it created. +#[macro_export] +macro_rules! vmstate_fields { + ($($field:expr),*$(,)*) =3D> {{ + static _FIELDS: &[$crate::bindings::VMStateField] =3D &[ + $($field),*, + $crate::bindings::VMStateField { + name: ::core::ptr::null(), + err_hint: ::core::ptr::null(), + offset: 0, + size: 0, + start: 0, + num: 0, + num_offset: 0, + size_offset: 0, + info: ::core::ptr::null(), + flags: VMStateFlags::VMS_END, + vmsd: ::core::ptr::null(), + version_id: 0, + struct_version_id: 0, + field_exists: None, + } + ]; + _FIELDS.as_ptr() + }} +} + +/// A transparent wrapper type for the `subsections` field of +/// [`VMStateDescription`](crate::bindings::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` +/// pointers are foreign types in Rust) is to create a wrapper struct and +/// `unsafe impl Sync` for it. +/// +/// This struct is used in the [`vmstate_subsections`] macro implementatio= n. +#[repr(transparent)] +pub struct VMStateSubsectionsWrapper(pub &'static [*const crate::bindings:= :VMStateDescription]); + +unsafe impl Sync for VMStateSubsectionsWrapper {} + +/// 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. +#[macro_export] +macro_rules! vmstate_subsections { + ($($subsection:expr),*$(,)*) =3D> {{ + static _SUBSECTIONS: $crate::vmstate::VMStateSubsectionsWrapper = =3D $crate::vmstate::VMStateSubsectionsWrapper(&[ + $({ + static _SUBSECTION: $crate::bindings::VMStateDescription = =3D $subsection; + ::core::ptr::addr_of!(_SUBSECTION) + }),*, + ::core::ptr::null() + ]); + _SUBSECTIONS.0.as_ptr() + }} +} diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index aa1e0568c69..37c4dd44f81 100644 --- a/rust/qemu-api/tests/tests.rs +++ b/rust/qemu-api/tests/tests.rs @@ -8,17 +8,18 @@ bindings::*, declare_properties, define_property, definitions::{Class, ObjectImpl}, - device_class_init, vm_state_description, + device_class_init, + zeroable::Zeroable, }; =20 #[test] fn test_device_decl_macros() { // Test that macros can compile. - vm_state_description! { - VMSTATE, - name: c"name", + pub static VMSTATE: VMStateDescription =3D VMStateDescription { + name: c"name".as_ptr(), unmigratable: true, - } + ..Zeroable::ZERO + }; =20 #[repr(C)] #[derive(qemu_api_macros::Object)] --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872188; cv=none; d=zohomail.com; s=zohoarc; b=mFbaOBjfDxYzRjOZqlOlgDJdFC+ITH4zMZ/Ihg3+2TWfBJhwF/ESIsfFhpb0ICbu57TbSpG5Ie0z0ug7PoMoWSR/fNsLClpphPTF2MCpchDZTqVArpB2dsgtOO2wsj98tios6DULAC6h2AkhgUwGa3i4Oj5I/xHULWdkrxrwAoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872188; 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=/I8P+Tgh/EAn+u3w8+IqULH94EfyesPkxVcOlTYfu04=; b=oL3fGG9xN3EMBaRfa0ptUZo5lJ0fXiiL5UyYUOhtCc1UGq4CkIbyURRD3BsGhfBfA0xahPmv3tBdmt39q77+YYaRI2XmepPb6jbfkKc8VZ8nvei16rDeMlwszcTf/uIEj9N5wAlOeeK3YcV5VUndNQMmw0OHNE8hS0hazdYio+k= 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 1729872188935142.36580845492824; Fri, 25 Oct 2024 09:03:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mlm-0001Rq-W2; Fri, 25 Oct 2024 12:02:35 -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 1t4Mlg-00012b-Kx for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:02:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4Mle-0004lZ-W8 for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:02:28 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-528-vY2DUq66NWuI786Jo_ZkHA-1; Fri, 25 Oct 2024 12:02:24 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a9a22a62e80so163728366b.1 for ; Fri, 25 Oct 2024 09:02:24 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b3a086de0sm84191566b.218.2024.10.25.09.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872146; 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=/I8P+Tgh/EAn+u3w8+IqULH94EfyesPkxVcOlTYfu04=; b=YzL3+4OAQA98lTBgkcFiKHzbnCOkpv2KLkxDdjnkxKPhXPAUT9+B4MogcLNtk4Arki652w vflsg8LGyYsAQgjjYRGdsbvAGqrAyzoEQnNwGQAacWeN9AXcPGM7tdKV4fZxkfKDIE/KI2 9bBXBtdhehNM7VYgcMBy7H9KBilKRyQ= X-MC-Unique: vY2DUq66NWuI786Jo_ZkHA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872142; x=1730476942; 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=/I8P+Tgh/EAn+u3w8+IqULH94EfyesPkxVcOlTYfu04=; b=r/lEJhi1OLPODToPaY2XPRmH4sxrPVWR877jDPDV3LVvpRxCJQblGk3z4tNHpfPyCV iKrbOhK8ObP2MchBZnejZzTDHM3sj/ZxOJmNtquZkvgRHtBzcis+xjAA4irpxFGZwvrC J/Kd6mP/T4vER+h+DhuTk15RfN1IoyXjWPShG0VVuitPMPUBXi9VWptMxr96DDEkY/ZZ wPs7meOVMLtpHkGAcwCC0L68Zri9IrwDwX4GFCybZQ3PonqXAKZkd37kwb+iQkabbpvU HtjAqLUfeiFVt9soAjXao0L7KBnkMN8G4FIAFY5Q6UBwY4dxa/vA+kk49W90GHPiQ27Q ub0A== X-Gm-Message-State: AOJu0Yy2bSzGfunjk4yAYLGg7KkYjoqiKgouusigM4sOFHYDuaS7jGnF RhyqqKaM+mFtZGotoKaOYSWrYE70ZlV6gJGf3ZIDibjY6X0s3lC5EiKB/TSCNxuuS2qP/ye/KdO t6/ssZKZ5OySXHYGZ5yK/ZfEYATxHz5wSQx6SJK4GyoF/vCXKXZJ99Nfc6EJsYi6Lf/DfKgZJAs mkd5nQpI3dCrhprFngKLQWmz+CBlVXWDNUUd+Krvo= X-Received: by 2002:a17:907:3f1e:b0:a9a:161:8da4 with SMTP id a640c23a62f3a-a9ad285f285mr623455566b.55.1729872142330; Fri, 25 Oct 2024 09:02:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9A+WR7gQD8FPzzMqXXrrkVK681k/tGh3Sza9ZGt95DpvEmjkrf34QT/3FiecCFHjQLIRiOA== X-Received: by 2002:a17:907:3f1e:b0:a9a:161:8da4 with SMTP id a640c23a62f3a-a9ad285f285mr623450066b.55.1729872141824; Fri, 25 Oct 2024 09:02:21 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 02/23] rust/pl011: fix default value for migrate-clock Date: Fri, 25 Oct 2024 18:01:47 +0200 Message-ID: <20241025160209.194307-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729872189909116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Tested-by: Zhao Liu --- rust/hw/char/pl011/src/device_class.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rust/hw/char/pl011/src/device_class.rs b/rust/hw/char/pl011/sr= c/device_class.rs index 08c846aa482..9282dc4d151 100644 --- a/rust/hw/char/pl011/src/device_class.rs +++ b/rust/hw/char/pl011/src/device_class.rs @@ -29,7 +29,8 @@ PL011State, migrate_clock, unsafe { &qdev_prop_bool }, - bool + bool, + default =3D true ), } =20 --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872526; cv=none; d=zohomail.com; s=zohoarc; b=fprSj9x3oM+QIKHIj5zb08SSkkjnXyYsLcn1mYLFOrOcLyay9Xw5KyQdTCCyHLl/t43Me53ctbuAbuME0PEa0PXQFl2gHLMOl7lS/aKpC8U78u3I+sfDZI2znOqfx5wqMWMs7QQby+sxJ6wDBR+91aY/7VfFUBqk9EdHkyqd5xE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872526; 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=hYenrZdbFRD95Cc02SvS7HaWNevX9ALocJClM8PQTC8=; b=Z/WWHzpXQxQIBXdYVxibFsQkho41l0MVKFskeN7wbn4TbMvR9NPds/lRMsUFqgMr01iPSWYA00fIhLV5BwhsVIx7fd+ALw5VIma8Dbg8uUcyzdp3KruUAuNcw2kNdSHiEz4sf/z1v49wy6nExfKPZyJ+Gofc41nrgY9X4OmOxdY= 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 1729872526665727.9036279120445; Fri, 25 Oct 2024 09:08:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mln-0001Sx-8L; Fri, 25 Oct 2024 12:02:35 -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 1t4Mlk-0001D6-2s for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:02:32 -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 1t4Mli-0004m5-8z for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:02:31 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-201-mxOG-sIaMYqIZtxJFplhPg-1; Fri, 25 Oct 2024 12:02:27 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a9a1af73615so154493066b.0 for ; Fri, 25 Oct 2024 09:02:27 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f03878bsm85143466b.87.2024.10.25.09.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872149; 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=hYenrZdbFRD95Cc02SvS7HaWNevX9ALocJClM8PQTC8=; b=I5HWimJwBXKGW7mLZgDwcJfO1Y9gHZ4Y2Pzkm9EEoDmuPqNqgtNYiAJ34Ri/mcqG/FA5MK 3VZsY3xSHdre07EHBjv+IAoSmTryhAxj5f/24ztFVWllEZ+zlmdk+UjD+PfT7m15hRqGgE FxNxMX0ectNzht11mYXIX48jn7ZHBek= X-MC-Unique: mxOG-sIaMYqIZtxJFplhPg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872146; x=1730476946; 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=hYenrZdbFRD95Cc02SvS7HaWNevX9ALocJClM8PQTC8=; b=pcHuNVQ6q2CFV6cKtIF38hfv4xrOPULV8tykp+q5NHB4rCF821ykCeOuhSEuvDcPsp 528jSRKDWX0lbWClonGUBjbaEOsiHxvqsEBVRhGgTb+SsdS4yVwIFm4fPQRvBu7umQb3 vwOQB2627B4BdBwnFU+RZ/qBI1zzHm/CdgRDjx2eaoHMbAnPZ0gVRH5m74OnixwJpBhM v4peM8To6YTLoHwRpnHTpQ8Pe0Mh3haIs5wmhyW05Hc3pM0pJI2h5Rb6Vp3hV6wDHWMz scXeeqwOtmpwwjX2kEI798MlCsHerKl7g2cemH8UuAMzJNMH4Hv/S7CIssaZkDmkmLGK IeRg== X-Gm-Message-State: AOJu0Yxe/m2/moEfJ4bORgFBZSMLP5bV0dS4W/L9qsEOVeNlBwLxA4Xt IORbPFVlKxtYORFXAHoexbhFM18DFK51xLgO6LGygHXrX0yKKdX9YURbLcxEt74Ieii4RPqjnPZ kEE5N4ywlcuTKk0h2NHV7dHHvL3hkFICKIxObReKptIkMjfx/E1mytA4QYBTPzLv+VxD+t642kq 0sPds+0tWp9mRHyjKfUr4H3HnS1S8ucdL9Tg87vHc= X-Received: by 2002:a17:907:3e90:b0:a9a:634:dd2 with SMTP id a640c23a62f3a-a9ad281453bmr586356466b.43.1729872145703; Fri, 25 Oct 2024 09:02:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFL1lIau8hjALEK5IsTkElQQJC8q6g69yC5YJmYQHzu0crs5ECA7I1tmkRyqwGvxbCkwVvRGg== X-Received: by 2002:a17:907:3e90:b0:a9a:634:dd2 with SMTP id a640c23a62f3a-a9ad281453bmr586348866b.43.1729872145027; Fri, 25 Oct 2024 09:02:25 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 03/23] rust/pl011: add support for migration Date: Fri, 25 Oct 2024 18:01:48 +0200 Message-ID: <20241025160209.194307-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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.697, 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: 1729872527702116600 Content-Type: text/plain; charset="utf-8" From: Manos Pitsidianakis Declare the vmstate description of the PL011 device. Based on a patch by Manos Pitsidianakis. Signed-off-by: Manos Pitsidianakis Signed-off-by: Paolo Bonzini Link: https://lore.kernel.org/r/20241024-rust-round-2-v1-4-051e7a25b978@lin= aro.org Tested-by: Zhao Liu --- rust/hw/char/pl011/src/device.rs | 27 ++++++++++ rust/hw/char/pl011/src/device_class.rs | 68 +++++++++++++++++++++++--- 2 files changed, 89 insertions(+), 6 deletions(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index b3d8bc004e0..dd9145669dc 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -20,6 +20,12 @@ =20 static PL011_ID_ARM: [c_uchar; 8] =3D [0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0,= 0x05, 0xb1]; =20 +/// Integer Baud Rate Divider, `UARTIBRD` +const IBRD_MASK: u32 =3D 0x3f; + +/// Fractional Baud Rate Divider, `UARTFBRD` +const FBRD_MASK: u32 =3D 0xffff; + const DATA_BREAK: u32 =3D 1 << 10; =20 /// QEMU sourced constant. @@ -492,6 +498,27 @@ pub fn update(&self) { unsafe { qemu_set_irq(*irq, i32::from(flags & i !=3D 0)) }; } } + + pub fn post_load(&mut self, _version_id: u32) -> Result<(), ()> { + /* Sanity-check input state */ + if self.read_pos >=3D self.read_fifo.len() || self.read_count > se= lf.read_fifo.len() { + return Err(()); + } + + if !self.fifo_enabled() && self.read_count > 0 && self.read_pos > = 0 { + // Older versions of PL011 didn't ensure that the single + // character in the FIFO in FIFO-disabled mode is in + // element 0 of the array; convert to follow the current + // code's assumptions. + self.read_fifo[0] =3D self.read_fifo[self.read_pos]; + self.read_pos =3D 0; + } + + self.ibrd &=3D IBRD_MASK; + self.fbrd &=3D FBRD_MASK; + + Ok(()) + } } =20 /// Which bits in the interrupt status matter for each outbound IRQ line ? diff --git a/rust/hw/char/pl011/src/device_class.rs b/rust/hw/char/pl011/sr= c/device_class.rs index 9282dc4d151..27cabbd6651 100644 --- a/rust/hw/char/pl011/src/device_class.rs +++ b/rust/hw/char/pl011/src/device_class.rs @@ -2,16 +2,73 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 -use core::ptr::NonNull; +use core::{ + ffi::{c_int, c_void}, + ptr::NonNull, +}; =20 -use qemu_api::{bindings::*, definitions::ObjectImpl, zeroable::Zeroable}; +use qemu_api::{ + bindings::*, vmstate_clock, vmstate_fields, vmstate_int32, vmstate_sub= sections, vmstate_uint32, + vmstate_uint32_array, vmstate_unused, zeroable::Zeroable, +}; =20 -use crate::device::PL011State; +use crate::device::{PL011State, PL011_FIFO_DEPTH}; + +extern "C" fn pl011_clock_needed(opaque: *mut c_void) -> bool { + unsafe { + debug_assert!(!opaque.is_null()); + let state =3D NonNull::new_unchecked(opaque.cast::()); + state.as_ref().migrate_clock + } +} + +/// Migration subsection for [`PL011State`] clock. +pub static VMSTATE_PL011_CLOCK: VMStateDescription =3D VMStateDescription { + name: c"pl011/clock".as_ptr(), + version_id: 1, + minimum_version_id: 1, + needed: Some(pl011_clock_needed), + fields: vmstate_fields! { + vmstate_clock!(clock, PL011State), + }, + ..Zeroable::ZERO +}; + +extern "C" fn pl011_post_load(opaque: *mut c_void, version_id: c_int) -> c= _int { + unsafe { + debug_assert!(!opaque.is_null()); + let mut state =3D NonNull::new_unchecked(opaque.cast::= ()); + let result =3D state.as_mut().post_load(version_id as u32); + if result.is_err() { -1 } else { 0 } + } +} =20 -#[used] pub static VMSTATE_PL011: VMStateDescription =3D VMStateDescription { - name: PL011State::TYPE_INFO.name, - unmigratable: true, + name: c"pl011".as_ptr(), + version_id: 2, + minimum_version_id: 2, + post_load: Some(pl011_post_load), + fields: vmstate_fields! { + vmstate_unused!(::core::mem::size_of::()), + vmstate_uint32!(flags, PL011State), + vmstate_uint32!(line_control, PL011State), + vmstate_uint32!(receive_status_error_clear, PL011State), + vmstate_uint32!(control, PL011State), + vmstate_uint32!(dmacr, PL011State), + vmstate_uint32!(int_enabled, PL011State), + vmstate_uint32!(int_level, PL011State), + vmstate_uint32_array!(read_fifo, PL011State, PL011_FIFO_DEPTH), + vmstate_uint32!(ilpr, PL011State), + vmstate_uint32!(ibrd, PL011State), + vmstate_uint32!(fbrd, PL011State), + vmstate_uint32!(ifl, PL011State), + vmstate_int32!(read_pos, PL011State), + vmstate_int32!(read_count, PL011State), + vmstate_int32!(read_trigger, PL011State), + }, + subsections: vmstate_subsections! { + VMSTATE_PL011_CLOCK + }, ..Zeroable::ZERO }; =20 --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872188; cv=none; d=zohomail.com; s=zohoarc; b=aJ1ce1mXoc0neidXWnhrRAZEbL3DDhClxM3awhRnIDoc/2qjjD2JL3XhC8dMXe0RraOISnxM+QOlcHJyv01sjX3r17FL9CzP3ZdaFUbdWwIYThfnIOZWbXkOyZ+LYr/8ZTxjC/Gotwya2oCol0/npM0ONGpep8KLnuecAs1CjC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872188; 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=my1BNlvD0bq7YqmljScKQm6jXcf+70EOh6w75o23M+w=; b=KmQUG/Y35EIYmqq60JkSzuH9/MoEpjSu8cJ6lrkvSx4sRyf4ZYyk6lYxEkAvxgpPvI+PIuzqGdVtw3JSkfsjz2ygz83by6cnoKLj7Mdkbwpiz3FG8tllxJCejW6mOMh1b6TwiIyYxbxaJzqZXpCvRyvRUpZIpPwuMdPiWfnVGa4= 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 1729872188935437.43367081448366; Fri, 25 Oct 2024 09:03:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mlr-0001dQ-R5; Fri, 25 Oct 2024 12:02:39 -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 1t4Mlp-0001Yx-1H for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:02:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4Mln-0004mV-2Y for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:02:36 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-578-CZUBCKq4MvCVzJRQNCK42Q-1; Fri, 25 Oct 2024 12:02:33 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a99fa9f0c25so151873866b.3 for ; Fri, 25 Oct 2024 09:02:32 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f0683edsm86084566b.93.2024.10.25.09.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:02:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872154; 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=my1BNlvD0bq7YqmljScKQm6jXcf+70EOh6w75o23M+w=; b=YzaRxR6Vpf1ILf8W22e2GoLylHPapDtf0Tx2tlRk2jPwCJm+iklWRoHPjT1+Cz54kcpl7K isk0Iz1UEmU8zdrf5SRZpv66LMwNgAXRolFOXySQfLj7sqVsGn4p4Q5y48IQ3hCY7L83pT CpeBlYOMVgdL6PO7vM8o0tkX3rTnuo0= X-MC-Unique: CZUBCKq4MvCVzJRQNCK42Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872151; x=1730476951; 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=my1BNlvD0bq7YqmljScKQm6jXcf+70EOh6w75o23M+w=; b=V+GTtLphY1fXuvmzi2PwSalgTGnCRn1Cw2QYOo84I9CnQZdiUAbr9BrRw30WmTq3QE lNItckbtGSZfkESO8q1AKjnY0fjjDb9XqRaNgOVe2XPK9FV0hccyRf55alIsp/IOzk2Q PFTWKqdVQOYdV/qbuLpHJy91Fb4oMeUCpo01uvtja4f5hIUNmruO/RyVEHGw6ngvRUfb 0itIlkszOEqpvhUKrz8zHEdHz/YDZ6muxW0Zq0mzziArIbLKytY9KKktigiYte6sIScs S+9GMUSPoVqzw0D079L1Y6d63PooZRuzh/nMduL7vJMLuWqHGsBJzK8PtmgKNWEMZON+ qj0A== X-Gm-Message-State: AOJu0YziqwGMRn5MkQV6bCSEUEvQbo+CbtChTHykAM5ZhppTFLPH3R38 ofa4vjjMe5QMOZz+gfwwHFLMSR4Xy1zRke3jUiB1/YWpQdybcPoihNKXFOQMYQpo1pr64wXBM+v 5FTJ+Mxj87p5B8wDYMpsolY0KZTtbCfH3u/oqjj2rVkd3Ey35zPoh5iyW5Bj/lGN36dbz7Tj9Jn 7oo+ZnVvcNdej+aenNOjej5Y9dTcXUWernZKsvSSc= X-Received: by 2002:a17:906:da8e:b0:a9a:6477:bd03 with SMTP id a640c23a62f3a-a9ad275f71dmr545271366b.38.1729872150941; Fri, 25 Oct 2024 09:02:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH186Ru82zC7u7sKHihGHGrJe37yeYvhaAYIWHCvCLRUJGODQuajGTT/T/7ZkNM6LOBTxBhww== X-Received: by 2002:a17:906:da8e:b0:a9a:6477:bd03 with SMTP id a640c23a62f3a-a9ad275f71dmr545264166b.38.1729872150235; Fri, 25 Oct 2024 09:02:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 04/23] rust/pl011: move CLK_NAME static to function scope Date: Fri, 25 Oct 2024 18:01:49 +0200 Message-ID: <20241025160209.194307-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729872189907116600 Content-Type: text/plain; charset="utf-8" From: Manos Pitsidianakis We do not need to have CLK_NAME public nor a static. No functional change. Signed-off-by: Manos Pitsidianakis Signed-off-by: Paolo Bonzini Link: https://lore.kernel.org/r/20241024-rust-round-2-v1-5-051e7a25b978@lin= aro.org Tested-by: Zhao Liu --- rust/hw/char/pl011/src/device.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index dd9145669dc..f91790ff185 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -102,9 +102,6 @@ impl qemu_api::definitions::Class for PL011Class { > =3D None; } =20 -#[used] -pub static CLK_NAME: &CStr =3D c"clk"; - impl PL011State { /// Initializes a pre-allocated, unitialized instance of `PL011State`. /// @@ -114,7 +111,9 @@ impl PL011State { /// `PL011State` type. It must not be called more than once on the same /// location/instance. All its fields are expected to hold unitialized /// values with the sole exception of `parent_obj`. - pub unsafe fn init(&mut self) { + unsafe fn init(&mut self) { + const CLK_NAME: &CStr =3D c"clk"; + let dev =3D addr_of_mut!(*self).cast::(); // SAFETY: // --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872670; cv=none; d=zohomail.com; s=zohoarc; b=B5Uy5BMa5pkDxEFHJ37ScABwVpyZG/X2EgThOD9xV9nh2mHllAEfrMp3V8X+dR/6wWmnFIFETbYzD+yzd5uolKDQZ62H4jNvrakCktwUjHN2XvxuYXEVm3zW75DhNtr73LHS+L0De2v0tcqTt7gBwgEKT3471uVujGiYKgso5ss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872670; 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=rKfrIinsgj9j+tvfQg1SYIKrObbRxPY5XNT1F0GLBRk=; b=fy9iiM8LKSppZn1cGpfgGhcZsmG6CuW7q3MnL6Sd4WW7gK1cYqBFLdcdYxOJ5LFkLZx6UOhcMBGtekIshVnNzPjPMTW8o9rxhnou6GdAA2/qhNupa/a3xhmFEenjjhs9IV/FIfqUE4lO39y7RB/6WzhGjq8O03kBsectSTq001I= 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 172987267005513.611479915826976; Fri, 25 Oct 2024 09:11:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mlv-0001gA-0o; Fri, 25 Oct 2024 12:02:43 -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 1t4Mls-0001eM-G5 for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:02:40 -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 1t4Mlp-0004n3-HH for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:02:40 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-149-tfBkLRVNNECT9WEby9NTDA-1; Fri, 25 Oct 2024 12:02:35 -0400 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5c999f254aeso1929996a12.0 for ; Fri, 25 Oct 2024 09:02:35 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb629c250sm759850a12.27.2024.10.25.09.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872156; 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=rKfrIinsgj9j+tvfQg1SYIKrObbRxPY5XNT1F0GLBRk=; b=HHAeYTt1yqQP18svBgUvWYTyH0C+9SsB0C0bQJC91tB1vqJ2VEqExFTAoZlSJn31suIVJu r5o9NG5BoLvyJqxw9a/oPwsRxaa6c7hGikjgDGaUMHV2dWwCHIL7WEQz1UpJRu3TAnWiEr yrPCZZH0NSZ2ib5j9iUiAatlZ2C8KnA= X-MC-Unique: tfBkLRVNNECT9WEby9NTDA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872154; x=1730476954; 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=rKfrIinsgj9j+tvfQg1SYIKrObbRxPY5XNT1F0GLBRk=; b=sCnAGpeaX+6v5ZVRAetENkwNoC59TOUCXi16hKu+xvMEaxzqmDQz47zdM1VceDQlKo yS/iXPVXrgfmD4XEohNv0FKclfzPzodh4MnyLiIiyKIl9rSK3nXRSMJotOK0ut9YG5TE O3GQR60S4AE5aPNtl9NFUQ/+gOw3MfDhDG9LrU6oLaBnbzXsTmInHKF50i30vA/pgYNN S5DnzsEvQPVzcjkOrM4RWPzEWe53Mnt5CfQp30AcHG3riIQm6WsCZNiNNEdifWkOq3wR pzudJ+R04hTvMHVIQZsYzZuPaNrxDHKfPNhypjEZ/tEKO0i4YxKthgkoRuccBntzqR6G CyBA== X-Gm-Message-State: AOJu0YyRfGCadAKV9eovuOdFWHXQd0edUf7RcthrvpTeRkPf278gDgaV F83Uz3Q9zUDMY9WDFJIDA7Fi9WEAOyWAAhdeHM8yBtycgBUgT1l0CcRWmkLP1KywblsmP7K1e2s eplpLFidNsWA6Ik1EWn7dwl94OqDn3fyFCSS68/oV2ftJuquETZLg8kWaUmtltXqDrept9qlWxp m5DvMe5dGuCIn/AyvlumLSu4XUNpkmpucHh6KW8M4= X-Received: by 2002:a05:6402:3814:b0:5c9:367a:68d9 with SMTP id 4fb4d7f45d1cf-5cb8b1c1b13mr8213338a12.15.1729872153856; Fri, 25 Oct 2024 09:02:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7yU9yqwH3xS3296qTOuOhl/lc6/xFAIlF0HVEt+ayJm+UwhI/SN91Hx6eBRrdb5z5sOHhYw== X-Received: by 2002:a05:6402:3814:b0:5c9:367a:68d9 with SMTP id 4fb4d7f45d1cf-5cb8b1c1b13mr8213266a12.15.1729872153234; Fri, 25 Oct 2024 09:02:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 05/23] rust/pl011: add TYPE_PL011_LUMINARY device Date: Fri, 25 Oct 2024 18:01:50 +0200 Message-ID: <20241025160209.194307-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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.697, 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: 1729872670511116600 Content-Type: text/plain; charset="utf-8" From: Manos Pitsidianakis Add a device specialization for the Luminary UART device. This commit adds a DeviceId enum that utilizes the Index trait to return different bytes depending on what device id the UART has (Arm -default- or Luminary) Signed-off-by: Manos Pitsidianakis Signed-off-by: Paolo Bonzini Link: https://lore.kernel.org/r/20241024-rust-round-2-v1-6-051e7a25b978@lin= aro.org Tested-by: Zhao Liu --- rust/hw/char/pl011/src/device.rs | 77 ++++++++++++++++++++++++++++++-- rust/hw/char/pl011/src/lib.rs | 1 + 2 files changed, 75 insertions(+), 3 deletions(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index f91790ff185..051c59f39ae 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -18,8 +18,6 @@ RegisterOffset, }; =20 -static PL011_ID_ARM: [c_uchar; 8] =3D [0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0,= 0x05, 0xb1]; - /// Integer Baud Rate Divider, `UARTIBRD` const IBRD_MASK: u32 =3D 0x3f; =20 @@ -31,6 +29,29 @@ /// QEMU sourced constant. pub const PL011_FIFO_DEPTH: usize =3D 16_usize; =20 +#[derive(Clone, Copy, Debug)] +enum DeviceId { + #[allow(dead_code)] + Arm =3D 0, + Luminary, +} + +impl std::ops::Index for DeviceId { + type Output =3D c_uchar; + + fn index(&self, idx: hwaddr) -> &Self::Output { + match self { + Self::Arm =3D> &Self::PL011_ID_ARM[idx as usize], + Self::Luminary =3D> &Self::PL011_ID_LUMINARY[idx as usize], + } + } +} + +impl DeviceId { + const PL011_ID_ARM: [c_uchar; 8] =3D [0x11, 0x10, 0x14, 0x00, 0x0d, 0x= f0, 0x05, 0xb1]; + const PL011_ID_LUMINARY: [c_uchar; 8] =3D [0x11, 0x00, 0x18, 0x01, 0x0= d, 0xf0, 0x05, 0xb1]; +} + #[repr(C)] #[derive(Debug, qemu_api_macros::Object)] /// PL011 Device Model in QEMU @@ -75,6 +96,8 @@ pub struct PL011State { pub clock: NonNull, #[doc(alias =3D "migrate_clk")] pub migrate_clock: bool, + /// The byte string that identifies the device. + device_id: DeviceId, } =20 impl ObjectImpl for PL011State { @@ -162,7 +185,7 @@ pub fn read( =20 std::ops::ControlFlow::Break(match RegisterOffset::try_from(offset= ) { Err(v) if (0x3f8..0x400).contains(&v) =3D> { - u64::from(PL011_ID_ARM[((offset - 0xfe0) >> 2) as usize]) + u64::from(self.device_id[(offset - 0xfe0) >> 2]) } Err(_) =3D> { // qemu_log_mask(LOG_GUEST_ERROR, "pl011_read: Bad offset = 0x%x\n", (int)offset); @@ -619,3 +642,51 @@ pub fn post_load(&mut self, _version_id: u32) -> Resul= t<(), ()> { state.as_mut().init(); } } + +#[repr(C)] +#[derive(Debug, qemu_api_macros::Object)] +/// PL011 Luminary device model. +pub struct PL011Luminary { + parent_obj: PL011State, +} + +#[repr(C)] +pub struct PL011LuminaryClass { + _inner: [u8; 0], +} + +/// Initializes a pre-allocated, unitialized instance of `PL011Luminary`. +/// +/// # Safety +/// +/// We expect the FFI user of this function to pass a valid pointer, that = has +/// the same size as [`PL011Luminary`]. We also expect the device is +/// readable/writeable from one thread at any time. +pub unsafe extern "C" fn pl011_luminary_init(obj: *mut Object) { + unsafe { + debug_assert!(!obj.is_null()); + let mut state =3D NonNull::new_unchecked(obj.cast::= ()); + let state =3D state.as_mut(); + state.parent_obj.device_id =3D DeviceId::Luminary; + } +} + +impl qemu_api::definitions::Class for PL011LuminaryClass { + const CLASS_INIT: Option< + unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core::ffi= ::c_void), + > =3D None; + const CLASS_BASE_INIT: Option< + unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core::ffi= ::c_void), + > =3D None; +} + +impl ObjectImpl for PL011Luminary { + type Class =3D PL011LuminaryClass; + const TYPE_INFO: qemu_api::bindings::TypeInfo =3D qemu_api::type_info!= { Self }; + const TYPE_NAME: &'static CStr =3D crate::TYPE_PL011_LUMINARY; + const PARENT_TYPE_NAME: Option<&'static CStr> =3D Some(crate::TYPE_PL0= 11); + const ABSTRACT: bool =3D false; + const INSTANCE_INIT: Option = =3D Some(pl011_luminary_init); + const INSTANCE_POST_INIT: Option =3D None; + const INSTANCE_FINALIZE: Option =3D None; +} diff --git a/rust/hw/char/pl011/src/lib.rs b/rust/hw/char/pl011/src/lib.rs index 2939ee50c99..c6bb76a7926 100644 --- a/rust/hw/char/pl011/src/lib.rs +++ b/rust/hw/char/pl011/src/lib.rs @@ -46,6 +46,7 @@ pub mod memory_ops; =20 pub const TYPE_PL011: &::core::ffi::CStr =3D c"pl011"; +pub const TYPE_PL011_LUMINARY: &::core::ffi::CStr =3D c"pl011_luminary"; =20 /// Offset of each register from the base memory address of the device. /// --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872687; cv=none; d=zohomail.com; s=zohoarc; b=PiMRf2X/aNeBy1265J2T9SzmHG+gLqjb/dkxf44AqEUEcUtK9J1ep0ysjtHUBPF5C5gxfiZe4sZlTQqV8fCrDoAow3fza2CWJuCnhrcDWiBhooXNxBvq2Yu4Es7t7S03KTigPikH5N2P4Ru8JlKN3iSvNKro9qrdGF+52oo/9IU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872687; 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=YhTrf8krh6qlx4DUI+jP2iIptj4/eIA7hdP8klGMHA0=; b=CWahXBMYolfZZDmwH6Ql0gp6XimyzaXZyv5MVfOqs6w/0/xhTQwV+cBEpN1w20F6Vjki/mWC59FbOYS846ZHZccTF6ZpXVb+scSnP4cEyW1dG/ZPmT7034q40d02v45DrKIWBaduG3mcsgH+NJmxoFd4YcdmkWJRIP9ZePqVrHk= 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 1729872687364426.8567877231468; Fri, 25 Oct 2024 09:11:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mm1-0001id-Mk; Fri, 25 Oct 2024 12:02:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4Mlz-0001hd-AE for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:02:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4Mlx-0004oR-Pq for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:02:47 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-348-dX4TcUkINHOQISCH660ByA-1; Fri, 25 Oct 2024 12:02:43 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a99fa9f0c25so151890766b.3 for ; Fri, 25 Oct 2024 09:02:43 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b30c7b5a9sm85495066b.171.2024.10.25.09.02.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872164; 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=YhTrf8krh6qlx4DUI+jP2iIptj4/eIA7hdP8klGMHA0=; b=PGbHrmB6oaWXCoOkBXzkG2zCa3msS59UWx6PTUDPCoPjWy3Eedkbhg0I9k87rGz+ZZyTYJ 4jI8lA8PrGpFGFFZyNt1lJjSLL6yiyJlksKBmlzCfFM1W7PnXO47n0cT1ni45Eq9Q1oRhy GRMd45ekPl+AihTDiChbv81WzjMmHJY= X-MC-Unique: dX4TcUkINHOQISCH660ByA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872161; x=1730476961; 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=YhTrf8krh6qlx4DUI+jP2iIptj4/eIA7hdP8klGMHA0=; b=VeIX4KAR8KiKab4H7xJb8fK7ijefUpHY4jozrIjSOizp8DcVvX+KKcTeybWRvPR3AO 8LXsnr4My906eak5SsuzRZLx7EFrDqPudfU2JoNCsodcbXjy6qppaoJdHLEYNWd4XNtE cujmPXuYq8o8BDk451ahgOJH+ertkPSBnvUz7pDl2S43YuxQ8FqelmqAeUYQm4Dn3+68 NcsKvY/mBxN1iAmiIuDsMYVzZgIvb43bXhmzxvMv0rInTGGhVn2b2nKZYmY/dH1xyJsM MHXL8DriQAZcB90oHjw7e1kWfT2942nKpQQWVZxmCo6tB/YB1lKHVdM/KA+6Fk+hjo6b BaYA== X-Gm-Message-State: AOJu0Yyc5SOTd4J2ID/g+EPUPm4qb/bDbowPKo2HB3EgdF+5nnUDNA8y 3/tflvv6zszLFOLXNnrgVcfbkf5dIopkzd6uyYV02LYkb8qDxP9grFI7koAxGkEUUoAEFHB5jbN oo4Bi/LAyjR2myM4YlFaryMTG7WEsEBy7Vf5uMASrARIJH+cZnCEyZocrX+fqDuZZHsX9hXV863 cC12AVvy9NdLVsUARVowJk5SFFVD2VG+yHfqB8eBs= X-Received: by 2002:a17:906:da8e:b0:a9a:6477:bd03 with SMTP id a640c23a62f3a-a9ad275f71dmr545373566b.38.1729872160839; Fri, 25 Oct 2024 09:02:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJt9cXARG1Y+gPzcX69CGLH9IV3oFHKdXZIlhduNZ0bgg40/03BHx1p1bGDxodLO5CixqpDA== X-Received: by 2002:a17:906:da8e:b0:a9a:6477:bd03 with SMTP id a640c23a62f3a-a9ad275f71dmr545363566b.38.1729872159849; Fri, 25 Oct 2024 09:02:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 06/23] rust/pl011: remove commented out C code Date: Fri, 25 Oct 2024 18:01:51 +0200 Message-ID: <20241025160209.194307-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729872688563116600 Content-Type: text/plain; charset="utf-8" From: Manos Pitsidianakis This code juxtaposed what should be happening according to the C device model but is not needed now that this has been reviewed (I hope) and its validity checked against what the C device does (I hope, again). No functional change. Signed-off-by: Manos Pitsidianakis Signed-off-by: Paolo Bonzini Link: https://lore.kernel.org/r/20241024-rust-round-2-v1-8-051e7a25b978@lin= aro.org Tested-by: Zhao Liu --- rust/hw/char/pl011/src/device.rs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index 051c59f39ae..98357db04e8 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -192,7 +192,6 @@ pub fn read( 0 } Ok(DR) =3D> { - // s->flags &=3D ~PL011_FLAG_RXFF; self.flags.set_receive_fifo_full(false); let c =3D self.read_fifo[self.read_pos]; if self.read_count > 0 { @@ -200,11 +199,9 @@ pub fn read( self.read_pos =3D (self.read_pos + 1) & (self.fifo_dep= th() - 1); } if self.read_count =3D=3D 0 { - // self.flags |=3D PL011_FLAG_RXFE; self.flags.set_receive_fifo_empty(true); } if self.read_count + 1 =3D=3D self.read_trigger { - //self.int_level &=3D ~ INT_RX; self.int_level &=3D !registers::INT_RX; } // Update error bits. @@ -374,13 +371,6 @@ fn loopback_mdmctrl(&mut self) { * dealt with here. */ =20 - //fr =3D s->flags & ~(PL011_FLAG_RI | PL011_FLAG_DCD | - // PL011_FLAG_DSR | PL011_FLAG_CTS); - //fr |=3D (cr & CR_OUT2) ? PL011_FLAG_RI : 0; - //fr |=3D (cr & CR_OUT1) ? PL011_FLAG_DCD : 0; - //fr |=3D (cr & CR_RTS) ? PL011_FLAG_CTS : 0; - //fr |=3D (cr & CR_DTR) ? PL011_FLAG_DSR : 0; - // self.flags.set_ring_indicator(self.control.out_2()); self.flags.set_data_carrier_detect(self.control.out_1()); self.flags.set_clear_to_send(self.control.request_to_send()); @@ -391,10 +381,6 @@ fn loopback_mdmctrl(&mut self) { let mut il =3D self.int_level; =20 il &=3D !Interrupt::MS; - //il |=3D (fr & PL011_FLAG_DSR) ? INT_DSR : 0; - //il |=3D (fr & PL011_FLAG_DCD) ? INT_DCD : 0; - //il |=3D (fr & PL011_FLAG_CTS) ? INT_CTS : 0; - //il |=3D (fr & PL011_FLAG_RI) ? INT_RI : 0; =20 if self.flags.data_set_ready() { il |=3D Interrupt::DSR as u32; @@ -500,10 +486,8 @@ pub fn put_fifo(&mut self, value: c_uint) { let slot =3D (self.read_pos + self.read_count) & (depth - 1); self.read_fifo[slot] =3D value; self.read_count +=3D 1; - // s->flags &=3D ~PL011_FLAG_RXFE; self.flags.set_receive_fifo_empty(false); if self.read_count =3D=3D depth { - //s->flags |=3D PL011_FLAG_RXFF; self.flags.set_receive_fifo_full(true); } =20 --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872292; cv=none; d=zohomail.com; s=zohoarc; b=bEJbS/bE39n2MhQ3sOGjxRA3SrPKByNZ2xgqkAniMKJBxpstGpzpeqzo36fxaefPJqzW1gTlLv4WYVELMHRVxJ8DvoaC9WrHsiIVoBflgCEvhxWDtNvgOpua0BRWCBW+MEBAGa5C8Akb5PpU0IPOGg81w/xKcRpLuj0JVshh1Qw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872292; 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=5jVDymogFtNuVLT1QLTECiV9TKaEM7wWr4YXUEOhTmY=; b=LitRhGtpKoAtZURAO2QiZLBaPH9M1D17JH9iARDLr9edmg57h2b9+JTR3Epb+qgPYp8G/5zRcO/uP1+yXoENXCPNs6mtc+ufrxf3YEwUNBS74+lEPvRdu75igr9M2L4nPSwxN/JfCempEs23utVHZhrkR+jFGy9FdfcsPzuyLMs= 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 17298722923111005.9997935468812; Fri, 25 Oct 2024 09:04:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4MmH-0001q2-Hh; Fri, 25 Oct 2024 12:03:05 -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 1t4MmG-0001om-0l for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:03:04 -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 1t4MmE-0004pZ-KB for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:03:03 -0400 Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-nFehYEbfOteI1kwCn6qJeg-1; Fri, 25 Oct 2024 12:03:00 -0400 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2fb5035169dso20398271fa.3 for ; Fri, 25 Oct 2024 09:03:00 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f2971e8sm84354366b.125.2024.10.25.09.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:02:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872181; 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=5jVDymogFtNuVLT1QLTECiV9TKaEM7wWr4YXUEOhTmY=; b=VkqRujfB2lw/3soQYkkhZCRJYb4dWFtQTofCVXzJ5DAAa6pbILtBTyJSQ0ibwXIcsDJ5Ad XPmlpWPpibBSejJG+6kouKdF322CmhEOcEWjdvhLAZ/2meWYDNkXV3ExDTuQFF/wwa8r/T kQa42MhA6ZxfPTnzxbpE76cRtweY8j4= X-MC-Unique: nFehYEbfOteI1kwCn6qJeg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872178; x=1730476978; 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=5jVDymogFtNuVLT1QLTECiV9TKaEM7wWr4YXUEOhTmY=; b=GyRcZFs3sd3nlMTsjRy1Y2t5CDCgUbhFmzZXseMiqCyS9nsEwenxK1QMVHhhSvrGcq uHIzA0UkXPzFkjIxFmDi0emMPTMXgJehfx1YWqtxpsGCRNf6YyF7RQzCEAJ3QOOTijkH nlR3HKX9427uydsZ9KYXbVijIQn2cnAePEbI88CCRDQPffZ9bCFqEGLvUWdH/rKufqFE DMsNpyQFEskUY3QO2ljIE6w6t/yOjXscfS000sbM48tlCE4aYr0vHM2astoD9S0OCDJv a4OvF0S+GHN66jPhK9ykiDq6//s+MUPvra2dkfdIz7LHqPpH3S9t3gIaMuNMaulxQPpH wHMA== X-Gm-Message-State: AOJu0YzGaM4hYELlX98vJ91OB71Ob9f9nl3lYYsOqy8OvO4Fn4A4C1gU kWxrBXFY7FRmi2fRVaBcby5fAXdrIqMCdgepvVutnl3Oj/O7XJR88oYs/DWkoex5bM5QU7586/W r6sS0yaW9gFJbpvRhXsHWIEQ38EksXAC885t7dhsSn9DxLuJPH0Ng7JPcIlFhgqL2dHFhEbQqNr YwLqGb3p+e+cYcKN7D8gTZVucyRHQ+Uln7MLFmSH0= X-Received: by 2002:a2e:b8c5:0:b0:2fb:3960:9671 with SMTP id 38308e7fff4ca-2fc9d31a99bmr97521581fa.15.1729872177358; Fri, 25 Oct 2024 09:02:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQUrUv9f0GtDtwEjkNavU5VZBRD5UB8MEcTlzGgKrp5gIfxBE8rhtDEevdwt+08r0o9gUCXw== X-Received: by 2002:a2e:b8c5:0:b0:2fb:3960:9671 with SMTP id 38308e7fff4ca-2fc9d31a99bmr97519301fa.15.1729872175334; Fri, 25 Oct 2024 09:02:55 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 07/23] rust/pl011: Use correct masks for IBRD and FBRD Date: Fri, 25 Oct 2024 18:01:52 +0200 Message-ID: <20241025160209.194307-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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.697, 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: 1729872294402116600 Content-Type: text/plain; charset="utf-8" From: Manos Pitsidianakis Port fix from commit cd247eae16ab1b9ce97fd34c000c1b883feeda45 "hw/char/pl011: Use correct masks for IBRD and FBRD" Related issue: Signed-off-by: Manos Pitsidianakis Signed-off-by: Paolo Bonzini Link: https://lore.kernel.org/r/20241024-rust-round-2-v1-9-051e7a25b978@lin= aro.org Tested-by: Zhao Liu --- rust/hw/char/pl011/src/device.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index 98357db04e8..788b47203b1 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -19,10 +19,10 @@ }; =20 /// Integer Baud Rate Divider, `UARTIBRD` -const IBRD_MASK: u32 =3D 0x3f; +const IBRD_MASK: u32 =3D 0xffff; =20 /// Fractional Baud Rate Divider, `UARTFBRD` -const FBRD_MASK: u32 =3D 0xffff; +const FBRD_MASK: u32 =3D 0x3f; =20 const DATA_BREAK: u32 =3D 1 << 10; =20 --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872233; cv=none; d=zohomail.com; s=zohoarc; b=IPR87C854xpOaVEXdMAM1WHGrsM2BdhMXbfPNRxOmDVrDFYGI5D0t6QwiM6nhFPbDCXVkHz8qVSdP7xHG2n+SdSBM8fvpJKFoLOnqOgIFf3vAfPdVMyLZZKD7aC5JGlQVzyZAcwXHKlBS3eSCQzPU6iHZTRYi94sG1sRegr0vew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872233; 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=SHZpikGNVFgjiDhFQjm7CP2c0blb3vG5jwdwFgYBZPE=; b=YshjJDE6uydGTkAho3ZFDrFOWtKjL3K8EPHdS2KodHuvti4Xdw3KZRiCNFlKuSY1uIxFEAfQXIlJR/DY7u0AHe2gZi8/7T+WBODr8k2wc12fQvUz1oWyAmrSLt7hmqOYLnDm3fMtpFvSv3u7ZvpblaSne/eIf937SK57zlf6HFI= 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 1729872233082846.5678589726689; Fri, 25 Oct 2024 09:03:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4MmU-00026Z-QO; Fri, 25 Oct 2024 12:03:19 -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 1t4MmP-00021T-5y for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:03:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4MmN-0004q1-1Y for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:03:12 -0400 Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-156-UvFP4-YYPFWQz4SQ3HjI-g-1; Fri, 25 Oct 2024 12:03:09 -0400 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2fb4e2da8baso17579021fa.0 for ; Fri, 25 Oct 2024 09:03:08 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb62c4860sm752003a12.54.2024.10.25.09.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872190; 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=SHZpikGNVFgjiDhFQjm7CP2c0blb3vG5jwdwFgYBZPE=; b=fMXHGwEII2A4LEfkEGMa+HzfYgDAVcygC6keRYW892XSGyYxSNKh6uvWJfcV6lt1vEZIbV P9JbAnQ9PCVJHAIMuthujJFZnC6f8piCI3QCOP5r+DvZMnwB7TWhCkMqPc+EJwEaopO6NG Jd+4KIu19mJAJnvIR8rHj6cdap6Eg8Y= X-MC-Unique: UvFP4-YYPFWQz4SQ3HjI-g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872186; x=1730476986; 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=SHZpikGNVFgjiDhFQjm7CP2c0blb3vG5jwdwFgYBZPE=; b=xAGIbh6N1NwroBeIOoz14sXM1ZzewC+3+9gAl3JJVi57OeY6SEDT0cxIYdqcvr7Eil 9r9GDEplpjSHYMR50IPyWofZR9MhWf+8vZpwiFuCc2icZhn0vA8QkVFy4idsms/VPdoi dN9fvj/KswcuukYvTk/E0ZI4zkVIzZek72bc1NTO09Nj7jszcZPlVuNIxy9XH1FAdSf6 jOwYT5ifVMVa34zI3TtCWMRhjyDNPBEvxuszKKEO5UHJdPG8gDDzxMrrH2poIf4BtI2M CYNDfhikJsFsc7AL/MWXpSOfNv7le77HBdXjRCCPuNwXq9HmWOOjAZ2cVvE+SNWhfhKx hhzQ== X-Gm-Message-State: AOJu0Yzny8I7Fy0IdqGyn/xi+k3MrqTpxTFft9HdWLrKhm0aKp1KykYt UKfW1rt6OEA7rgFhP7I4ap8ZrMMoKzvV8/fWgUNdjrm7rxaDiTryVRNkYrXNMzD8WJY231/3UPv 8VmTkEabUpmem7ouz94iuuNNC6Ty/eIWDwLXW0MJReRGBSfQFyLYLZyMuEMOv41LDJ84MtV/bbt QJ64HuXQ/4qL3Gsg7uZHXqZ5V++daWfMPJOpBgx6c= X-Received: by 2002:a2e:4619:0:b0:2fa:cc86:f217 with SMTP id 38308e7fff4ca-2fca8264714mr32733971fa.35.1729872185197; Fri, 25 Oct 2024 09:03:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGX0SK+dO0ES1KpzNxs1DZBihiCSdKwZn6wpiDNWGJRyJMfizHisBCqJ4cJpyuuEPZOWRVyiw== X-Received: by 2002:a2e:4619:0:b0:2fa:cc86:f217 with SMTP id 38308e7fff4ca-2fca8264714mr32732591fa.35.1729872182953; Fri, 25 Oct 2024 09:03:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 08/23] rust: patch bilge-impl to allow compilation with 1.63.0 Date: Fri, 25 Oct 2024 18:01:53 +0200 Message-ID: <20241025160209.194307-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729872234176116600 Content-Type: text/plain; charset="utf-8" Apply a patch that removes "let ... else" constructs, replacing them with "if let ... else" or "let ... =3D match ...". "let ... else" was stabilize= d in Rust 1.65.0. Reviewed-by: Junjie Mao Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini Tested-by: Zhao Liu --- .gitattributes | 2 + subprojects/bilge-impl-0.2-rs.wrap | 1 + .../packagefiles/bilge-impl-1.63.0.patch | 45 +++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 subprojects/packagefiles/bilge-impl-1.63.0.patch diff --git a/.gitattributes b/.gitattributes index 6dc6383d3d1..9ce7a19581a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,3 +5,5 @@ *.rs diff=3Drust *.rs.inc diff=3Drust Cargo.lock diff=3Dtoml merge=3Dbinary + +*.patch -text -whitespace diff --git a/subprojects/bilge-impl-0.2-rs.wrap b/subprojects/bilge-impl-0.= 2-rs.wrap index eefb10c36c2..b24c34a9043 100644 --- a/subprojects/bilge-impl-0.2-rs.wrap +++ b/subprojects/bilge-impl-0.2-rs.wrap @@ -5,3 +5,4 @@ source_filename =3D bilge-impl-0.2.0.tar.gz source_hash =3D feb11e002038ad243af39c2068c8a72bcf147acf05025dcdb916fcc000= adb2d8 #method =3D cargo patch_directory =3D bilge-impl-0.2-rs +diff_files =3D bilge-impl-1.63.0.patch diff --git a/subprojects/packagefiles/bilge-impl-1.63.0.patch b/subprojects= /packagefiles/bilge-impl-1.63.0.patch new file mode 100644 index 00000000000..987428a6d65 --- /dev/null +++ b/subprojects/packagefiles/bilge-impl-1.63.0.patch @@ -0,0 +1,45 @@ +--- a/src/shared/discriminant_assigner.rs ++++ b/src/shared/discriminant_assigner.rs +@@ -26,20 +26,20 @@ + let discriminant_expr =3D &discriminant.1; + let variant_name =3D &variant.ident; +=20 +- let Expr::Lit(ExprLit { lit: Lit::Int(int), .. }) =3D discriminan= t_expr else { ++ if let Expr::Lit(ExprLit { lit: Lit::Int(int), .. }) =3D discrimi= nant_expr { ++ let discriminant_value: u128 =3D int.base10_parse().unwrap_or= _else(unreachable); ++ if discriminant_value > self.max_value() { ++ abort!(variant, "Value of variant exceeds the given numbe= r of bits") ++ } ++ ++ Some(discriminant_value) ++ } else { + abort!( + discriminant_expr, + "variant `{}` is not a number", variant_name; + help =3D "only literal integers currently supported" + ) +- }; +- +- let discriminant_value: u128 =3D int.base10_parse().unwrap_or_els= e(unreachable); +- if discriminant_value > self.max_value() { +- abort!(variant, "Value of variant exceeds the given number of= bits") + } +- +- Some(discriminant_value) + } +=20 + fn assign(&mut self, variant: &Variant) -> u128 { +--- a/src/shared/fallback.rs ++++ b/src/shared/fallback.rs +@@ -22,8 +22,9 @@ + } + Unnamed(fields) =3D> { + let variant_fields =3D fields.unnamed.iter(); +- let Ok(fallback_value) =3D variant_fields.exactly_one() e= lse { +- abort!(variant, "fallback variant must have exactly o= ne field"; help =3D "use only one field or change to a unit variant") ++ let fallback_value =3D match variant_fields.exactly_one()= { ++ Ok(ok) =3D> ok, ++ _ =3D> abort!(variant, "fallback variant must have ex= actly one field"; help =3D "use only one field or change to a unit variant") + }; +=20 + if !is_last_variant { --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872291; cv=none; d=zohomail.com; s=zohoarc; b=AsRH02t541hzvmBGkO61RKLTXTBMwcFHODRK0Y53D62BalOlcjDMmDyS+vPDNX7LqHos4YE+7D5JC5k7EkT2SJ9KiF6d6uRcV6vZ9+HcWK13pqdtTIjrUvIBWYnn5ndqhhVf95QfPBfA47vwjfKvYHhjSGPVvgkXbIJ4XloBOWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872291; 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=zDYuK9gssUSWouiyNUfyuA4WH+J2VX1Jg4Z7natGato=; b=nnP65Q1tLNvxnPAVG/sm19n4x0maJoI/45I6pvhxBClMsYCA+Sriq6Mzv8H5/qQhBC6N6t0dz9+e34+EbXeB5LA8rnAFzWP1n8n1VEeLwzLTe1kxM5L2Vz6k9ryg88SDX+Ruj6zFLD/IqSGA5EBJY89wwdxLrrp1a5A42TtE5o4= 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 172987229187987.35791418564702; Fri, 25 Oct 2024 09:04:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mmu-0002M0-K0; Fri, 25 Oct 2024 12:03:48 -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 1t4MmZ-00029q-8O for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:03:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4MmV-0004qX-MB for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:03:23 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-160-WbWbFuuYPN-qk1V1iCH0pQ-1; Fri, 25 Oct 2024 12:03:14 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a9a157d028fso85330766b.0 for ; Fri, 25 Oct 2024 09:03:13 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb6255be3sm759977a12.3.2024.10.25.09.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872199; 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=zDYuK9gssUSWouiyNUfyuA4WH+J2VX1Jg4Z7natGato=; b=AUoDnLUTgF/8IT7REyb50dfQIM/r89jyrJWHWuvPhbOMdKUnl8cWNe4R9JIzf8m3A9DgCy PTGP9O1WKXdsEhYDtKkRCIu3vmVUPfLqiZMKixIaW2JqBkwg0AFP312R2GvHa+1JK6y5UG 75DHtZEbPYDXquQAdykyHOjNktoXJDw= X-MC-Unique: WbWbFuuYPN-qk1V1iCH0pQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872193; x=1730476993; 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=zDYuK9gssUSWouiyNUfyuA4WH+J2VX1Jg4Z7natGato=; b=IZ6HJqoBc1JaJ1tRlBPQHrjUe3j28HYo1paDrnfDb0ko9F2gPprV5+BVkKhqcN7KAT 6HzizHmyL0XjuiecXhvQftgT2uuP5rbTzOI36RYRvVRc2H7W0OGc+e3asVgbEXRZkuS5 0u4tkvyZKQbxkBjDM73k/+nmEvKeTz73HtVJFbucQuosbzNIE1Vx0K2timj32KyrbPIQ mEhRatJ4y/Yf2k+jAycfHXkEzt32V+O5PAZ8hcBrUZEn8O5L0JAwmCXyAQoxQf4u/p4j pTOhUKXFi80frdjZCnL/98/Zw/a1lTbX6GuIKhO+MXhhazJXeDi3aK0FonvAXkLxXVMT QoDA== X-Gm-Message-State: AOJu0Yzfe1K7gDPrZW4QxZvMUuM86zmN39vAvvWP9HtdNzSY6hHyGWzm HH1peZKNG8zvdDyTRJOvH8X1ktelngyjWKCuRyBpC2jMmsH9YVKSEHNoKZUo01PMyZjyh1px5Aq 4sWCoH/NZe85OmtWh2pB5/lk8zhyAmTBSFW+OfMew1s9bLpCtE/JUEz0j7d/rbp+ueXP7EnGQ1J U3Hf8PjMt8UoguKR7xWGd6uhbl65BPFcCbC/kxZ3I= X-Received: by 2002:a05:6402:e85:b0:5ca:ef8:bff8 with SMTP id 4fb4d7f45d1cf-5cb8b28ecf9mr10555642a12.33.1729872192629; Fri, 25 Oct 2024 09:03:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9tY32/KpL413ToKYTKOpkoo1H3ehqqRaC03JWMM5R5s37sAyef4a7zbNaf5aMUWMl8bCDHQ== X-Received: by 2002:a05:6402:e85:b0:5ca:ef8:bff8 with SMTP id 4fb4d7f45d1cf-5cb8b28ecf9mr10555589a12.33.1729872192154; Fri, 25 Oct 2024 09:03:12 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 09/23] rust: fix cfgs of proc-macro2 for 1.63.0 Date: Fri, 25 Oct 2024 18:01:54 +0200 Message-ID: <20241025160209.194307-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729872292472116600 Content-Type: text/plain; charset="utf-8" Replay the configuration that would be computed by build.rs when compiling on a 1.63.0 compiler. Reviewed-by: Junjie Mao Signed-off-by: Paolo Bonzini Tested-by: Zhao Liu --- subprojects/packagefiles/proc-macro2-1-rs/meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subprojects/packagefiles/proc-macro2-1-rs/meson.build b/subpro= jects/packagefiles/proc-macro2-1-rs/meson.build index 818ec59336b..8e601b50ccc 100644 --- a/subprojects/packagefiles/proc-macro2-1-rs/meson.build +++ b/subprojects/packagefiles/proc-macro2-1-rs/meson.build @@ -15,7 +15,9 @@ _proc_macro2_rs =3D static_library( rust_abi: 'rust', rust_args: [ '--cfg', 'feature=3D"proc-macro"', - '--cfg', 'span_locations', + '--cfg', 'no_literal_byte_character', + '--cfg', 'no_literal_c_string', + '--cfg', 'no_source_text', '--cfg', 'wrap_proc_macro', ], dependencies: [ --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872625; cv=none; d=zohomail.com; s=zohoarc; b=A+RvkZxkFPolzhErE5oeo7qAQ2UW9jpPCwuJmV+kEnQcNRNw77J/PYzxK9wQQl5DZEceY9P1uLHeexaUoWJ/MY7yRIfLf24nyOVOm97yd7dskR8jHWWfZJGIF5/LSCJZIODDn/1kNTtbmxzBR1xTXvAnG1w9/f7A9uncmscixvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872625; 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=JRpYd5gLU5pnd2gn0TumqBM3kJhFe2BgTXzKLOcnZGg=; b=cm7lqxtBGdcIIz8Lno2mv74+WUXMwX4INcsFw6RCyuqjUYCalGu5Xx4fExvCW+T9PuxYuzfnah5KBNBjBzkTp7zd5LItsfPzQiMNWszP+upRDbrTgDllfoVS9X5tToAoPIzHRUqLgEQmcw6lmgF3pNPt/Qgjt4HH97qp87ziiX8= 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 1729872625976311.398646122311; Fri, 25 Oct 2024 09:10:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mn0-0002Vh-0M; Fri, 25 Oct 2024 12:03:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4Mmg-0002Gs-Gu for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:03:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4Mme-0004rJ-5E for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:03:30 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-548-Cm8Df4srMIqyHq_jvTusWg-1; Fri, 25 Oct 2024 12:03:24 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a9a194d672bso159445666b.2 for ; Fri, 25 Oct 2024 09:03:24 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f0698c0sm85027666b.95.2024.10.25.09.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872207; 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=JRpYd5gLU5pnd2gn0TumqBM3kJhFe2BgTXzKLOcnZGg=; b=WD2n3WVRfI5YkzaCGCzoK7G86WjlcdptbLVRqWCSfsfjhyhO3R1Z6O9MKaWvUJs8s2C0SG t6nLnPR8sbfaf0NAJ6+uTixAlxlbLW1bzvzfVQO3uRZtTMrEe26QTzIxF+0bo5ZpArH5Sl 0gTvAYJnSOv0fJsBE8+LnOMrLuReSI4= X-MC-Unique: Cm8Df4srMIqyHq_jvTusWg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872201; x=1730477001; 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=JRpYd5gLU5pnd2gn0TumqBM3kJhFe2BgTXzKLOcnZGg=; b=fLInT2+6QJE23q/IEUSjzlkJV+4FpZ6SFqh69l4TJEzEloqVY+NSNOjoxb2kk9pi6I HhLbu4B+Y7hdtOBVvxFyX0XdldyD/5c+BxX32WOCoCht2p7JT0bda+/kGp5HgMrh7wkl hoFKqJwR3mdmRKGndKHDaLkLASSo/TFec1IGvv5STxBz3t5qU5nHZJELtZk9mmUg59kd 9Ml3GfDJ8bqxTMmJ/mMwAOSo/kKfab35svq4QJWkHJJ65RtjqFh5tH4gK2xuHxl2W/xe 1V5NmKXr7kWhP4W479osMRHSUkf8MsL0rVk+QcFTusF27qJsPREFmSpPukdksbPOg1pz f5hg== X-Gm-Message-State: AOJu0YzrqnhiNRtI3ARNA1s5elWG2fCSS/zozyq283eKpmPxSNihNh0V 5JydCedseAksfTXuqucYFq2F7tbgNtTO/bJQE56OEwfVruXN3uAxt30Wq7r41A2ORpqOVDgDiVg 5HYmytsJBcrXD7LP4YLyxfqcSbmReiEI7KiioL4fKQtE8SbHsn37qh0etEMy5PVe30fkOH1K8Xr qJ7mCVuWe2cv/Na3PaYLoi4jhjbnaFJfFiZJaavLU= X-Received: by 2002:a17:907:5015:b0:a9d:e1d6:42a1 with SMTP id a640c23a62f3a-a9de1d6435emr21190166b.30.1729872201011; Fri, 25 Oct 2024 09:03:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyt2JvE9VYA2xkI3VIFOyVoR52tOPHTdEzenqsysH29mMicK8aICqmXcRNSvL5Hv7W8Z+0rw== X-Received: by 2002:a17:907:5015:b0:a9d:e1d6:42a1 with SMTP id a640c23a62f3a-a9de1d6435emr21186166b.30.1729872200346; Fri, 25 Oct 2024 09:03:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 10/23] rust: use std::os::raw instead of core::ffi Date: Fri, 25 Oct 2024 18:01:55 +0200 Message-ID: <20241025160209.194307-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729872626246116600 Content-Type: text/plain; charset="utf-8" core::ffi::c_* types were introduced in Rust 1.64.0. Use the older types in std::os::raw, which are now aliases of the types in core::ffi. There is no need to compile QEMU as no_std, so this is acceptable as long as we supp= ort a version of Debian with Rust 1.63.0. Reviewed-by: Zhao Liu Signed-off-by: Paolo Bonzini Tested-by: Zhao Liu --- meson.build | 3 +-- rust/hw/char/pl011/src/device.rs | 35 +++++++++++----------------- rust/hw/char/pl011/src/lib.rs | 4 ++-- rust/hw/char/pl011/src/memory_ops.rs | 14 +++-------- rust/qemu-api/src/definitions.rs | 2 +- rust/qemu-api/src/device_class.rs | 6 ++--- rust/qemu-api/src/lib.rs | 11 +++++---- rust/qemu-api/src/vmstate.rs | 10 ++++---- rust/qemu-api/tests/tests.rs | 9 ++++--- 9 files changed, 39 insertions(+), 55 deletions(-) diff --git a/meson.build b/meson.build index 5e2b0fb82b2..e819148f36c 100644 --- a/meson.build +++ b/meson.build @@ -3933,14 +3933,13 @@ if have_rust and have_system bindgen_args =3D [ '--disable-header-comment', '--raw-line', '// @generated', - '--ctypes-prefix', 'core::ffi', + '--ctypes-prefix', 'std::os::raw', '--formatter', 'rustfmt', '--generate-block', '--generate-cstr', '--impl-debug', '--merge-extern-blocks', '--no-doc-comments', - '--use-core', '--with-derive-default', '--no-layout-tests', '--no-prepend-enum-name', diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index 788b47203b1..036757f7f3a 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -2,9 +2,10 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 -use core::{ - ffi::{c_int, c_uchar, c_uint, c_void, CStr}, - ptr::{addr_of, addr_of_mut, NonNull}, +use core::ptr::{addr_of, addr_of_mut, NonNull}; +use std::{ + ffi::CStr, + os::raw::{c_int, c_uchar, c_uint, c_void}, }; =20 use qemu_api::{ @@ -117,11 +118,10 @@ pub struct PL011Class { } =20 impl qemu_api::definitions::Class for PL011Class { - const CLASS_INIT: Option< - unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core::ffi= ::c_void), - > =3D Some(crate::device_class::pl011_class_init); + const CLASS_INIT: Option =3D + Some(crate::device_class::pl011_class_init); const CLASS_BASE_INIT: Option< - unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core::ffi= ::c_void), + unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut c_void), > =3D None; } =20 @@ -176,11 +176,7 @@ unsafe fn init(&mut self) { } } =20 - pub fn read( - &mut self, - offset: hwaddr, - _size: core::ffi::c_uint, - ) -> std::ops::ControlFlow { + pub fn read(&mut self, offset: hwaddr, _size: c_uint) -> std::ops::Con= trolFlow { use RegisterOffset::*; =20 std::ops::ControlFlow::Break(match RegisterOffset::try_from(offset= ) { @@ -562,11 +558,7 @@ pub fn post_load(&mut self, _version_id: u32) -> Resul= t<(), ()> { /// readable/writeable from one thread at any time. /// /// The buffer and size arguments must also be valid. -pub unsafe extern "C" fn pl011_receive( - opaque: *mut core::ffi::c_void, - buf: *const u8, - size: core::ffi::c_int, -) { +pub unsafe extern "C" fn pl011_receive(opaque: *mut c_void, buf: *const u8= , size: c_int) { unsafe { debug_assert!(!opaque.is_null()); let mut state =3D NonNull::new_unchecked(opaque.cast::= ()); @@ -585,7 +577,7 @@ pub fn post_load(&mut self, _version_id: u32) -> Result= <(), ()> { /// We expect the FFI user of this function to pass a valid pointer, that = has /// the same size as [`PL011State`]. We also expect the device is /// readable/writeable from one thread at any time. -pub unsafe extern "C" fn pl011_event(opaque: *mut core::ffi::c_void, event= : QEMUChrEvent) { +pub unsafe extern "C" fn pl011_event(opaque: *mut c_void, event: QEMUChrEv= ent) { unsafe { debug_assert!(!opaque.is_null()); let mut state =3D NonNull::new_unchecked(opaque.cast::= ()); @@ -656,11 +648,10 @@ pub struct PL011LuminaryClass { } =20 impl qemu_api::definitions::Class for PL011LuminaryClass { - const CLASS_INIT: Option< - unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core::ffi= ::c_void), - > =3D None; + const CLASS_INIT: Option =3D + None; const CLASS_BASE_INIT: Option< - unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core::ffi= ::c_void), + unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut c_void), > =3D None; } =20 diff --git a/rust/hw/char/pl011/src/lib.rs b/rust/hw/char/pl011/src/lib.rs index c6bb76a7926..a539062aa30 100644 --- a/rust/hw/char/pl011/src/lib.rs +++ b/rust/hw/char/pl011/src/lib.rs @@ -45,8 +45,8 @@ pub mod device_class; pub mod memory_ops; =20 -pub const TYPE_PL011: &::core::ffi::CStr =3D c"pl011"; -pub const TYPE_PL011_LUMINARY: &::core::ffi::CStr =3D c"pl011_luminary"; +pub const TYPE_PL011: &::std::ffi::CStr =3D c"pl011"; +pub const TYPE_PL011_LUMINARY: &::std::ffi::CStr =3D c"pl011_luminary"; =20 /// Offset of each register from the base memory address of the device. /// diff --git a/rust/hw/char/pl011/src/memory_ops.rs b/rust/hw/char/pl011/src/= memory_ops.rs index fc69922fbf3..169d485a4d2 100644 --- a/rust/hw/char/pl011/src/memory_ops.rs +++ b/rust/hw/char/pl011/src/memory_ops.rs @@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later =20 use core::ptr::NonNull; +use std::os::raw::{c_uint, c_void}; =20 use qemu_api::{bindings::*, zeroable::Zeroable}; =20 @@ -22,11 +23,7 @@ }, }; =20 -unsafe extern "C" fn pl011_read( - opaque: *mut core::ffi::c_void, - addr: hwaddr, - size: core::ffi::c_uint, -) -> u64 { +unsafe extern "C" fn pl011_read(opaque: *mut c_void, addr: hwaddr, size: c= _uint) -> u64 { assert!(!opaque.is_null()); let mut state =3D unsafe { NonNull::new_unchecked(opaque.cast::()) }; let val =3D unsafe { state.as_mut().read(addr, size) }; @@ -43,12 +40,7 @@ } } =20 -unsafe extern "C" fn pl011_write( - opaque: *mut core::ffi::c_void, - addr: hwaddr, - data: u64, - _size: core::ffi::c_uint, -) { +unsafe extern "C" fn pl011_write(opaque: *mut c_void, addr: hwaddr, data: = u64, _size: c_uint) { unsafe { assert!(!opaque.is_null()); let mut state =3D NonNull::new_unchecked(opaque.cast::= ()); diff --git a/rust/qemu-api/src/definitions.rs b/rust/qemu-api/src/definitio= ns.rs index 064afe60549..26597934bbd 100644 --- a/rust/qemu-api/src/definitions.rs +++ b/rust/qemu-api/src/definitions.rs @@ -4,7 +4,7 @@ =20 //! Definitions required by QEMU when registering a device. =20 -use ::core::ffi::{c_void, CStr}; +use std::{ffi::CStr, os::raw::c_void}; =20 use crate::bindings::{Object, ObjectClass, TypeInfo}; =20 diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index 3d40256f60f..cb4573ca6ef 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -7,7 +7,7 @@ macro_rules! device_class_init { ($func:ident, props =3D> $props:ident, realize_fn =3D> $realize_fn:exp= r, legacy_reset_fn =3D> $legacy_reset_fn:expr, vmsd =3D> $vmsd:ident$(,)*) = =3D> { pub unsafe extern "C" fn $func( klass: *mut $crate::bindings::ObjectClass, - _: *mut ::core::ffi::c_void, + _: *mut ::std::os::raw::c_void, ) { let mut dc =3D ::core::ptr::NonNull::new(klass.cast::<$crate::bindings::D= eviceClass>()).unwrap(); @@ -26,7 +26,7 @@ macro_rules! define_property { ($name:expr, $state:ty, $field:expr, $prop:expr, $type:expr, default = =3D $defval:expr$(,)*) =3D> { $crate::bindings::Property { // use associated function syntax for type checking - name: ::core::ffi::CStr::as_ptr($name), + name: ::std::ffi::CStr::as_ptr($name), info: $prop, offset: ::core::mem::offset_of!($state, $field) as isize, set_default: true, @@ -37,7 +37,7 @@ macro_rules! define_property { ($name:expr, $state:ty, $field:expr, $prop:expr, $type:expr$(,)*) =3D>= { $crate::bindings::Property { // use associated function syntax for type checking - name: ::core::ffi::CStr::as_ptr($name), + name: ::std::ffi::CStr::as_ptr($name), info: $prop, offset: ::core::mem::offset_of!($state, $field) as isize, set_default: false, diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index 10ab3d7e639..ed840ee2f72 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -34,7 +34,10 @@ unsafe impl Sync for bindings::VMStateInfo {} pub mod vmstate; pub mod zeroable; =20 -use std::alloc::{GlobalAlloc, Layout}; +use std::{ + alloc::{GlobalAlloc, Layout}, + os::raw::c_void, +}; =20 #[cfg(HAVE_GLIB_WITH_ALIGNED_ALLOC)] extern "C" { @@ -48,8 +51,8 @@ fn g_aligned_alloc0( =20 #[cfg(not(HAVE_GLIB_WITH_ALIGNED_ALLOC))] extern "C" { - fn qemu_memalign(alignment: usize, size: usize) -> *mut ::core::ffi::c= _void; - fn qemu_vfree(ptr: *mut ::core::ffi::c_void); + fn qemu_memalign(alignment: usize, size: usize) -> *mut c_void; + fn qemu_vfree(ptr: *mut c_void); } =20 extern "C" { @@ -114,7 +117,7 @@ fn default() -> Self { } =20 // Sanity check. -const _: [(); 8] =3D [(); ::core::mem::size_of::<*mut ::core::ffi::c_void>= ()]; +const _: [(); 8] =3D [(); ::core::mem::size_of::<*mut c_void>()]; =20 unsafe impl GlobalAlloc for QemuAllocator { unsafe fn alloc(&self, layout: Layout) -> *mut u8 { diff --git a/rust/qemu-api/src/vmstate.rs b/rust/qemu-api/src/vmstate.rs index 2a626137e25..5dd783a902a 100644 --- a/rust/qemu-api/src/vmstate.rs +++ b/rust/qemu-api/src/vmstate.rs @@ -55,7 +55,7 @@ macro_rules! vmstate_single_test { $crate::bindings::VMStateField { name: ::core::concat!(::core::stringify!($field_name), 0) .as_bytes() - .as_ptr() as *const ::core::ffi::c_char, + .as_ptr() as *const ::std::os::raw::c_char, err_hint: ::core::ptr::null(), offset: ::core::mem::offset_of!($struct_name, $field_name), size: $size, @@ -132,7 +132,7 @@ macro_rules! vmstate_array { $crate::bindings::VMStateField { name: ::core::concat!(::core::stringify!($field_name), 0) .as_bytes() - .as_ptr() as *const ::core::ffi::c_char, + .as_ptr() as *const ::std::os::raw::c_char, err_hint: ::core::ptr::null(), offset: ::core::mem::offset_of!($struct_name, $field_name), size: $size, @@ -180,7 +180,7 @@ macro_rules! vmstate_struct_pointer_v { $crate::bindings::VMStateField { name: ::core::concat!(::core::stringify!($field_name), 0) .as_bytes() - .as_ptr() as *const ::core::ffi::c_char, + .as_ptr() as *const ::std::os::raw::c_char, err_hint: ::core::ptr::null(), offset: ::core::mem::offset_of!($struct_name, $field_name), size: ::core::mem::size_of::<*const $type>(), @@ -205,7 +205,7 @@ macro_rules! vmstate_array_of_pointer { $crate::bindings::VMStateField { name: ::core::concat!(::core::stringify!($field_name), 0) .as_bytes() - .as_ptr() as *const ::core::ffi::c_char, + .as_ptr() as *const ::std::os::raw::c_char, version_id: $version_id, num: $num as _, info: $info, @@ -230,7 +230,7 @@ macro_rules! vmstate_array_of_pointer_to_struct { $crate::bindings::VMStateField { name: ::core::concat!(::core::stringify!($field_name), 0) .as_bytes() - .as_ptr() as *const ::core::ffi::c_char, + .as_ptr() as *const ::std::os::raw::c_char, version_id: $version_id, num: $num as _, vmsd: $vmsd, diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index 37c4dd44f81..c7089f0cf21 100644 --- a/rust/qemu-api/tests/tests.rs +++ b/rust/qemu-api/tests/tests.rs @@ -2,7 +2,7 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 -use core::ffi::CStr; +use std::{ffi::CStr, os::raw::c_void}; =20 use qemu_api::{ bindings::*, @@ -64,11 +64,10 @@ impl ObjectImpl for DummyState { } =20 impl Class for DummyClass { - const CLASS_INIT: Option< - unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core:= :ffi::c_void), - > =3D Some(dummy_class_init); + const CLASS_INIT: Option =3D + Some(dummy_class_init); const CLASS_BASE_INIT: Option< - unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut core:= :ffi::c_void), + unsafe extern "C" fn(klass: *mut ObjectClass, data: *mut c_voi= d), > =3D None; } =20 --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872359; cv=none; d=zohomail.com; s=zohoarc; b=F7C4Foi/kmHYa31rvaHfEMjQe71jrQXeqLIqZt8xkzY78YpTyMBlHRxOWhYNkjXnBbhpK9tIUZ6mG6fVCBruETbwppsIJ0TOAeqrG10N8N5OqKaXqzKuc2gyhWSBQqGA02CkfOT/D+OjK0pbDTxYnhqstUqPEI2A3DXXpCchXMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872359; 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=N1AWbbclV6flLDb0VZh8Mn48C06nKC3a8IWhDK0o1WU=; b=GZh+PuxOKdddSx0P35fNrQiI/cufM5MFVq9GhBN0TTpAgHxsIyU1l3xFQe67Y0sf72h579Dr2PJepu+kFBl49Iu71BLNHZ1nKKo+JagTVtFUSKjKHpwdSuc731PSrkb/CJ7Gqb69Gww+VZl4DpgURGqSuyQ8GiiEZxoQQniz5h0= 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 1729872359154850.743996588693; Fri, 25 Oct 2024 09:05:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mn4-0002yi-SH; Fri, 25 Oct 2024 12:03:55 -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 1t4Mmp-0002OF-Gm for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:03:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4Mmn-0004s1-Ak for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:03:39 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-304-t2D9Fpf_PmOOdkbQ1RbLMw-1; Fri, 25 Oct 2024 12:03:34 -0400 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5c94862c3adso1546564a12.3 for ; Fri, 25 Oct 2024 09:03:34 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb62c22d1sm757566a12.45.2024.10.25.09.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872215; 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=N1AWbbclV6flLDb0VZh8Mn48C06nKC3a8IWhDK0o1WU=; b=iAjr6nK4zVGJycVBLNzBAYAos61Q5aMCq8G3A7e5IjAVozGYddzlZAKIBJurgBQbySl16Q 6iUVGe89cwmWYM6+r1hLLCCjuFSRjlrFrl0hpaiyHD3OVkIQSrRFAuH/fOzN2MH8VtmK2T knliLm+e/IuC2keTRjNyvf4Rxk7lwXo= X-MC-Unique: t2D9Fpf_PmOOdkbQ1RbLMw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872212; x=1730477012; 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=N1AWbbclV6flLDb0VZh8Mn48C06nKC3a8IWhDK0o1WU=; b=ga1byDNPLoH9tMWxnBla9ytLR/RagCaNDOO2AVQCxvPgsE2jNqXSNtCx3Y0mMkkM3O Xe9xDmPe0e/J9dfthaJYykOGmQSi2+sDgnKJ/oQXXQkRzXAfNpQIYCqcvsFe7Z1z4n3S vuMmaIVXIYuwwBvHDr4K3W/qHxAgy3w1wpj6Hi8Pk+Ek54Ktg0S383nhZ2GpEvx8jbPK Vs66HW8QnvmSJWI9wtbNROTy1zDOjcxW2Qp+UMukyZRQkBHxEjp4vgCOI4XPpFq2DbM/ HhjDn8y2zd8M2O/TDfPeh3A853IytfDI/3j4fbSatxoMJ3dl1o4bshSbNR/XR4Tu6/W4 P/qQ== X-Gm-Message-State: AOJu0YwAnsyN312i7q+ozxpcJ8um1teGiac0zxeLQMzUArbA4ezOYvyd SSQ5xvKwZvCOSM5+ghocpNfmEWfl/1XJvWoUg/qiUMDz7bmkMU/XfM15Cw87GGiA6ctas5wpXfz sF6ePFdf54CZea2ZTj5kaLdpCANtbifXrlR4Q0p/UxC5J/7PrvRoy6OPGdqLqSZbvy0Hjs0S/No /8z543omexjxUMnYdGegbzOrMVrwlat8j4J29FA7k= X-Received: by 2002:a05:6402:2710:b0:5c8:84a8:5185 with SMTP id 4fb4d7f45d1cf-5cb8ac37e7bmr8484533a12.6.1729872211748; Fri, 25 Oct 2024 09:03:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsiiWJvT/MFQBypq3FPhiRGYaQ1OSqGv4ivGfQOjHxhSP1P3cR8si84K29So5YltfE87UzlA== X-Received: by 2002:a05:6402:2710:b0:5c8:84a8:5185 with SMTP id 4fb4d7f45d1cf-5cb8ac37e7bmr8484451a12.6.1729872210794; Fri, 25 Oct 2024 09:03:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 11/23] rust: introduce a c_str macro Date: Fri, 25 Oct 2024 18:01:56 +0200 Message-ID: <20241025160209.194307-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729872361084116600 Content-Type: text/plain; charset="utf-8" This allows CStr constants to be defined easily on Rust 1.63.0, while checking that there are no embedded NULs. c"" literals were only stabilized in Rust 1.77.0. Signed-off-by: Paolo Bonzini Reviewed-by: Zhao Liu Tested-by: Zhao Liu --- rust/hw/char/pl011/src/device.rs | 5 ++- rust/hw/char/pl011/src/device_class.rs | 18 ++++----- rust/hw/char/pl011/src/lib.rs | 6 ++- rust/qemu-api/meson.build | 4 ++ rust/qemu-api/src/c_str.rs | 53 ++++++++++++++++++++++++++ rust/qemu-api/src/lib.rs | 1 + rust/qemu-api/src/vmstate.rs | 2 +- rust/qemu-api/tests/tests.rs | 8 ++-- 8 files changed, 78 insertions(+), 19 deletions(-) create mode 100644 rust/qemu-api/src/c_str.rs diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index 036757f7f3a..2d225d544de 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -10,6 +10,7 @@ =20 use qemu_api::{ bindings::{self, *}, + c_str, definitions::ObjectImpl, }; =20 @@ -135,7 +136,7 @@ impl PL011State { /// location/instance. All its fields are expected to hold unitialized /// values with the sole exception of `parent_obj`. unsafe fn init(&mut self) { - const CLK_NAME: &CStr =3D c"clk"; + const CLK_NAME: &CStr =3D c_str!("clk"); =20 let dev =3D addr_of_mut!(*self).cast::(); // SAFETY: @@ -598,7 +599,7 @@ pub fn post_load(&mut self, _version_id: u32) -> Result= <(), ()> { let dev: *mut DeviceState =3D qdev_new(PL011State::TYPE_INFO.name); let sysbus: *mut SysBusDevice =3D dev.cast::(); =20 - qdev_prop_set_chr(dev, c"chardev".as_ptr(), chr); + qdev_prop_set_chr(dev, c_str!("chardev").as_ptr(), chr); sysbus_realize_and_unref(sysbus, addr_of!(error_fatal) as *mut *mu= t Error); sysbus_mmio_map(sysbus, 0, addr); sysbus_connect_irq(sysbus, 0, irq); diff --git a/rust/hw/char/pl011/src/device_class.rs b/rust/hw/char/pl011/sr= c/device_class.rs index 27cabbd6651..8a2019e5345 100644 --- a/rust/hw/char/pl011/src/device_class.rs +++ b/rust/hw/char/pl011/src/device_class.rs @@ -2,14 +2,12 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 -use core::{ - ffi::{c_int, c_void}, - ptr::NonNull, -}; +use core::ptr::NonNull; +use std::os::raw::{c_int, c_void}; =20 use qemu_api::{ - bindings::*, vmstate_clock, vmstate_fields, vmstate_int32, vmstate_sub= sections, vmstate_uint32, - vmstate_uint32_array, vmstate_unused, zeroable::Zeroable, + bindings::*, c_str, vmstate_clock, vmstate_fields, vmstate_int32, vmst= ate_subsections, + vmstate_uint32, vmstate_uint32_array, vmstate_unused, zeroable::Zeroab= le, }; =20 use crate::device::{PL011State, PL011_FIFO_DEPTH}; @@ -24,7 +22,7 @@ extern "C" fn pl011_clock_needed(opaque: *mut c_void) -> = bool { =20 /// Migration subsection for [`PL011State`] clock. pub static VMSTATE_PL011_CLOCK: VMStateDescription =3D VMStateDescription { - name: c"pl011/clock".as_ptr(), + name: c_str!("pl011/clock").as_ptr(), version_id: 1, minimum_version_id: 1, needed: Some(pl011_clock_needed), @@ -43,7 +41,7 @@ extern "C" fn pl011_post_load(opaque: *mut c_void, versio= n_id: c_int) -> c_int { } =20 pub static VMSTATE_PL011: VMStateDescription =3D VMStateDescription { - name: c"pl011".as_ptr(), + name: c_str!("pl011").as_ptr(), version_id: 2, minimum_version_id: 2, post_load: Some(pl011_post_load), @@ -74,14 +72,14 @@ extern "C" fn pl011_post_load(opaque: *mut c_void, vers= ion_id: c_int) -> c_int { qemu_api::declare_properties! { PL011_PROPERTIES, qemu_api::define_property!( - c"chardev", + c_str!("chardev"), PL011State, char_backend, unsafe { &qdev_prop_chr }, CharBackend ), qemu_api::define_property!( - c"migrate-clk", + c_str!("migrate-clk"), PL011State, migrate_clock, unsafe { &qdev_prop_bool }, diff --git a/rust/hw/char/pl011/src/lib.rs b/rust/hw/char/pl011/src/lib.rs index a539062aa30..a98d5cf9574 100644 --- a/rust/hw/char/pl011/src/lib.rs +++ b/rust/hw/char/pl011/src/lib.rs @@ -41,12 +41,14 @@ extern crate bilge_impl; extern crate qemu_api; =20 +use qemu_api::c_str; + pub mod device; pub mod device_class; pub mod memory_ops; =20 -pub const TYPE_PL011: &::std::ffi::CStr =3D c"pl011"; -pub const TYPE_PL011_LUMINARY: &::std::ffi::CStr =3D c"pl011_luminary"; +pub const TYPE_PL011: &::std::ffi::CStr =3D c_str!("pl011"); +pub const TYPE_PL011_LUMINARY: &::std::ffi::CStr =3D c_str!("pl011_luminar= y"); =20 /// Offset of each register from the base memory address of the device. /// diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index 3b849f7c413..c950b008d59 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -3,6 +3,7 @@ _qemu_api_rs =3D static_library( structured_sources( [ 'src/lib.rs', + 'src/c_str.rs', 'src/definitions.rs', 'src/device_class.rs', 'src/vmstate.rs', @@ -18,6 +19,9 @@ _qemu_api_rs =3D static_library( ], ) =20 +rust.test('rust-qemu-api-tests', _qemu_api_rs, + suite: ['unit', 'rust']) + qemu_api =3D declare_dependency( link_with: _qemu_api_rs, dependencies: qemu_api_macros, diff --git a/rust/qemu-api/src/c_str.rs b/rust/qemu-api/src/c_str.rs new file mode 100644 index 00000000000..cc6d8dc1211 --- /dev/null +++ b/rust/qemu-api/src/c_str.rs @@ -0,0 +1,53 @@ +// Copyright 2024 Red Hat, Inc. +// Author(s): Paolo Bonzini +// SPDX-License-Identifier: GPL-2.0-or-later + +#[macro_export] +/// Given a string constant _without_ embedded or trailing NULs, return +/// a CStr. +/// +/// Needed for compatibility with Rust <1.77. +macro_rules! c_str { + ($str:expr) =3D> {{ + const STRING: &str =3D concat!($str, "\0"); + const BYTES: &[u8] =3D STRING.as_bytes(); + + // "for" is not allowed in const context... oh well, + // everybody loves some lisp. This could be turned into + // a procedural macro if this is a problem; alternatively + // Rust 1.72 makes CStr::from_bytes_with_nul a const function. + const fn f(b: &[u8], i: usize) { + if i =3D=3D b.len() - 1 { + } else if b[i] =3D=3D 0 { + panic!("c_str argument contains NUL") + } else { + f(b, i + 1) + } + } + f(BYTES, 0); + + // SAFETY: absence of NULs apart from the final byte was checked a= bove + unsafe { std::ffi::CStr::from_bytes_with_nul_unchecked(BYTES) } + }}; +} + +#[cfg(test)] +mod tests { + use std::ffi::CStr; + + use crate::c_str; + + #[test] + fn test_cstr_macro() { + let good =3D c_str!("=F0=9F=A6=80"); + let good_bytes =3D b"\xf0\x9f\xa6\x80\0"; + assert_eq!(good.to_bytes_with_nul(), good_bytes); + } + + #[test] + fn test_cstr_macro_const() { + const GOOD: &CStr =3D c_str!("=F0=9F=A6=80"); + const GOOD_BYTES: &[u8] =3D b"\xf0\x9f\xa6\x80\0"; + assert_eq!(GOOD.to_bytes_with_nul(), GOOD_BYTES); + } +} diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index ed840ee2f72..e6bd953e10b 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -29,6 +29,7 @@ unsafe impl Sync for bindings::VMStateDescription {} unsafe impl Sync for bindings::VMStateField {} unsafe impl Sync for bindings::VMStateInfo {} =20 +pub mod c_str; pub mod definitions; pub mod device_class; pub mod vmstate; diff --git a/rust/qemu-api/src/vmstate.rs b/rust/qemu-api/src/vmstate.rs index 5dd783a902a..0aaaef1c7c8 100644 --- a/rust/qemu-api/src/vmstate.rs +++ b/rust/qemu-api/src/vmstate.rs @@ -14,7 +14,7 @@ macro_rules! vmstate_unused_buffer { ($field_exists_fn:expr, $version_id:expr, $size:expr) =3D> {{ $crate::bindings::VMStateField { - name: c"unused".as_ptr(), + name: c_str!("unused").as_ptr(), err_hint: ::core::ptr::null(), offset: 0, size: $size, diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index c7089f0cf21..381ac84657b 100644 --- a/rust/qemu-api/tests/tests.rs +++ b/rust/qemu-api/tests/tests.rs @@ -6,7 +6,7 @@ =20 use qemu_api::{ bindings::*, - declare_properties, define_property, + c_str, declare_properties, define_property, definitions::{Class, ObjectImpl}, device_class_init, zeroable::Zeroable, @@ -16,7 +16,7 @@ fn test_device_decl_macros() { // Test that macros can compile. pub static VMSTATE: VMStateDescription =3D VMStateDescription { - name: c"name".as_ptr(), + name: c_str!("name").as_ptr(), unmigratable: true, ..Zeroable::ZERO }; @@ -36,7 +36,7 @@ pub struct DummyClass { declare_properties! { DUMMY_PROPERTIES, define_property!( - c"migrate-clk", + c_str!("migrate-clk"), DummyState, migrate_clock, unsafe { &qdev_prop_bool }, @@ -55,7 +55,7 @@ pub struct DummyClass { impl ObjectImpl for DummyState { type Class =3D DummyClass; const TYPE_INFO: qemu_api::bindings::TypeInfo =3D qemu_api::type_i= nfo! { Self }; - const TYPE_NAME: &'static CStr =3D c"dummy"; + const TYPE_NAME: &'static CStr =3D c_str!("dummy"); const PARENT_TYPE_NAME: Option<&'static CStr> =3D Some(TYPE_DEVICE= ); const ABSTRACT: bool =3D false; const INSTANCE_INIT: Option =3D None; --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872480; cv=none; d=zohomail.com; s=zohoarc; b=NQsg6vAoONyR09myPgZnZfJqkZpXnJFESrHoM3e/OwHHvystZjUDHtSH3z24pVVZuBkimw6rFPdyKM9/r2TsEacHrLsMYydgIhUHjwm8Uhf+PRD/h0I0Ih9qSKzkQUfV/IqlrOU+w9uOyJR2MZhCkLspvXipHbtQb//cIxP9c0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872480; 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=2wB6JRp5b76OAUvoiYkeVBQK6MMDnpjCaH4KljLaOxY=; b=F5Ia2sNFePbZl05UoqbC9WoSf9oZK5CyUqOW6IsSdM3rqiIO2yZt1tEHqg/KO9FcdYDfSdJAeJEudLM+HnDyc1HAxzHqagi1XTITkYgJkDJHgeEemnbH8qbRUOTj1xezpKD7DRzNgjc1KoIcmYsAXz3RF3eItHFOZz6XftILPOY= 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 1729872480440883.3142015539438; Fri, 25 Oct 2024 09:08:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mn5-000305-BI; Fri, 25 Oct 2024 12:03:55 -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 1t4Mmy-0002ln-Ic for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:03:49 -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 1t4Mmv-0004sq-9d for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:03:47 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-231-eKNnQe29MVO3kyTPqm8Z7Q-1; Fri, 25 Oct 2024 12:03:43 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5c94862c3adso1546656a12.3 for ; Fri, 25 Oct 2024 09:03:43 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb625810bsm753117a12.14.2024.10.25.09.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872224; 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=2wB6JRp5b76OAUvoiYkeVBQK6MMDnpjCaH4KljLaOxY=; b=WoZv2A0dNQrAj28jVKA7wdUtQHVUaxPCSGVAByGz8ao5rDhnAYfUlDoIF6B1PvsduTPz3y 3I63R3ThEwZHIYQ/8dxMN/i/StJIQ4u9ptbtStLr/zCKinOSwJhtKFxAaTXqm46fDh8hpl hH9OJtauCezemmxGMqDhI3/iSb4/1sM= X-MC-Unique: eKNnQe29MVO3kyTPqm8Z7Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872220; x=1730477020; 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=2wB6JRp5b76OAUvoiYkeVBQK6MMDnpjCaH4KljLaOxY=; b=rhekqGN5I6zl+o89bgdkMhaL0S8IuHp2+5isz0o7Q/4qK//bO4pmczolqmvHhs2O9Y jrZXMu8KKMAhg2NY3jmu2bTP5cwNiYSM7l/TPxEpR+xhNcIid/Fj7yVgl/K7VzjhDOwK 9gAM0N2GrBwCYmonxdggU+hTYpwYtj3UT2otm+bksuZ6rUR3Qog8B+ElXLdC1JijXPsp RI81BZV71mw1slTkAxuqJIf3nQVnPwBt0YbL2bUOCQvQqr6XJSXrjoHQAFeMnEk0K0Ng P/oe8UJmu0aJslUIRDQggeef9m/yJBNCRhDASqnb6Fr/1jyTtExxR4nxrETtIt9E5mRL /Qew== X-Gm-Message-State: AOJu0YzqtB5BjWOX+Pnu2krFJYaocX+5pkZTv48PMXPBXIqMX8gNFb8b WlVQHBzZqT3kPjcaF60M+MU0Snhsy1NhawLLX65wSMSxDU9iu0JG8OMgSM/nSGlj3NjgCJJkwNJ dTiXRf5dB7acaZAfdfhez7IZS4QuAVdLa2XwE4ZfOYMoZdsQNfPncJ4G6yt5PkyLpZio5MjtJLb 6nLuVbCNsdsIDS6WKPXxeK/fAL5jFR+kWhiPD6B2s= X-Received: by 2002:a05:6402:84a:b0:5c9:3ff:2734 with SMTP id 4fb4d7f45d1cf-5cb8ac86aa0mr7150387a12.12.1729872220178; Fri, 25 Oct 2024 09:03:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGn8jOUSXxfcx9veK5F38rxLJDSO0g3t7TLjKEjwQ1Cc75UQgwroyeIj9UnQYnzFQ1bH6e91Q== X-Received: by 2002:a05:6402:84a:b0:5c9:3ff:2734 with SMTP id 4fb4d7f45d1cf-5cb8ac86aa0mr7150354a12.12.1729872219623; Fri, 25 Oct 2024 09:03:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 12/23] rust: silence unknown warnings for the sake of old compilers Date: Fri, 25 Oct 2024 18:01:57 +0200 Message-ID: <20241025160209.194307-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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.697, 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: 1729872481474116600 Content-Type: text/plain; charset="utf-8" Occasionally, we may need to silence warnings and clippy lints that were only introduced in newer Rust compiler versions. However, this would fail when compiling with an older rustc: error: unknown lint: `non_local_definitions` --> rust/qemu-api/rust-qemu-api-tests.p/structured/offset_of.rs:79:17 So by default we need to block the unknown_lints warning. To avoid misspelled lints or other similar issues, re-enable it in the CI job that uses nightly rust. Signed-off-by: Paolo Bonzini Tested-by: Zhao Liu --- meson.build | 8 ++++++++ .gitlab-ci.d/buildtest.yml | 2 +- meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index e819148f36c..69b8367eb3c 100644 --- a/meson.build +++ b/meson.build @@ -3327,6 +3327,14 @@ if have_rust and have_system # Prohibit code that is forbidden in Rust 2024 rustc_args +=3D ['-D', 'unsafe_op_in_unsafe_fn'] =20 + # Occasionally, we may need to silence warnings and clippy lints that + # were only introduced in newer Rust compiler versions. Do not croak + # in that case; a CI job with rust_strict_lints =3D=3D true ensures that + # we do not have misspelled allow() attributes. + if not get_option('strict_rust_lints') + rustc_args +=3D ['-A', 'unknown_lints'] + endif + # Apart from procedural macros, our Rust executables will often link # with C code, so include all the libraries that C code needs. This # is safe; https://github.com/rust-lang/rust/pull/54675 says that diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml index 19ba5b9c818..aba65ff833a 100644 --- a/.gitlab-ci.d/buildtest.yml +++ b/.gitlab-ci.d/buildtest.yml @@ -128,7 +128,7 @@ build-system-fedora-rust-nightly: job: amd64-fedora-rust-nightly-container variables: IMAGE: fedora-rust-nightly - CONFIGURE_ARGS: --disable-docs --enable-rust + CONFIGURE_ARGS: --disable-docs --enable-rust --enable-strict-rust-lints TARGETS: aarch64-softmmu MAKE_CHECK_ARGS: check-build allow_failure: true diff --git a/meson_options.txt b/meson_options.txt index 0ee4d7bb86b..e46199a3232 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -376,3 +376,5 @@ option('x86_version', type : 'combo', choices : ['0', '= 1', '2', '3', '4'], value =20 option('rust', type: 'feature', value: 'disabled', description: 'Rust support') +option('strict_rust_lints', type: 'boolean', value: false, + description: 'Enable stricter set of Rust warnings') diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 6d08605b771..e898b20307d 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -47,6 +47,8 @@ meson_options_help() { printf "%s\n" ' getrandom()' printf "%s\n" ' --enable-safe-stack SafeStack Stack Smash Protecti= on (requires' printf "%s\n" ' clang/llvm and coroutine backe= nd ucontext)' + printf "%s\n" ' --enable-strict-rust-lints' + printf "%s\n" ' Enable stricter set of Rust wa= rnings' printf "%s\n" ' --enable-strip Strip targets on install' printf "%s\n" ' --enable-tcg-interpreter TCG with bytecode interpreter = (slow)' printf "%s\n" ' --enable-trace-backends=3DCHOICES' @@ -490,6 +492,8 @@ _meson_option_parse() { --disable-spice-protocol) printf "%s" -Dspice_protocol=3Ddisabled ;; --enable-stack-protector) printf "%s" -Dstack_protector=3Denabled ;; --disable-stack-protector) printf "%s" -Dstack_protector=3Ddisabled ;; + --enable-strict-rust-lints) printf "%s" -Dstrict_rust_lints=3Dtrue ;; + --disable-strict-rust-lints) printf "%s" -Dstrict_rust_lints=3Dfalse ;; --enable-strip) printf "%s" -Dstrip=3Dtrue ;; --disable-strip) printf "%s" -Dstrip=3Dfalse ;; --sysconfdir=3D*) quote_sh "-Dsysconfdir=3D$2" ;; --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872480; cv=none; d=zohomail.com; s=zohoarc; b=UCjwrIhySZVSn8E7ejAbOK53ljsQnCvPB0ZKOlR91MhIBnG/SLcbdHus2qFpr0xsFd5jD0aNbizA3jJa3ZSI3pP7oQ7C+rD4WXHgYsAcgMaRi6W8yyBLHVZz0x/r/byTiN4tTZqM3+D7pWi9UCseg+ksltOP5hbXXVHU6Ek0nBY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872480; 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=tgWG4QrvBYKougesQ0BiWi02RU29Y/LaKzz9PJv7isg=; b=c58kNOXzL3JklGTnQd1tcxYUaaM08Tlb+tAujHd6Qc1UlKFLnwQz0vb3t8zJ3RBUDKQzWz+qHlg6nnlLv/fwp3yKFpotWyotOB0twZNEgkLCHhrv6/0LiECuhKAKEolRheK1eb7pCz6c8oWmtNwHX5F1jkiFsl+cyXVLtveyZOk= 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 1729872480538825.4618674168387; Fri, 25 Oct 2024 09:08:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mn9-0003AM-P5; Fri, 25 Oct 2024 12:03:59 -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 1t4Mn7-00034n-9Z for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:03:57 -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 1t4Mn3-0004tO-Rs for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:03:56 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-681-xeA84wW0NZSd-cq8vIT8mw-1; Fri, 25 Oct 2024 12:03:52 -0400 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5c94862c3adso1546771a12.3 for ; Fri, 25 Oct 2024 09:03:51 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb62c22d1sm757768a12.45.2024.10.25.09.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872233; 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=tgWG4QrvBYKougesQ0BiWi02RU29Y/LaKzz9PJv7isg=; b=gbeqpIV137bsPlLR5eq3l6s9e36dPWXKj28JaDWI4v9fYVL/6bN3v15b1x4KP9q6roZgmc NM31hw9SkI7aAjIAAVxKTJ8iAJGXenH1Yi7Ojl06bOqTTNd2EpRra7HUFV+LqlFEYKm4/N gkpe8kUOEQGehBhgdDxIwejyjylp+as= X-MC-Unique: xeA84wW0NZSd-cq8vIT8mw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872227; x=1730477027; 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=tgWG4QrvBYKougesQ0BiWi02RU29Y/LaKzz9PJv7isg=; b=Jz0ex6wPvIKVDTxVnDJ7Pn8Ri0dMdifBl5fOGSM9wy+IfaGxsJ6enTv0O8NSmFWYsX gRU9kL3Jr5i9oRvqMXdUgiB9YrwCPnqHVijGLJW7lC2C9CGTjK7fDske5aHefziA2Doh Y48tJ7WG7q5kIFilmuzoEOFoUeIu7xjyX4zAZTWn0hyE8YegURmhRB8AQn9Shvgi2B/i DYoWgbFrqtUQDa3lRwaMyg6yjK3BHr5+wNez0eP0UuxyLUHL7J4lfCycXeTTsUyvlckc tYU2kMY5GlN/e5SGBkkvIFWB6XGXQmXUhjcpLBxiSOgsA0xY2E5RAM4Tdx0HSf+47yCD fduw== X-Gm-Message-State: AOJu0YxNo8RHkrYgbLK4LgvufWrNhPYnEF2PvSs7BxVlstwQRcB1qs9f +UuvmZHbXcR2R0ucxl6FZqgMqjrC+k1O4cmQMG4bPTeR9/b6g/nqDw5Ct0P25eBWGJqIyrw76PJ kDaxdYgQuoB1Nq9B/x3XfW8sGyXEs7RQPUWdCMK+/iDlxV6nIzU0aQQ5ofunaRIPZsnu+7ONfa0 jRfSX9/iBvwHDqMKDlpVcpWr6AHlwYZ/QC37Xmg3Q= X-Received: by 2002:a05:6402:c4b:b0:5c9:57bd:e9d with SMTP id 4fb4d7f45d1cf-5cb8acfa774mr8984833a12.19.1729872227250; Fri, 25 Oct 2024 09:03:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFo+IpPCgXFxnI+vBxFyzloxpIcZza3hwhd1qSntwAhAWRmUDA/ncpT9h+QhOtdjHZDMF6+3Q== X-Received: by 2002:a05:6402:c4b:b0:5c9:57bd:e9d with SMTP id 4fb4d7f45d1cf-5cb8acfa774mr8984785a12.19.1729872226726; Fri, 25 Oct 2024 09:03:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 13/23] rust: synchronize dependencies between subprojects and Cargo.lock Date: Fri, 25 Oct 2024 18:01:58 +0200 Message-ID: <20241025160209.194307-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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.697, 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: 1729872481512116600 Content-Type: text/plain; charset="utf-8" The next commit will introduce a new build.rs dependency for rust/qemu-api, version_check. Before adding it, ensure that all dependencies are synchronized between the Meson- and cargo-based build systems. Note that it's not clear whether in the long term we'll use Cargo for anything; it seems that the three main uses (clippy, rustfmt, rustdoc) can all be invoked manually---either via glue code in QEMU, or by extending Meson to gain the relevant functionality. However, for the time being we're stuck with Cargo so it should at least look at the same code as the rest of the build system. Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao Reviewed-by: Zhao Liu Tested-by: Zhao Liu --- rust/hw/char/pl011/Cargo.lock | 3 +++ rust/qemu-api-macros/Cargo.lock | 9 ++++--- rust/qemu-api/Cargo.lock | 47 +++++++++++++++++++++++++++++++++ rust/qemu-api/Cargo.toml | 1 + 4 files changed, 56 insertions(+), 4 deletions(-) diff --git a/rust/hw/char/pl011/Cargo.lock b/rust/hw/char/pl011/Cargo.lock index b58cebb186e..9f43b33e8b8 100644 --- a/rust/hw/char/pl011/Cargo.lock +++ b/rust/hw/char/pl011/Cargo.lock @@ -91,6 +91,9 @@ dependencies =3D [ [[package]] name =3D "qemu_api" version =3D "0.1.0" +dependencies =3D [ + "qemu_api_macros", +] =20 [[package]] name =3D "qemu_api_macros" diff --git a/rust/qemu-api-macros/Cargo.lock b/rust/qemu-api-macros/Cargo.l= ock index fdc0fce116c..f989e25829f 100644 --- a/rust/qemu-api-macros/Cargo.lock +++ b/rust/qemu-api-macros/Cargo.lock @@ -4,9 +4,9 @@ version =3D 3 =20 [[package]] name =3D "proc-macro2" -version =3D "1.0.86" +version =3D "1.0.84" source =3D "registry+https://github.com/rust-lang/crates.io-index" -checksum =3D "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae10= 3b77" +checksum =3D "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a= 49d6" dependencies =3D [ "unicode-ident", ] @@ -18,6 +18,7 @@ dependencies =3D [ "proc-macro2", "quote", "syn", + "unicode-ident", ] =20 [[package]] @@ -31,9 +32,9 @@ dependencies =3D [ =20 [[package]] name =3D "syn" -version =3D "2.0.72" +version =3D "2.0.66" source =3D "registry+https://github.com/rust-lang/crates.io-index" -checksum =3D "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7= a8af" +checksum =3D "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cd= cff5" dependencies =3D [ "proc-macro2", "quote", diff --git a/rust/qemu-api/Cargo.lock b/rust/qemu-api/Cargo.lock index e9c51a243a8..e407911cdd1 100644 --- a/rust/qemu-api/Cargo.lock +++ b/rust/qemu-api/Cargo.lock @@ -2,6 +2,53 @@ # It is not intended for manual editing. version =3D 3 =20 +[[package]] +name =3D "proc-macro2" +version =3D "1.0.84" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a= 49d6" +dependencies =3D [ + "unicode-ident", +] + [[package]] name =3D "qemu_api" version =3D "0.1.0" +dependencies =3D [ + "qemu_api_macros", +] + +[[package]] +name =3D "qemu_api_macros" +version =3D "0.1.0" +dependencies =3D [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name =3D "quote" +version =3D "1.0.36" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208ac= aca7" +dependencies =3D [ + "proc-macro2", +] + +[[package]] +name =3D "syn" +version =3D "2.0.66" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cd= cff5" +dependencies =3D [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name =3D "unicode-ident" +version =3D "1.0.12" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0f= ee4b" diff --git a/rust/qemu-api/Cargo.toml b/rust/qemu-api/Cargo.toml index 3677def3fe2..db594c64083 100644 --- a/rust/qemu-api/Cargo.toml +++ b/rust/qemu-api/Cargo.toml @@ -14,6 +14,7 @@ keywords =3D [] categories =3D [] =20 [dependencies] +qemu_api_macros =3D { path =3D "../qemu-api-macros" } =20 [features] default =3D [] --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872292; cv=none; d=zohomail.com; s=zohoarc; b=CLV7Cr/uTbUlEM6Jj1YgvAHc9zkF0YI03WqWqz1joca60UrA08XXUv7xIpTg4QYM0eMQmK/irRV8TPjAcEXB/+F1vRSu7+fgrF91J+QJxBbZ60skWAaEZqwdXf9N+Tu3vLjCRqrCg3D3DB2OgN+hN5GWAn8jukEREqu+wHwvwWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872292; 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=qkFMNQ5Htp0kKrDfk6aFD0NUD+y1hI6PGKaCy6DDY4c=; b=Epa8lha1NMEOqC7eS2u1F9AGZsNSBgLd0vDoiheUEIwJjEpz2Nlmf3nZGyfKjEPXz+oA8a5o9SnvS//2I5MVZ75cxod8+m0bEp2hHLpj4FhWuDsadptJPFP23ln931D2zZAQyezzmdNGf8Hgg0cL8CaAlom28dt5AJo/y1d9Eqc= 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 1729872292344582.6319303347491; Fri, 25 Oct 2024 09:04:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4MnG-0003Y5-S1; Fri, 25 Oct 2024 12:04:07 -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 1t4MnD-0003Og-LT for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:03 -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 1t4MnB-0004tl-Si for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:03 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-253-9kq-ZvKpNU-f-2Ksc9hqEQ-1; Fri, 25 Oct 2024 12:03:59 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a9a1828916fso280312466b.1 for ; Fri, 25 Oct 2024 09:03:58 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1e75fff3sm85531566b.29.2024.10.25.09.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872241; 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=qkFMNQ5Htp0kKrDfk6aFD0NUD+y1hI6PGKaCy6DDY4c=; b=MwrMlsupbrIi4u/4f+FohsmMtPGbEQxepfbH9feBBgnI6bVPdilBXoS+6+zed9XsN23Xgv u9Cfc5TPON6DAsr6dbkZStvDGANlmLP2mv+ZTAoqHjB90rrhpXmUaEaAfTIx0pdGngmR/P W6PoA3p/rb91iThxbTL8HnLGhaxQU0U= X-MC-Unique: 9kq-ZvKpNU-f-2Ksc9hqEQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872237; x=1730477037; 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=qkFMNQ5Htp0kKrDfk6aFD0NUD+y1hI6PGKaCy6DDY4c=; b=Q9AqTOXdvgu+evX7EVNBrSK6thNYd+Rzn5PRogBBYrnmzqv1AoSyI5kjeViMuQciGh jY63bg+Kaw89qsOetZr276YVQpPYZm0ZOyuvtsmSfVFozCQ4FFlAQSYPP2ASBHmgfFWx k9QG5R7IgxiSMNP6sROai6ZAArCTrvW+GDOtHPoby1yJRHrUoXIWj7m8i2ClvvguWLv1 EWKgNYYJEJ7SHHesGG2awdqfwDDX7jHFH98cJhu+NYcJVDzXVMxMjzq3Zb7D3HOJQXjb aqZJR1iqpLCylUycjIWFcAJ7Dy92C/ULdKFumZPRx/6Z1yTszmS5eUBVN+/KzpCpxtIZ qlIg== X-Gm-Message-State: AOJu0YxZCGIUOCSbkGCxFeTS3IqRWZOFMwc4Fy3iRPy2UYdvgOfKdj9q 3ZG0jAqPksogEAvTBjZvNmnte1LQOqGHD3La0y3UA/X45WJESNDyyHBBE/PUA9SQRiY3ZvwOVnG 0wC7z8M9UcAIRNJ2rQy72ya149cRoxlm4B6A/R5eayt1sxZqPjqKIPDdSXlK6BcQ2KBFAM4tQKA 8FW6OCzJrO+cGG09BVjMU2Gu8XYFDJViVvXagfC5E= X-Received: by 2002:a17:906:794b:b0:a9a:3c94:23c4 with SMTP id a640c23a62f3a-a9de38e3034mr2948566b.22.1729872235094; Fri, 25 Oct 2024 09:03:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGX+5M21UcmYQt+zFxFYDnXhKyrG0csm0H1HWvSp66jGGSxFUavnAchg9Wt46ZpndRAHIqkPQ== X-Received: by 2002:a17:906:794b:b0:a9a:3c94:23c4 with SMTP id a640c23a62f3a-a9de38e3034mr2943366b.22.1729872234499; Fri, 25 Oct 2024 09:03:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 14/23] rust: create a cargo workspace Date: Fri, 25 Oct 2024 18:01:59 +0200 Message-ID: <20241025160209.194307-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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.697, 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: 1729872294506116600 Content-Type: text/plain; charset="utf-8" Workspaces allows tracking dependencies for multiple crates at once, by having a single Cargo.lock file at the top of the rust/ tree. Because QEMU's Cargo.lock files have to be synchronized with the versions of crates in subprojects/, using a workspace avoids the need to copy over the Cargo.lock file when adding a new device (and thus a new crate) under rust/hw/. In addition, workspaces let cargo download and build dependencies just once. While right now we have one leaf crate (hw/char/pl011), this will not be the case once more devices are added. Signed-off-by: Paolo Bonzini Reviewed-by: Junjie Mao Reviewed-by: Zhao Liu Tested-by: Zhao Liu --- rust/{hw/char/pl011 =3D> }/Cargo.lock | 0 rust/Cargo.toml | 7 ++++ rust/hw/char/pl011/Cargo.toml | 3 -- rust/qemu-api-macros/Cargo.lock | 48 ------------------------- rust/qemu-api-macros/Cargo.toml | 3 -- rust/qemu-api/Cargo.lock | 54 ----------------------------- rust/qemu-api/Cargo.toml | 3 -- 7 files changed, 7 insertions(+), 111 deletions(-) rename rust/{hw/char/pl011 =3D> }/Cargo.lock (100%) create mode 100644 rust/Cargo.toml delete mode 100644 rust/qemu-api-macros/Cargo.lock delete mode 100644 rust/qemu-api/Cargo.lock diff --git a/rust/hw/char/pl011/Cargo.lock b/rust/Cargo.lock similarity index 100% rename from rust/hw/char/pl011/Cargo.lock rename to rust/Cargo.lock diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 00000000000..0c94d5037da --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,7 @@ +[workspace] +resolver =3D "2" +members =3D [ + "qemu-api-macros", + "qemu-api", + "hw/char/pl011", +] diff --git a/rust/hw/char/pl011/Cargo.toml b/rust/hw/char/pl011/Cargo.toml index b089e3dded6..a373906b9fb 100644 --- a/rust/hw/char/pl011/Cargo.toml +++ b/rust/hw/char/pl011/Cargo.toml @@ -21,6 +21,3 @@ bilge =3D { version =3D "0.2.0" } bilge-impl =3D { version =3D "0.2.0" } qemu_api =3D { path =3D "../../../qemu-api" } qemu_api_macros =3D { path =3D "../../../qemu-api-macros" } - -# Do not include in any global workspace -[workspace] diff --git a/rust/qemu-api-macros/Cargo.lock b/rust/qemu-api-macros/Cargo.l= ock deleted file mode 100644 index f989e25829f..00000000000 --- a/rust/qemu-api-macros/Cargo.lock +++ /dev/null @@ -1,48 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version =3D 3 - -[[package]] -name =3D "proc-macro2" -version =3D "1.0.84" -source =3D "registry+https://github.com/rust-lang/crates.io-index" -checksum =3D "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a= 49d6" -dependencies =3D [ - "unicode-ident", -] - -[[package]] -name =3D "qemu_api_macros" -version =3D "0.1.0" -dependencies =3D [ - "proc-macro2", - "quote", - "syn", - "unicode-ident", -] - -[[package]] -name =3D "quote" -version =3D "1.0.36" -source =3D "registry+https://github.com/rust-lang/crates.io-index" -checksum =3D "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208ac= aca7" -dependencies =3D [ - "proc-macro2", -] - -[[package]] -name =3D "syn" -version =3D "2.0.66" -source =3D "registry+https://github.com/rust-lang/crates.io-index" -checksum =3D "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cd= cff5" -dependencies =3D [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name =3D "unicode-ident" -version =3D "1.0.12" -source =3D "registry+https://github.com/rust-lang/crates.io-index" -checksum =3D "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0f= ee4b" diff --git a/rust/qemu-api-macros/Cargo.toml b/rust/qemu-api-macros/Cargo.t= oml index 144cc3650fa..f8d6d03609f 100644 --- a/rust/qemu-api-macros/Cargo.toml +++ b/rust/qemu-api-macros/Cargo.toml @@ -20,6 +20,3 @@ proc-macro =3D true proc-macro2 =3D "1" quote =3D "1" syn =3D "2" - -# Do not include in any global workspace -[workspace] diff --git a/rust/qemu-api/Cargo.lock b/rust/qemu-api/Cargo.lock deleted file mode 100644 index e407911cdd1..00000000000 --- a/rust/qemu-api/Cargo.lock +++ /dev/null @@ -1,54 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version =3D 3 - -[[package]] -name =3D "proc-macro2" -version =3D "1.0.84" -source =3D "registry+https://github.com/rust-lang/crates.io-index" -checksum =3D "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a= 49d6" -dependencies =3D [ - "unicode-ident", -] - -[[package]] -name =3D "qemu_api" -version =3D "0.1.0" -dependencies =3D [ - "qemu_api_macros", -] - -[[package]] -name =3D "qemu_api_macros" -version =3D "0.1.0" -dependencies =3D [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name =3D "quote" -version =3D "1.0.36" -source =3D "registry+https://github.com/rust-lang/crates.io-index" -checksum =3D "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208ac= aca7" -dependencies =3D [ - "proc-macro2", -] - -[[package]] -name =3D "syn" -version =3D "2.0.66" -source =3D "registry+https://github.com/rust-lang/crates.io-index" -checksum =3D "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cd= cff5" -dependencies =3D [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name =3D "unicode-ident" -version =3D "1.0.12" -source =3D "registry+https://github.com/rust-lang/crates.io-index" -checksum =3D "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0f= ee4b" diff --git a/rust/qemu-api/Cargo.toml b/rust/qemu-api/Cargo.toml index db594c64083..e092f61e8f3 100644 --- a/rust/qemu-api/Cargo.toml +++ b/rust/qemu-api/Cargo.toml @@ -20,8 +20,5 @@ qemu_api_macros =3D { path =3D "../qemu-api-macros" } default =3D [] allocator =3D [] =20 -# Do not include in any global workspace -[workspace] - [lints.rust] unexpected_cfgs =3D { level =3D "warn", check-cfg =3D ['cfg(MESON)', 'cfg(= HAVE_GLIB_WITH_ALIGNED_ALLOC)'] } --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872291; cv=none; d=zohomail.com; s=zohoarc; b=kZvNSpESHQxQOjcTsyILMJn1D6mJxBJTIjppFfXsqjsJoQQzK88SKQ1qahvEfAV3j8zV8AbOQe+hsundvnuGUChv01HWKMxXQw7IpAjPFhYhimLepwAMetngwRsUBF2jfdwfkFSj9oqBO/6FCjtx5UksUTj7t0VWC4lfzxX2SRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872291; 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=+5UXLeSNTKZFIyyJrO31yi9+dqN57JHc1LDcaUTPJDk=; b=mT8DDPBVRJc5BzwhME3yK2VQg85jAXLLRB1sdeXEA4UHBC939707kKo1Pz5xGR2aOCNpZVTiYMkumA14a5vUJlBQ+hV9iMZVqFyfkSM+NDYPRvtiwmqvSqmstj169AfTyR1MFYtciTC6S1coJczNoO0hhBY/ZaPOrmTXBhCqLjI= 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 1729872291898786.2603268894035; Fri, 25 Oct 2024 09:04:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mnk-0003qy-Sw; Fri, 25 Oct 2024 12:04: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 1t4MnN-0003j3-L7 for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4MnH-0004uJ-36 for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:10 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-272-Gi9L_qHiNxW3dXjd9m55Ew-1; Fri, 25 Oct 2024 12:04:05 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a99fc3e2285so146469766b.0 for ; Fri, 25 Oct 2024 09:04:04 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b3a08477bsm84055966b.201.2024.10.25.09.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872246; 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=+5UXLeSNTKZFIyyJrO31yi9+dqN57JHc1LDcaUTPJDk=; b=XO+lvWruqHDP0mv60nMaPinigPhdPza1W8e7VVnllKzosWS1mJyqKrZgWY33310tYtZXft E/67z5yAOoBlzI0sR3wRUnnxrgFu218yakdt4mLZ5fvwsMIqNrh2GC1Ht1Xc0x+WTDxVie mHopBpg439T1Kfh56crNCn5X5ykw/f4= X-MC-Unique: Gi9L_qHiNxW3dXjd9m55Ew-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872241; x=1730477041; 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=+5UXLeSNTKZFIyyJrO31yi9+dqN57JHc1LDcaUTPJDk=; b=XSeQ6gj/9V1juuQ3IFmO/PQedqqwfbjr3mh4t3ak0QgarEFxMl2pr9twIdkqr2UxHn BgRVb9YM3RmU2sfv9kZ1i6oLc1Ck8jw75PIqZeE6Dl1r+qYPRR9aeUXC5dJz8wfuNPgd Jgx5VYNgcBjwJWhmJ+4aRsxFMtaq5ivVNONWRMLDwgBc4I5dK9vw4W8lYYFYvNmOfxmL iyNx6dNNA8Bps8upBatuSR9gtEajY49mWojyF6Gnbyh2Oxs50jZSBw8uWpCB9qLNV50G 9UYOlux98nHbooBUOi/fm2vllCENVK/bkt/vao0HNUIICArdnUbvYyREaJOUdPivxGtb Bo7w== X-Gm-Message-State: AOJu0YzUgd0kNuJ4MrOvTbVavN+HveB1SlDyvbvM/hqJQ0rirKjRG4o4 jWZL1Q5c2gkGn743OasVkjMUdIfWoo5gJA2CV4pngMKAzqd6fwZh22AiQ2mM8x/qDuZnEp0gK65 qnj3K2LA6fgM591UR07DlRyZYQeJFP++2DHbMElMImn52Hezi4Dy7AvKCfzH2ckS/5XL/+CJPrv 6PPfZXT5SQIydp/Q2BqOhWYO4ZqXw48qmxwydYJwY= X-Received: by 2002:a17:907:7b97:b0:a9a:14fc:9868 with SMTP id a640c23a62f3a-a9abf845c7emr1011199166b.4.1729872240582; Fri, 25 Oct 2024 09:04:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYbCkXHSHn0pW3MitwYigUbxut1i9SGXK1VPt/u1JezpzIrvN6KNAV2yh56q907VieuHuq0Q== X-Received: by 2002:a17:907:7b97:b0:a9a:14fc:9868 with SMTP id a640c23a62f3a-a9abf845c7emr1011194966b.4.1729872239882; Fri, 25 Oct 2024 09:03:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 15/23] rust: introduce alternative implementation of offset_of! Date: Fri, 25 Oct 2024 18:02:00 +0200 Message-ID: <20241025160209.194307-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729872292619116600 Content-Type: text/plain; charset="utf-8" From: Junjie Mao offset_of! was stabilized in Rust 1.77.0. Use an alternative implemenation that was found on the Rust forums, and whose author agreed to license as MIT for use in QEMU. The alternative allows only one level of field access, but apart from this can be used just by replacing core::mem::offset_of! with qemu_api::offset_of!. The actual implementation of offset_of! is done in a declarative macro, but for simplicity and to avoid introducing an extra level of indentation, the trigger is a procedural macro #[derive(offsets)]. The procedural macro is perhaps a bit overengineered, but it helps introducing some idioms that will be useful in the future as well. Signed-off-by: Junjie Mao Co-developed-by: Paolo Bonzini Signed-off-by: Paolo Bonzini Tested-by: Zhao Liu --- rust/Cargo.lock | 1 + rust/hw/char/pl011/src/device.rs | 2 +- rust/qemu-api-macros/Cargo.toml | 2 +- rust/qemu-api-macros/src/lib.rs | 81 ++++++++- rust/qemu-api/Cargo.toml | 6 +- rust/qemu-api/build.rs | 9 + rust/qemu-api/meson.build | 12 +- rust/qemu-api/src/device_class.rs | 8 +- rust/qemu-api/src/lib.rs | 4 + rust/qemu-api/src/offset_of.rs | 161 ++++++++++++++++++ rust/qemu-api/src/vmstate.rs | 10 +- rust/qemu-api/tests/tests.rs | 1 + subprojects/packagefiles/syn-2-rs/meson.build | 1 + 13 files changed, 280 insertions(+), 18 deletions(-) create mode 100644 rust/qemu-api/src/offset_of.rs diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 9f43b33e8b8..c0c6069247a 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -93,6 +93,7 @@ name =3D "qemu_api" version =3D "0.1.0" dependencies =3D [ "qemu_api_macros", + "version_check", ] =20 [[package]] diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index 2d225d544de..bca727e37f0 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -55,7 +55,7 @@ impl DeviceId { } =20 #[repr(C)] -#[derive(Debug, qemu_api_macros::Object)] +#[derive(Debug, qemu_api_macros::Object, qemu_api_macros::offsets)] /// PL011 Device Model in QEMU pub struct PL011State { pub parent_obj: SysBusDevice, diff --git a/rust/qemu-api-macros/Cargo.toml b/rust/qemu-api-macros/Cargo.t= oml index f8d6d03609f..a8f7377106b 100644 --- a/rust/qemu-api-macros/Cargo.toml +++ b/rust/qemu-api-macros/Cargo.toml @@ -19,4 +19,4 @@ proc-macro =3D true [dependencies] proc-macro2 =3D "1" quote =3D "1" -syn =3D "2" +syn =3D { version =3D "2", features =3D ["extra-traits"] } diff --git a/rust/qemu-api-macros/src/lib.rs b/rust/qemu-api-macros/src/lib= .rs index a4bc5d01ee8..c2ea22101e4 100644 --- a/rust/qemu-api-macros/src/lib.rs +++ b/rust/qemu-api-macros/src/lib.rs @@ -3,8 +3,34 @@ // SPDX-License-Identifier: GPL-2.0-or-later =20 use proc_macro::TokenStream; -use quote::quote; -use syn::{parse_macro_input, DeriveInput}; +use proc_macro2::Span; +use quote::{quote, quote_spanned}; +use syn::{ + parse_macro_input, parse_quote, punctuated::Punctuated, token::Comma, = Data, DeriveInput, Field, + Fields, Ident, Type, Visibility, +}; + +struct CompileError(String, Span); + +impl From for proc_macro2::TokenStream { + fn from(err: CompileError) -> Self { + let CompileError(msg, span) =3D err; + quote_spanned! { span =3D> compile_error!(#msg); } + } +} + +fn is_c_repr(input: &DeriveInput, msg: &str) -> Result<(), CompileError> { + let expected =3D parse_quote! { #[repr(C)] }; + + if input.attrs.iter().any(|attr| attr =3D=3D &expected) { + Ok(()) + } else { + Err(CompileError( + format!("#[repr(C)] required for {}", msg), + input.ident.span(), + )) + } +} =20 #[proc_macro_derive(Object)] pub fn derive_object(input: TokenStream) -> TokenStream { @@ -21,3 +53,48 @@ pub fn derive_object(input: TokenStream) -> TokenStream { =20 TokenStream::from(expanded) } + +fn get_fields(input: &DeriveInput) -> Result<&Punctuated, Co= mpileError> { + if let Data::Struct(s) =3D &input.data { + if let Fields::Named(fs) =3D &s.fields { + Ok(&fs.named) + } else { + Err(CompileError( + "Cannot generate offsets for unnamed fields.".to_string(), + input.ident.span(), + )) + } + } else { + Err(CompileError( + "Cannot generate offsets for union or enum.".to_string(), + input.ident.span(), + )) + } +} + +#[rustfmt::skip::macros(quote)] +fn derive_offsets_or_error(input: DeriveInput) -> Result { + is_c_repr(&input, "#[derive(offsets)]")?; + + let name =3D &input.ident; + let fields =3D get_fields(&input)?; + let field_names: Vec<&Ident> =3D fields.iter().map(|f| f.ident.as_ref(= ).unwrap()).collect(); + let field_types: Vec<&Type> =3D fields.iter().map(|f| &f.ty).collect(); + let field_vis: Vec<&Visibility> =3D fields.iter().map(|f| &f.vis).coll= ect(); + + Ok(quote! { + ::qemu_api::with_offsets! { + struct #name { + #(#field_vis #field_names: #field_types,)* + } + } + }) +} + +#[proc_macro_derive(offsets)] +pub fn derive_offsets(input: TokenStream) -> TokenStream { + let input =3D parse_macro_input!(input as DeriveInput); + let expanded =3D derive_offsets_or_error(input).unwrap_or_else(Into::i= nto); + + TokenStream::from(expanded) +} diff --git a/rust/qemu-api/Cargo.toml b/rust/qemu-api/Cargo.toml index e092f61e8f3..cc716d75d46 100644 --- a/rust/qemu-api/Cargo.toml +++ b/rust/qemu-api/Cargo.toml @@ -16,9 +16,13 @@ categories =3D [] [dependencies] qemu_api_macros =3D { path =3D "../qemu-api-macros" } =20 +[build-dependencies] +version_check =3D "~0.9" + [features] default =3D [] allocator =3D [] =20 [lints.rust] -unexpected_cfgs =3D { level =3D "warn", check-cfg =3D ['cfg(MESON)', 'cfg(= HAVE_GLIB_WITH_ALIGNED_ALLOC)'] } +unexpected_cfgs =3D { level =3D "warn", check-cfg =3D ['cfg(MESON)', 'cfg(= HAVE_GLIB_WITH_ALIGNED_ALLOC)', + 'cfg(has_offset_of)'] } diff --git a/rust/qemu-api/build.rs b/rust/qemu-api/build.rs index 419b154c2d2..20f8f718b90 100644 --- a/rust/qemu-api/build.rs +++ b/rust/qemu-api/build.rs @@ -4,6 +4,8 @@ =20 use std::path::Path; =20 +use version_check as rustc; + fn main() { if !Path::new("src/bindings.rs").exists() { panic!( @@ -11,4 +13,11 @@ fn main() { (`ninja bindings.rs`) and copy them to src/bindings.rs, or bu= ild through meson." ); } + + // Check for available rustc features + if rustc::is_min_version("1.77.0").unwrap_or(false) { + println!("cargo:rustc-cfg=3Dhas_offset_of"); + } + + println!("cargo:rerun-if-changed=3Dbuild.rs"); } diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index c950b008d59..6f637af7b1b 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -1,3 +1,9 @@ +_qemu_api_cfg =3D ['--cfg', 'MESON'] +# _qemu_api_cfg +=3D ['--cfg', 'feature=3D"allocator"'] +if rustc.version().version_compare('>=3D1.77.0') + _qemu_api_cfg +=3D ['--cfg', 'has_offset_of'] +endif + _qemu_api_rs =3D static_library( 'qemu_api', structured_sources( @@ -6,6 +12,7 @@ _qemu_api_rs =3D static_library( 'src/c_str.rs', 'src/definitions.rs', 'src/device_class.rs', + 'src/offset_of.rs', 'src/vmstate.rs', 'src/zeroable.rs', ], @@ -13,10 +20,7 @@ _qemu_api_rs =3D static_library( ), override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', - rust_args: [ - '--cfg', 'MESON', - # '--cfg', 'feature=3D"allocator"', - ], + rust_args: _qemu_api_cfg, ) =20 rust.test('rust-qemu-api-tests', _qemu_api_rs, diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index cb4573ca6ef..56608c7f7fc 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -23,23 +23,23 @@ macro_rules! device_class_init { =20 #[macro_export] macro_rules! define_property { - ($name:expr, $state:ty, $field:expr, $prop:expr, $type:expr, default = =3D $defval:expr$(,)*) =3D> { + ($name:expr, $state:ty, $field:ident, $prop:expr, $type:expr, default = =3D $defval:expr$(,)*) =3D> { $crate::bindings::Property { // use associated function syntax for type checking name: ::std::ffi::CStr::as_ptr($name), info: $prop, - offset: ::core::mem::offset_of!($state, $field) as isize, + offset: $crate::offset_of!($state, $field) as isize, set_default: true, defval: $crate::bindings::Property__bindgen_ty_1 { u: $defval = as u64 }, ..$crate::zeroable::Zeroable::ZERO } }; - ($name:expr, $state:ty, $field:expr, $prop:expr, $type:expr$(,)*) =3D>= { + ($name:expr, $state:ty, $field:ident, $prop:expr, $type:expr$(,)*) =3D= > { $crate::bindings::Property { // use associated function syntax for type checking name: ::std::ffi::CStr::as_ptr($name), info: $prop, - offset: ::core::mem::offset_of!($state, $field) as isize, + offset: $crate::offset_of!($state, $field) as isize, set_default: false, ..$crate::zeroable::Zeroable::ZERO } diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index e6bd953e10b..aa8d16ec94b 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -32,6 +32,7 @@ unsafe impl Sync for bindings::VMStateInfo {} pub mod c_str; pub mod definitions; pub mod device_class; +pub mod offset_of; pub mod vmstate; pub mod zeroable; =20 @@ -169,3 +170,6 @@ unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { } } } + +#[cfg(has_offset_of)] +pub use core::mem::offset_of; diff --git a/rust/qemu-api/src/offset_of.rs b/rust/qemu-api/src/offset_of.rs new file mode 100644 index 00000000000..075e98f986b --- /dev/null +++ b/rust/qemu-api/src/offset_of.rs @@ -0,0 +1,161 @@ +// SPDX-License-Identifier: MIT + +/// This macro provides the same functionality as `core::mem::offset_of`, +/// except that only one level of field access is supported. The declarat= ion +/// of the struct must be wrapped with `with_offsets! { }`. +/// +/// It is needed because `offset_of!` was only stabilized in Rust 1.77. +#[cfg(not(has_offset_of))] +#[macro_export] +macro_rules! offset_of { + ($Container:ty, $field:ident) =3D> { + <$Container>::OFFSET_TO__.$field + }; +} + +/// A wrapper for struct declarations, that allows using `offset_of!` in +/// versions of Rust prior to 1.77 +#[macro_export] +macro_rules! with_offsets { + // This method to generate field offset constants comes from: + // + // https://play.rust-lang.org/?version=3Dstable&mode=3Ddebug&editi= on=3D2018&gist=3D10a22a9b8393abd7b541d8fc844bc0df + // + // used under MIT license with permission of Yandros aka Daniel Henry-= Mantilla + ( + $(#[$struct_meta:meta])* + $struct_vis:vis + struct $StructName:ident { + $( + $(#[$field_meta:meta])* + $field_vis:vis + $field_name:ident : $field_ty:ty + ),* + $(,)? + } + ) =3D> ( + #[cfg(not(has_offset_of))] + const _: () =3D { + struct StructOffsetsHelper(std::marker::PhantomData); + const END_OF_PREV_FIELD: usize =3D 0; + + // populate StructOffsetsHelper with associated consts, + // one for each field + $crate::with_offsets! { + @struct $StructName + @names [ $($field_name)* ] + @tys [ $($field_ty ,)*] + } + + // now turn StructOffsetsHelper's consts into a single stru= ct, + // applying field visibility. This provides better error mess= ages + // than if offset_of! used StructOffsetsHelper:: directly. + pub + struct StructOffsets { + $( + $field_vis + $field_name: usize, + )* + } + impl $StructName { + pub + const OFFSET_TO__: StructOffsets =3D StructOffsets { + $( + $field_name: StructOffsetsHelper::<$StructName>::$= field_name, + )* + }; + } + }; + ); + + ( + @struct $StructName:ident + @names [] + @tys [] + ) =3D> (); + + ( + @struct $StructName:ident + @names [$field_name:ident $($other_names:tt)*] + @tys [$field_ty:ty , $($other_tys:tt)*] + ) =3D> ( + #[allow(non_local_definitions)] + #[allow(clippy::modulo_one)] + impl StructOffsetsHelper<$StructName> { + #[allow(nonstandard_style)] + const $field_name: usize =3D { + const ALIGN: usize =3D std::mem::align_of::<$field_ty>(); + const TRAIL: usize =3D END_OF_PREV_FIELD % ALIGN; + END_OF_PREV_FIELD + (if TRAIL =3D=3D 0 { 0usize } else { A= LIGN - TRAIL }) + }; + } + const _: () =3D { + const END_OF_PREV_FIELD: usize =3D + StructOffsetsHelper::<$StructName>::$field_name + + std::mem::size_of::<$field_ty>() + ; + $crate::with_offsets! { + @struct $StructName + @names [$($other_names)*] + @tys [$($other_tys)*] + } + }; + ); +} + +#[cfg(test)] +mod tests { + use crate::offset_of; + + #[repr(C)] + struct Foo { + a: u16, + b: u32, + c: u64, + d: u16, + } + + #[repr(C)] + struct Bar { + pub a: u16, + pub b: u64, + c: Foo, + d: u64, + } + + crate::with_offsets! { + #[repr(C)] + struct Bar { + pub a: u16, + pub b: u64, + c: Foo, + d: u64, + } + } + + #[repr(C)] + pub struct Baz { + b: u32, + a: u8, + } + crate::with_offsets! { + #[repr(C)] + pub struct Baz { + b: u32, + a: u8, + } + } + + #[test] + fn test_offset_of() { + const OFFSET_TO_C: usize =3D offset_of!(Bar, c); + + assert_eq!(offset_of!(Bar, a), 0); + assert_eq!(offset_of!(Bar, b), 8); + assert_eq!(OFFSET_TO_C, 16); + assert_eq!(offset_of!(Bar, d), 40); + + assert_eq!(offset_of!(Baz, b), 0); + assert_eq!(offset_of!(Baz, a), 4); + } +} diff --git a/rust/qemu-api/src/vmstate.rs b/rust/qemu-api/src/vmstate.rs index 0aaaef1c7c8..b452d01ae3e 100644 --- a/rust/qemu-api/src/vmstate.rs +++ b/rust/qemu-api/src/vmstate.rs @@ -57,7 +57,7 @@ macro_rules! vmstate_single_test { .as_bytes() .as_ptr() as *const ::std::os::raw::c_char, err_hint: ::core::ptr::null(), - offset: ::core::mem::offset_of!($struct_name, $field_name), + offset: $crate::offset_of!($struct_name, $field_name), size: $size, start: 0, num: 0, @@ -134,7 +134,7 @@ macro_rules! vmstate_array { .as_bytes() .as_ptr() as *const ::std::os::raw::c_char, err_hint: ::core::ptr::null(), - offset: ::core::mem::offset_of!($struct_name, $field_name), + offset: $crate::offset_of!($struct_name, $field_name), size: $size, start: 0, num: $length as _, @@ -182,7 +182,7 @@ macro_rules! vmstate_struct_pointer_v { .as_bytes() .as_ptr() as *const ::std::os::raw::c_char, err_hint: ::core::ptr::null(), - offset: ::core::mem::offset_of!($struct_name, $field_name), + offset: $crate::offset_of!($struct_name, $field_name), size: ::core::mem::size_of::<*const $type>(), start: 0, num: 0, @@ -211,7 +211,7 @@ macro_rules! vmstate_array_of_pointer { info: $info, size: ::core::mem::size_of::<*const $type>(), flags: VMStateFlags(VMStateFlags::VMS_ARRAY.0 | VMStateFlags::= VMS_ARRAY_OF_POINTER.0), - offset: ::core::mem::offset_of!($struct_name, $field_name), + offset: $crate::offset_of!($struct_name, $field_name), err_hint: ::core::ptr::null(), start: 0, num_offset: 0, @@ -240,7 +240,7 @@ macro_rules! vmstate_array_of_pointer_to_struct { | VMStateFlags::VMS_STRUCT.0 | VMStateFlags::VMS_ARRAY_OF_POINTER.0, ), - offset: ::core::mem::offset_of!($struct_name, $field_name), + offset: $crate::offset_of!($struct_name, $field_name), err_hint: ::core::ptr::null(), start: 0, num_offset: 0, diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index 381ac84657b..7442f695646 100644 --- a/rust/qemu-api/tests/tests.rs +++ b/rust/qemu-api/tests/tests.rs @@ -21,6 +21,7 @@ fn test_device_decl_macros() { ..Zeroable::ZERO }; =20 + #[derive(qemu_api_macros::offsets)] #[repr(C)] #[derive(qemu_api_macros::Object)] pub struct DummyState { diff --git a/subprojects/packagefiles/syn-2-rs/meson.build b/subprojects/pa= ckagefiles/syn-2-rs/meson.build index a53335f3092..9f56ce1c24d 100644 --- a/subprojects/packagefiles/syn-2-rs/meson.build +++ b/subprojects/packagefiles/syn-2-rs/meson.build @@ -24,6 +24,7 @@ _syn_rs =3D static_library( '--cfg', 'feature=3D"printing"', '--cfg', 'feature=3D"clone-impls"', '--cfg', 'feature=3D"proc-macro"', + '--cfg', 'feature=3D"extra-traits"', ], dependencies: [ quote_dep, --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872594; cv=none; d=zohomail.com; s=zohoarc; b=oEYIfYaRaTOMgl5i7DKoVnC32IT4D71H3UyHc2MQIUajJJSGXuyM3F/XLKa1MXZsyE3y/QGKT6I+c8wRAikf2vp6WfXmzLijzV2kCaYnon6lpnHu4ygpD6evINUeJlhkRkkYEGHy1E9fV9c9Q+HP/CBN9zeUQqFcp/9w+qwASnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872594; 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=lF4rdAhy19DxRdx2p8FMvfbjzQhye5OhOp5HNVlQP1w=; b=Oh9p0io+N7JWqVXtaDugj7n1RQNAoYrOuNoaor6IrE8MG7O/drjEul7ATW2sH8EsE51c8DevrZyqjI66oN/mqvc8rPRCBAYifp66zj4yu1LOdMtH//6c7S+rDXrBb+S8jXOFBxpAwgnF7hA0qzBApvKmSiINzYuE2IyMT+65Tuw= 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 1729872594950202.9741316640542; Fri, 25 Oct 2024 09:09:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mnt-00043w-3a; Fri, 25 Oct 2024 12:04:45 -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 1t4MnZ-0003p2-0h for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4MnV-0004vu-QS for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:23 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-AumjB-COPB21fnArr_yBKQ-1; Fri, 25 Oct 2024 12:04:19 -0400 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5cbb0b2c6e8so684114a12.0 for ; Fri, 25 Oct 2024 09:04:18 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb6348ec6sm758523a12.87.2024.10.25.09.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:04:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872260; 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=lF4rdAhy19DxRdx2p8FMvfbjzQhye5OhOp5HNVlQP1w=; b=KekOjGP/BADpWaDXD0RZQd3W1hfjc+7HKHX8fmzqdXYcubfduksfcUAoefybMzZ97s6QT4 PHe8DM78ig2QxfYFCOl3Hb6lKqJWaPCxkdBk/SKhmIaOgmreUs1FuhCxImvhPxevf2tzMa yiT8w+F/8OeQ6g/bnP5PBQNnXsLwRMM= X-MC-Unique: AumjB-COPB21fnArr_yBKQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872256; x=1730477056; 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=lF4rdAhy19DxRdx2p8FMvfbjzQhye5OhOp5HNVlQP1w=; b=Otm0sUnzPGBFUoh5ejsQk1FMN6w3vjJmTUWZAXh+hQD/gSRqNT+K1+IyCqZ4N6Qwgd qr5+Wt9WceVNGADJjRc+8PFdyZ7LwarCBf+CVBNEmAf4EU6PA65XKqxCco8qfnZZ3q0Q QzvMda3cT0Elp7202DnIYKcCfYHg/V9hfALfEnPbAVMeuxqlGQGg1agHDeJZ47KAGGJp PNoP7HPjcn/uVnMM5QvY3Gjy+alRzs+16DVKPwqxlD4jbcxIxmMD4mxx+cL0L01fLNxw fzq21GFSPQgMxe59xexFjBG4y5VKeHCOIggWsYEjIeadNpHdMW+CpVJ9jRmuNrBxxdWM AjcQ== X-Gm-Message-State: AOJu0YxIGQMRm77JpVnfMMKcS/seiZ+L08S2PbTrWskraQBRfgYTd2Uk A+Dxq6a8UDSsoUGJCQWgKeiwVqqoLaZa+U9LWdxJcok8EXJaL8WgnsmR/JjAkLr0OOr0pLzf3WE eaWTDSLueFzr9asy8CQ9TpRv3PmOoUh5WGfrktNxn5JtDJXznIdR6cq/Ick8oHzsfcCMvvI59dW ETUCdtinDvXQE65PfPUc/u9Rq8z5ZIz5dD0ZxOB0U= X-Received: by 2002:a05:6402:13d3:b0:5ca:e5b:bbdb with SMTP id 4fb4d7f45d1cf-5cb8acb7b16mr7338545a12.18.1729872256013; Fri, 25 Oct 2024 09:04:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXy8L7yHeeXU1+w6XKn+whHOxFUNpZvJl/XFf2YkNAfAUz7/57mtu9FzHvuOujom4wD7U/xg== X-Received: by 2002:a05:6402:13d3:b0:5ca:e5b:bbdb with SMTP id 4fb4d7f45d1cf-5cb8acb7b16mr7338506a12.18.1729872255524; Fri, 25 Oct 2024 09:04:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 16/23] rust: do not use MaybeUninit::zeroed() Date: Fri, 25 Oct 2024 18:02:01 +0200 Message-ID: <20241025160209.194307-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729872596110116600 Content-Type: text/plain; charset="utf-8" MaybeUninit::zeroed() is handy but is not available as a "const" function until Rust 1.75.0. Remove the default implementation of Zeroable::ZERO, and write by hand the definitions for those types that need it. It may be possible to add automatic implementation of the trait, via a procedural macro and/or a trick similar to offset_of!, but do it the easy way for now. Signed-off-by: Paolo Bonzini Tested-by: Zhao Liu --- rust/qemu-api/src/zeroable.rs | 91 +++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 14 deletions(-) diff --git a/rust/qemu-api/src/zeroable.rs b/rust/qemu-api/src/zeroable.rs index 45ec95c9f70..13cdb2ccba5 100644 --- a/rust/qemu-api/src/zeroable.rs +++ b/rust/qemu-api/src/zeroable.rs @@ -1,23 +1,86 @@ // SPDX-License-Identifier: GPL-2.0-or-later =20 +use std::ptr; + /// Encapsulates the requirement that -/// `MaybeUninit::::zeroed().assume_init()` does not cause -/// undefined behavior. +/// `MaybeUninit::::zeroed().assume_init()` does not cause undefined +/// behavior. This trait in principle could be implemented as just: +/// +/// ``` +/// const ZERO: Self =3D unsafe { +/// ::core::mem::MaybeUninit::<$crate::bindings::Property>::zeroed= ().assume_init() +/// }, +/// ``` +/// +/// The need for a manual implementation is only because `zeroed()` cannot +/// be used as a `const fn` prior to Rust 1.75.0. Once we can assume a new +/// enough version of the compiler, we could provide a `#[derive(Zeroable)= ]` +/// macro to check at compile-time that all struct fields are Zeroable, and +/// use the above blanket implementation of the `ZERO` constant. /// /// # Safety /// -/// Do not add this trait to a type unless all-zeroes is -/// a valid value for the type. In particular, remember that raw -/// pointers can be zero, but references and `NonNull` cannot -/// unless wrapped with `Option<>`. +/// Because the implementation of `ZERO` is manual, it does not make +/// any assumption on the safety of `zeroed()`. However, other users of t= he +/// trait could use it that way. Do not add this trait to a type unless +/// all-zeroes is a valid value for the type. In particular, remember that +/// raw pointers can be zero, but references and `NonNull` cannot pub unsafe trait Zeroable: Default { - /// SAFETY: If the trait was added to a type, then by definition - /// this is safe. - const ZERO: Self =3D unsafe { ::core::mem::MaybeUninit::::zeroed= ().assume_init() }; + const ZERO: Self; } =20 -unsafe impl Zeroable for crate::bindings::Property__bindgen_ty_1 {} -unsafe impl Zeroable for crate::bindings::Property {} -unsafe impl Zeroable for crate::bindings::VMStateDescription {} -unsafe impl Zeroable for crate::bindings::MemoryRegionOps__bindgen_ty_1 {} -unsafe impl Zeroable for crate::bindings::MemoryRegionOps__bindgen_ty_2 {} +unsafe impl Zeroable for crate::bindings::Property__bindgen_ty_1 { + const ZERO: Self =3D Self { i: 0 }; +} + +unsafe impl Zeroable for crate::bindings::Property { + const ZERO: Self =3D Self { + name: ptr::null(), + info: ptr::null(), + offset: 0, + bitnr: 0, + bitmask: 0, + set_default: false, + defval: Zeroable::ZERO, + arrayoffset: 0, + arrayinfo: ptr::null(), + arrayfieldsize: 0, + link_type: ptr::null(), + }; +} + +unsafe impl Zeroable for crate::bindings::VMStateDescription { + const ZERO: Self =3D Self { + name: ptr::null(), + unmigratable: false, + early_setup: false, + version_id: 0, + minimum_version_id: 0, + priority: crate::bindings::MigrationPriority::MIG_PRI_DEFAULT, + pre_load: None, + post_load: None, + pre_save: None, + post_save: None, + needed: None, + dev_unplug_pending: None, + fields: ptr::null(), + subsections: ptr::null(), + }; +} + +unsafe impl Zeroable for crate::bindings::MemoryRegionOps__bindgen_ty_1 { + const ZERO: Self =3D Self { + min_access_size: 0, + max_access_size: 0, + unaligned: false, + accepts: None, + }; +} + +unsafe impl Zeroable for crate::bindings::MemoryRegionOps__bindgen_ty_2 { + const ZERO: Self =3D Self { + min_access_size: 0, + max_access_size: 0, + unaligned: false, + }; +} --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872436; cv=none; d=zohomail.com; s=zohoarc; b=gkxUTeMjIrFW/KYznLwcc+Ay9fpOnNbBglAL3C0M6cwyUtfO6y2uopYBRQhzYOuon/w2iRTuJcG6rZYGbpTZwFsoVGc2bXA/00J3tYv3MEqUYARBmLIlrh1zfWJgXySRrXemi9dFMhOlZYDqj8zviVMVe5jbHN7sH9gfCcjP9G4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872436; 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=5bGJBtVVkGQYWHGxYnD41tlCY5KrVJ/GvB7hkFSkEs4=; b=U/qJ7Bz1b9XGLnVbYFvIR73RDjFFOiM6NvTTc9ih52Z1Hh0VkRB8H5JbyqjoN7KthMso7hoFtpRPsL0yJE87XrIyOdKbTt84DuS/9wArNjETvp43Mg9p7i/lHza15lLYv3EMfeR2yiLHNLqZZRsEJeH58AhjvBqsYXz75cngDBM= 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 1729872436347200.70703478291068; Fri, 25 Oct 2024 09:07:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mnw-0004Re-IC; Fri, 25 Oct 2024 12:04:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4Mnl-0003zV-MF for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4Mni-0004x1-Nq for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:37 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-176-0-3JnyTuNc63VAeNG7HVPg-1; Fri, 25 Oct 2024 12:04:31 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5c938ae4152so3691159a12.1 for ; Fri, 25 Oct 2024 09:04:31 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f029617sm84911666b.81.2024.10.25.09.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872274; 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=5bGJBtVVkGQYWHGxYnD41tlCY5KrVJ/GvB7hkFSkEs4=; b=gqYWEywVtrHDG3I+h8ZKzUMxtdRLtQPAWkDDV5ocycCqskuuBrw+TRXMdvW/8gzwE6mYnp pXs6Gv+W/0iyP7ry2FAAKcE9iMXJvQ+U+43/q7mm6jZEFiBSFQa6+e5ZPFwRWSJpW4Auew OQ9SgxydYqcUyIpDvU8wZNWn/sR4XYs= X-MC-Unique: 0-3JnyTuNc63VAeNG7HVPg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872269; x=1730477069; 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=5bGJBtVVkGQYWHGxYnD41tlCY5KrVJ/GvB7hkFSkEs4=; b=cx4Ky6XkMuS+TpGW2v7SBXvrRYu+ffmbz1M6uFnbWBZhBUDSXbLIoUYiFA79sLBkB0 z36zlbfGpZTVMjAtk4jjT2hlcxhHnC4DmgJHU51ZnVQE6SWHMMWv5zUVJYR1Sp+qx+xN NY4CBtMFkhMH7PJQ8rx8cLzt4vMr0zCTQ5QZnxOFXktCZlb9ylqDtAkBueglHDdLeUcV vBHjcZ+b6RKxtcJfJuWABYyWQ6WJY+hIg9YM+s8DBBCMYwPP5t9Z3JITMV4LV4VH1r9Y SZ22OZKsZWcHm6kfsnPNdQyMamzwJ9J1LSHxv7dCol7IoQCD8Rs+ffV5GInlN6A90TiO yzTw== X-Gm-Message-State: AOJu0YzXWVgjjRbB6fLU+drGNx26YhsrtTGcJx+PUb/pWSsnMs31MF99 u024k1ussgbW+vkP2hSsIBHYbHG8VxAZpZMtbza+xupyRmabAtSWJ187hTuabAbNyi3RPFT57eo lmitF6fOdx5VXCrnbAuYZoizugetiWHOsFEmegKlpP2JU95gsZhsJCwjyUZbW1Cyl0FyNvOXgDj HlXNUqEY9JAfXPQxeq+Q2bBT5/LUorj8s/RaOpjCI= X-Received: by 2002:a17:907:2d89:b0:a9a:dfa5:460e with SMTP id a640c23a62f3a-a9de3917fc6mr1934866b.34.1729872268843; Fri, 25 Oct 2024 09:04:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG876xCoOxcgMaCnTKx/b1U91+hWy1WNVNj6Q3ISjbqAMuGa/ZbTGE5v2+cwFYjR4OgbSW7AQ== X-Received: by 2002:a17:907:2d89:b0:a9a:dfa5:460e with SMTP id a640c23a62f3a-a9de3917fc6mr1930666b.34.1729872268302; Fri, 25 Oct 2024 09:04:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 17/23] rust: clean up detection of the language Date: Fri, 25 Oct 2024 18:02:02 +0200 Message-ID: <20241025160209.194307-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729872437352116600 Content-Type: text/plain; charset="utf-8" Disable the detection code altogether if have_system =3D=3D false. Signed-off-by: Paolo Bonzini Tested-by: Zhao Liu --- meson.build | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/meson.build b/meson.build index 69b8367eb3c..d199bcdd824 100644 --- a/meson.build +++ b/meson.build @@ -53,6 +53,17 @@ cpu =3D host_machine.cpu_family() =20 target_dirs =3D config_host['TARGET_DIRS'].split() =20 +# type of binaries to build +have_linux_user =3D false +have_bsd_user =3D false +have_system =3D false +foreach target : target_dirs + have_linux_user =3D have_linux_user or target.endswith('linux-user') + have_bsd_user =3D have_bsd_user or target.endswith('bsd-user') + have_system =3D have_system or target.endswith('-softmmu') +endforeach +have_user =3D have_linux_user or have_bsd_user + ############ # Programs # ############ @@ -71,11 +82,13 @@ if host_os =3D=3D 'darwin' and \ all_languages +=3D ['objc'] objc =3D meson.get_compiler('objc') endif -have_rust =3D false -if not get_option('rust').disabled() and add_languages('rust', required: g= et_option('rust'), native: false) \ - and add_languages('rust', required: get_option('rust'), native: true) + +have_rust =3D add_languages('rust', native: false, + required: get_option('rust').disable_auto_if(not have_system)) +have_rust =3D have_rust and add_languages('rust', native: true, + required: get_option('rust').disable_auto_if(not have_system)) +if have_rust rustc =3D meson.get_compiler('rust') - have_rust =3D true if rustc.version().version_compare('<1.80.0') if get_option('rust').enabled() error('rustc version ' + rustc.version() + ' is unsupported: Please = upgrade to at least 1.80.0') @@ -186,17 +199,6 @@ have_vhost_net_vdpa =3D have_vhost_vdpa and get_option= ('vhost_net').allowed() have_vhost_net_kernel =3D have_vhost_kernel and get_option('vhost_net').al= lowed() have_vhost_net =3D have_vhost_net_kernel or have_vhost_net_user or have_vh= ost_net_vdpa =20 -# type of binaries to build -have_linux_user =3D false -have_bsd_user =3D false -have_system =3D false -foreach target : target_dirs - have_linux_user =3D have_linux_user or target.endswith('linux-user') - have_bsd_user =3D have_bsd_user or target.endswith('bsd-user') - have_system =3D have_system or target.endswith('-softmmu') -endforeach -have_user =3D have_linux_user or have_bsd_user - have_tools =3D get_option('tools') \ .disable_auto_if(not have_system) \ .allowed() @@ -3317,7 +3319,7 @@ endif =20 genh +=3D configure_file(output: 'config-host.h', configuration: config_ho= st_data) =20 -if have_rust and have_system +if have_rust rustc_args =3D run_command( find_program('scripts/rust/rustc_args.py'), '--config-headers', meson.project_build_root() / 'config-host.h', @@ -3937,7 +3939,7 @@ common_all =3D static_library('common', implicit_include_directories: false, dependencies: common_ss.all_dependencies()) =20 -if have_rust and have_system +if have_rust bindgen_args =3D [ '--disable-header-comment', '--raw-line', '// @generated', @@ -4091,7 +4093,7 @@ foreach target : target_dirs arch_srcs +=3D target_specific.sources() arch_deps +=3D target_specific.dependencies() =20 - if have_rust and have_system + if have_rust and target_type =3D=3D 'system' target_rust =3D rust_devices_ss.apply(config_target, strict: false) crates =3D [] foreach dep : target_rust.dependencies() @@ -4453,9 +4455,9 @@ else endif summary_info +=3D {'Rust support': have_rust} if have_rust - summary_info +=3D {'rustc version': rustc.version()} - summary_info +=3D {'rustc': ' '.join(rustc.cmd_array())} summary_info +=3D {'Rust target': config_host['RUST_TARGET_TRIPLE']} + summary_info +=3D {'rustc': ' '.join(rustc.cmd_array())} + summary_info +=3D {'rustc version': rustc.version()} endif option_cflags =3D (get_option('debug') ? ['-g'] : []) if get_option('optimization') !=3D 'plain' --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872525; cv=none; d=zohomail.com; s=zohoarc; b=IMlgPz4s1dxqBJ3cPWsegrpIX5oPqpeL5X7rxR6q01gyizUSqwpNt4ebBBxU6ysGeqkjOX3RjHAYQjirpWqhdhA1HMdJ2pFfe/sMOmVaVY2/28COi2lfuMmUbOYKTz4c8oePufA90lzR2DsFeWDfIek/O+nWMPXxfvqoA0xtsjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872525; 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=7NHNEVxOvAxgYJFwBOR2YWeM/1KhpOxYbBjuxgcI8Io=; b=eSXLoYlH2Fn+Vytaz912iWkRD/3Rr7WGmZG8Eg55vwo17Nk2E6itVILxSLeaqhzpGOBCHA8gtXJUrymKql7E1li2FWZEs1qKCNsUL9ja2YzRGb6EpM7Kc8D7Y3wmctou1uNPJSZkNHspKacQB/ukrt9DbOL4Eb1QQjula1AG8k4= 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 1729872525429188.95750579876153; Fri, 25 Oct 2024 09:08:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4MoU-0004wa-UF; Fri, 25 Oct 2024 12:05:32 -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 1t4Mnn-000411-Ka for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4Mnm-0004xZ-3m for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:39 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-32-dWkPTc2SNTa1fMH_RwIdJw-1; Fri, 25 Oct 2024 12:04:36 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a9a0d8baa2cso334453166b.0 for ; Fri, 25 Oct 2024 09:04:35 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f0292c2sm84958766b.69.2024.10.25.09.04.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872277; 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=7NHNEVxOvAxgYJFwBOR2YWeM/1KhpOxYbBjuxgcI8Io=; b=Bw0xe0vzSCQn0uMNDIEMwg3rmRCsX1VAGmBscyVUR2AenT7FcGLyX9/6i6Hlz2FWwCDx4p NWs2Loyr/VfHUSjwpPfMZ7sV+oO+7aUFNtnZfv5JIAqRnR9348tz9lGwfr2Dp+05idyyQ1 f//mdaYAHiSAfGUUgz6tZMEkutjJml4= X-MC-Unique: dWkPTc2SNTa1fMH_RwIdJw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872274; x=1730477074; 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=7NHNEVxOvAxgYJFwBOR2YWeM/1KhpOxYbBjuxgcI8Io=; b=SzBpmEnXLho0TaN8Usct1qn/BVk7XpgG9CkcclVzQCihscsKjjyKb/SFyrUm0pfe4T RimUejkMietUVKmjn0l/ulmi6qIhSWv38nl/krux5MBLwOPybEzdXgqjtacQGSUrfnMf 3qLkeePsv640D8Wo7ocuR4ZGihtl7kzVEUr/cOsZpUg/8FdH6THT1s43n3+bloUSCVcc gCh4z42/6D4BWMTP9q6ceJdNEjCv6csHj6HXT7ZBcdB4gCtilfqKm4qHW/wfpOsUnYZm lelMqWOAOZZic+9IxiWZkWcpy1rFSxgcZFLhzYMG4lEpFn4G8g2v4fEmkvq8R9Ndlp87 +8KA== X-Gm-Message-State: AOJu0Yzw70gmOA0t53iY7qB1JcD7iYnQNCJeGKMGak5Q5UEYCI8XKd6F OM/0nUKEkYq6/B/W2IRrWxWo0BfJAp1Tw0Dbb5oxNIGC67HDf0MboutRkScTMHoqNq7AVhGbzEm N5r0BUj0zvcZfeN/HFKDfMrxaENj7Ob4FCaIXDVIrPS+oExE606SxVCeos+L61jveN5P/TKlZst L5tj+fFqUYnhnuFRBLir/zWhBNbj4qaExppjNk4A0= X-Received: by 2002:a17:907:7f07:b0:a9a:1af0:ee1a with SMTP id a640c23a62f3a-a9de355da45mr5038666b.6.1729872273821; Fri, 25 Oct 2024 09:04:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSLFvMWkTfjUsPsdDsvB3CJIpM6PmWDI04XYFlfwHqCBZJGG7AaL2FkvzhWG3fpPx/hGugCg== X-Received: by 2002:a17:907:7f07:b0:a9a:1af0:ee1a with SMTP id a640c23a62f3a-a9de355da45mr5035066b.6.1729872273353; Fri, 25 Oct 2024 09:04:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 18/23] rust: allow version 1.63.0 of rustc Date: Fri, 25 Oct 2024 18:02:03 +0200 Message-ID: <20241025160209.194307-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729872525671116600 Content-Type: text/plain; charset="utf-8" All constructs introduced by newer versions of Rust have been removed. Apart from Debian 12, all other supported Linux distributions have rustc 1.75.0 or newer. This means that they only lack c"" literals and stable offset_of!. Signed-off-by: Paolo Bonzini Tested-by: Zhao Liu --- meson.build | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index d199bcdd824..ab0613f353c 100644 --- a/meson.build +++ b/meson.build @@ -89,11 +89,12 @@ have_rust =3D have_rust and add_languages('rust', nativ= e: true, required: get_option('rust').disable_auto_if(not have_system)) if have_rust rustc =3D meson.get_compiler('rust') - if rustc.version().version_compare('<1.80.0') + if rustc.version().version_compare('<1.63.0') if get_option('rust').enabled() - error('rustc version ' + rustc.version() + ' is unsupported: Please = upgrade to at least 1.80.0') + error('rustc version ' + rustc.version() + ' is unsupported. Please = upgrade to at least 1.63.0') else - warning('rustc version ' + rustc.version() + ' is unsupported: Disab= ling Rust compilation. Please upgrade to at least 1.80.0 to use Rust.') + warning('rustc version ' + rustc.version() + ' is unsupported, disab= ling Rust compilation.') + message('Please upgrade to at least 1.63.0 to use Rust.') have_rust =3D false endif endif --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872622; cv=none; d=zohomail.com; s=zohoarc; b=Q5MEEioGVNBlydCfeH6xyPLCq8PM+sXh6WIFuf+EcA0SF0KExZoFHwCZLr4BIlyLaeRTv5LAT9c2quY8yMGwgCTeGvZQx1BIM0eNmXmlyJCTVDq/Bxxnz/1SDLtsBhOHDLqo6DIikaDzsh+uCi7lh4SBrXBR0Za8l9hlYZbKVuM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872622; 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=max4ptoWARDXa3Y5mnahsubFzzuLs19p4ctB7GiY7D4=; b=YjGY3EYb49Bj9GxpEYJxllLNjBYF+Bjh+z/fM49Ow8wsDjzwCGDjd5kx16GtXs3qd7GOog70t0Nztc4ZuoOUI3Eqs1wKyX9VzQTL6iquMIyYDRaZjrH+dvFWUFMRMtrivv18H5c5Sc05nDzjV8ZeFEUHjSQXJSqFykM7XPdJIYQ= 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 1729872622704314.1251707028754; Fri, 25 Oct 2024 09:10:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mov-0005Ce-EX; Fri, 25 Oct 2024 12:05:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4Mnx-0004WJ-RR for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:51 -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 1t4Mnv-0004yv-VB for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:49 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-1nflGp0VNk-arTG7xYITZw-1; Fri, 25 Oct 2024 12:04:42 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a9adb271de7so102553266b.0 for ; Fri, 25 Oct 2024 09:04:42 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1dfbc814sm85423266b.37.2024.10.25.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872287; 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=max4ptoWARDXa3Y5mnahsubFzzuLs19p4ctB7GiY7D4=; b=OIXKjH9XKJDWMFkEd0D55MVxHBjSOcnp9m/Gy5d5QIyj9SBMCHBDPUKFI4tfRI/90TCi0P EFPDBU7+x3SPP9ToYTkj9jm5JyR35+ufL16euchQuBp5ABtbY8NPKCyQNlPJXZZGR42y3H sDIjqaOGhzJa0wOUir/tcDfFzJeklpU= X-MC-Unique: 1nflGp0VNk-arTG7xYITZw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872280; x=1730477080; 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=max4ptoWARDXa3Y5mnahsubFzzuLs19p4ctB7GiY7D4=; b=ZKyFTE3pfPwQAiPPe4qzmdfwCO9/VOmios8WwoB2F3DRrpsZaaQFuNQXcHhvpdXdin mOvx/1l4vBTPZV878Cxu656QSF6UTM27/ibpcoPirEmb+3LIRjRIHSfa9gzNq+SVm/KW VRxb92pViZ/dkNFs/HcinadpQOQmzpSR61pB+ZXB4e2YfotWMEsU+vXUU14mXp8UhT06 LHwCZrxBWzlzUj51Riw9RGqZbcLyXVfaL+uumJu6DG1plUxWLL0666hsbUoYVCaupTXJ rW9Xv6xd2b+1PNVRzh5vry0MoKu72wcuX18QVpRsyWodsOBXmb3EXvboauLG8LKSHtQm HLPw== X-Gm-Message-State: AOJu0YwK3ULgRuiTiVOr90aIvXzoiuMX+bNKcSaUUqRvnQcI+NK3lKxc Cos8pv1yW1BpJ4oMnutGCaA2hr0mQCOcFCd7OxbcHKU6a8pKRFNeSUi0EB4RsbUkn7y+ltUpT/X 7k0Wx6WPbLnLpPlvLaH8z/TAcJyJNVvDTvREupJcQrKr96d5ClEazNzoGND05qHLnPclSrals2V MqqRluXR/YtrGix02LuAZ+ZDuXMFEjrgMpkT2N5jc= X-Received: by 2002:a17:907:7da5:b0:a9a:421:720 with SMTP id a640c23a62f3a-a9ad283263emr466289866b.46.1729872279985; Fri, 25 Oct 2024 09:04:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEumtWYbq0/deuwQSHN+ZegtMRrT7wZQr4VKX8XXxm7QWfGz7uYrI0AEqHRFrcj6g1+9PG23Q== X-Received: by 2002:a17:907:7da5:b0:a9a:421:720 with SMTP id a640c23a62f3a-a9ad283263emr466286666b.46.1729872279440; Fri, 25 Oct 2024 09:04:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 19/23] rust: do not use --generate-cstr Date: Fri, 25 Oct 2024 18:02:04 +0200 Message-ID: <20241025160209.194307-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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.697, 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: 1729872624275116600 Content-Type: text/plain; charset="utf-8" --generate-cstr is a good idea and generally the right thing to do, but it is not available in Debian 12 and Ubuntu 22.04. Work around the absence. Signed-off-by: Paolo Bonzini Tested-by: Zhao Liu --- meson.build | 4 +++- rust/hw/char/pl011/src/device.rs | 1 + rust/qemu-api/src/device_class.rs | 10 ++++++++++ rust/qemu-api/tests/tests.rs | 4 ++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index ab0613f353c..bfd04294850 100644 --- a/meson.build +++ b/meson.build @@ -3941,13 +3941,15 @@ common_all =3D static_library('common', dependencies: common_ss.all_dependencies()) =20 if have_rust + # We would like to use --generate-cstr, but it is only available + # starting with bindgen 0.66.0. The oldest supported versions + # are in Ubuntu 22.04 (0.59.1) and Debian 12 (0.60.1). bindgen_args =3D [ '--disable-header-comment', '--raw-line', '// @generated', '--ctypes-prefix', 'std::os::raw', '--formatter', 'rustfmt', '--generate-block', - '--generate-cstr', '--impl-debug', '--merge-extern-blocks', '--no-doc-comments', diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index bca727e37f0..2a85960b81f 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -12,6 +12,7 @@ bindings::{self, *}, c_str, definitions::ObjectImpl, + device_class::TYPE_SYS_BUS_DEVICE, }; =20 use crate::{ diff --git a/rust/qemu-api/src/device_class.rs b/rust/qemu-api/src/device_c= lass.rs index 56608c7f7fc..0ba798d3e3c 100644 --- a/rust/qemu-api/src/device_class.rs +++ b/rust/qemu-api/src/device_class.rs @@ -2,6 +2,10 @@ // Author(s): Manos Pitsidianakis // SPDX-License-Identifier: GPL-2.0-or-later =20 +use std::ffi::CStr; + +use crate::bindings; + #[macro_export] macro_rules! device_class_init { ($func:ident, props =3D> $props:ident, realize_fn =3D> $realize_fn:exp= r, legacy_reset_fn =3D> $legacy_reset_fn:expr, vmsd =3D> $vmsd:ident$(,)*) = =3D> { @@ -62,3 +66,9 @@ macro_rules! declare_properties { ]; }; } + +// workaround until we can use --generate-cstr in bindgen. +pub const TYPE_DEVICE: &CStr =3D + unsafe { CStr::from_bytes_with_nul_unchecked(bindings::TYPE_DEVICE) }; +pub const TYPE_SYS_BUS_DEVICE: &CStr =3D + unsafe { CStr::from_bytes_with_nul_unchecked(bindings::TYPE_SYS_BUS_DE= VICE) }; diff --git a/rust/qemu-api/tests/tests.rs b/rust/qemu-api/tests/tests.rs index 7442f695646..43a4827de12 100644 --- a/rust/qemu-api/tests/tests.rs +++ b/rust/qemu-api/tests/tests.rs @@ -8,7 +8,7 @@ bindings::*, c_str, declare_properties, define_property, definitions::{Class, ObjectImpl}, - device_class_init, + device_class, device_class_init, zeroable::Zeroable, }; =20 @@ -57,7 +57,7 @@ impl ObjectImpl for DummyState { type Class =3D DummyClass; const TYPE_INFO: qemu_api::bindings::TypeInfo =3D qemu_api::type_i= nfo! { Self }; const TYPE_NAME: &'static CStr =3D c_str!("dummy"); - const PARENT_TYPE_NAME: Option<&'static CStr> =3D Some(TYPE_DEVICE= ); + const PARENT_TYPE_NAME: Option<&'static CStr> =3D Some(device_clas= s::TYPE_DEVICE); const ABSTRACT: bool =3D false; const INSTANCE_INIT: Option =3D None; const INSTANCE_POST_INIT: Option =3D None; --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872442; cv=none; d=zohomail.com; s=zohoarc; b=TFmC8m4RMCVQVH/vbRaF2MujHxY84DX6ecjdnjbDTPnqJ4Lyq0tdPIkOJEPLQiLPw31p1zLrFXUoV4VlFJMntiTPts4WYK34LNhaP+h7v7nQHyBlj4AzxzO5ikWxSAg7LHzDwoK2taDws1Ht6aCLc+0MKWJHTYvdmu34Ev4yfJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872442; 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=/EguPHGv0KZEAhhaXf9YkHmhUGaAAWJPIVBGnJxjKSo=; b=RHRuidg32hO+96ABVaJeGBYhxJ2SrBYfrw8/Y58CczRVmR5NtUr/cEP85eSFVh5+aDfMKVDiEU2rnbXykW7BIoiiQ7PARLY7SX4eViFtlytMlJQp6AchNhIiV+L2sf25tvXpop9/NvH5Dv/ENM+kkjHPzXE7SP3Ajs5bsICIFc8= 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 1729872442682502.095863930046; Fri, 25 Oct 2024 09:07:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Moz-0005VZ-RP; Fri, 25 Oct 2024 12:05:54 -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 1t4Mo1-0004m7-Dl for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4Mnx-0004zI-Ii for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:52 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-584-435eXTh2MO-wnfx90cnYUg-1; Fri, 25 Oct 2024 12:04:47 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5cbb0b2c6e8so684596a12.0 for ; Fri, 25 Oct 2024 09:04:47 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb62c3da7sm761499a12.55.2024.10.25.09.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872289; 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=/EguPHGv0KZEAhhaXf9YkHmhUGaAAWJPIVBGnJxjKSo=; b=TwfHsQmAtDjT24z6sADfJlignqPRt5J5MS4qfLHP8F+/V0qltQNuuV4zbFIlxKxdBMwKT2 7BirXEoEvV7tc8+X4Zd9ieulV28R8DUGqYV6spFQWwDBh9dVYxrkfeT/u08jvu18pjd+mr vhhEzLEfm32qBmp8egUnPvqJ/NQK2RQ= X-MC-Unique: 435eXTh2MO-wnfx90cnYUg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872284; x=1730477084; 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=/EguPHGv0KZEAhhaXf9YkHmhUGaAAWJPIVBGnJxjKSo=; b=tKXJlamBh8JdetEQQ6jn79E519MSvfv/ZLIwBRpB6/svV8XK5s2ct5UrXqP6Jdec6E YfcLsKeCxWw5CYXXw6LBSUUyzs1hLZ1r+yyLDHW1QKSex9StfWwLKr4pj2gHwX4PtnVZ jWpPn+q2mlyKmBKTL63xPRPNp2Z/d5G7Ly8zh4m489bzOKi6vY+hTS8eOg/voc4mLdmn bM8NDvY6Q4QJnELDI3KVLn8i1m8GqsuGSItUnIlPFRoAeW13DVfiuUwvHrVoAm7qEi9d N+VBSxdQoAL8sle3ms9cm/nNTbuwar2doXLt+gZ4Pauzzl1+8rP0DbWBnIYdHtY1eker mb0Q== X-Gm-Message-State: AOJu0YyfHPunv+IN11M2qs5ESF0rJ8xBZ4rG7qESHk+XI/rWvxgbFDP4 qAlSO9tCkEbEv5yGkLuQ4mizc2CJ4fQ1Ei5Kw24TH8lS1cG2iCXN+ljPR0phX87dmOS0y3V57QY Rsybg/QtcBwLmAdWdtfBy95ckFFIcC7I9gyV5XbeFbg/6DJmYT+5MjxXueXpKmHsOQC0lLUpZlj ifVPniAsppeO5elcIB239v1FcWn9TgayOTKaPVuqE= X-Received: by 2002:a05:6402:5cd:b0:5c9:3f2:15fb with SMTP id 4fb4d7f45d1cf-5cb8af6bd46mr7487055a12.24.1729872284300; Fri, 25 Oct 2024 09:04:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEePOJZE+dDS5HHVfR5s7/0uEOaVEoi7/ZkBunx1mnlqsYPoFgaqj3p2FLKX4M+xOA3GF+s+g== X-Received: by 2002:a05:6402:5cd:b0:5c9:3f2:15fb with SMTP id 4fb4d7f45d1cf-5cb8af6bd46mr7487024a12.24.1729872283776; Fri, 25 Oct 2024 09:04:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 20/23] rust: allow older version of bindgen Date: Fri, 25 Oct 2024 18:02:05 +0200 Message-ID: <20241025160209.194307-21-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729872443361116600 Content-Type: text/plain; charset="utf-8" Cope with the old version that is provided in Debian 12. --size_t-is-usize is needed on bindgen <0.61.0, and it was removed in bindgen 0.65.0, so check for it in meson.build. --merge-extern-blocks was added in 0.61.0. --formatter rustfmt was added in 0.65.0 and is the default, so remove it. Apart from Debian 12 and Ubuntu 22.04, all other supported distros have version 0.66.x of bindgen or newer (or do not have bindgen at all). Signed-off-by: Paolo Bonzini Tested-by: Zhao Liu --- docs/about/build-platforms.rst | 12 ++++++++++++ meson.build | 29 +++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/docs/about/build-platforms.rst b/docs/about/build-platforms.rst index 8fd7da140a3..ff56091078e 100644 --- a/docs/about/build-platforms.rst +++ b/docs/about/build-platforms.rst @@ -107,6 +107,18 @@ Python build dependencies required, it may be necessary to fetch python modules from the Python Package Index (PyPI) via ``pip``, in order to build QEMU. =20 +Rust build dependencies + QEMU is generally conservative in adding new Rust dependencies, and all + of them are included in the distributed tarballs. One exception is the + bindgen tool, which is too big to package and distribute. The minimum + supported version of bindgen is 0.60.x. For distributions that do not + include bindgen or have an older version, it is recommended to install + a newer version using ``cargo install bindgen-cli``. + + Developers may want to use Cargo-based tools in the QEMU source tree; + this requires Cargo 1.74.0. Note that Cargo is not required in order + to build QEMU. + Optional build dependencies Build components whose absence does not affect the ability to build QEMU may not be available in distros, or may be too old for QEMU's diff --git a/meson.build b/meson.build index bfd04294850..fb0295b312c 100644 --- a/meson.build +++ b/meson.build @@ -100,6 +100,21 @@ if have_rust endif endif =20 +bindgen =3D find_program('bindgen', required: get_option('rust').disable_a= uto_if(not have_rust)) +if not bindgen.found() or bindgen.version().version_compare('<0.60.0') + if get_option('rust').enabled() + error('bindgen version ' + bindgen.version() + ' is unsupported. You c= an install a new version with "cargo install bindgen-cli"') + else + if bindgen.found() + warning('bindgen version ' + bindgen.version() + ' is unsupported, d= isabling Rust compilation.') + else + warning('bindgen not found, disabling Rust compilation.') + endif + message('To use Rust you can install a new version with "cargo install= bindgen-cli"') + have_rust =3D false + endif +endif + dtrace =3D not_found stap =3D not_found if 'dtrace' in get_option('trace_backends') @@ -3943,15 +3958,13 @@ common_all =3D static_library('common', if have_rust # We would like to use --generate-cstr, but it is only available # starting with bindgen 0.66.0. The oldest supported versions - # are in Ubuntu 22.04 (0.59.1) and Debian 12 (0.60.1). + # is 0.60.x (Debian 12 has 0.60.1) which introduces --allowlist-file. bindgen_args =3D [ '--disable-header-comment', '--raw-line', '// @generated', '--ctypes-prefix', 'std::os::raw', - '--formatter', 'rustfmt', '--generate-block', '--impl-debug', - '--merge-extern-blocks', '--no-doc-comments', '--with-derive-default', '--no-layout-tests', @@ -3960,6 +3973,12 @@ if have_rust '--allowlist-file', meson.project_source_root() + '/.*', '--allowlist-file', meson.project_build_root() + '/.*' ] + if bindgen.version().version_compare('<0.61.0') + # default in 0.61+ + bindgen_args +=3D ['--size_t-is-usize'] + else + bindgen_args +=3D ['--merge-extern-blocks'] + endif c_enums =3D [ 'DeviceCategory', 'GpioPolarity', @@ -3995,7 +4014,7 @@ if have_rust dependencies: common_ss.all_dependencies(), output: 'bindings.rs', include_directories: include_directories('.', 'include'), - bindgen_version: ['>=3D0.69.4'], + bindgen_version: ['>=3D0.60.0'], args: bindgen_args, ) subdir('rust') @@ -4461,6 +4480,8 @@ if have_rust summary_info +=3D {'Rust target': config_host['RUST_TARGET_TRIPLE']} summary_info +=3D {'rustc': ' '.join(rustc.cmd_array())} summary_info +=3D {'rustc version': rustc.version()} + summary_info +=3D {'bindgen': bindgen.full_path()} + summary_info +=3D {'bindgen version': bindgen.version()} endif option_cflags =3D (get_option('debug') ? ['-g'] : []) if get_option('optimization') !=3D 'plain' --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872636; cv=none; d=zohomail.com; s=zohoarc; b=DXKewGqdOmkd/Ag+Ne6BlObTBL1q2crix51BY4oktXrCjfAzynpHTneHkMHcit0zrxntTqDoVW0YiHMmLoQHXfZMhTUAwD6dPSinHyR07YyJxUfyiR288gb3ZIoivKU9xYvAsF6KnRzh4POUAZ69E+F6WelC/8zZekPqR7cEO2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872636; 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=qVfnkITdEn2MeEyLCW+ZaeMcn0OTk4tm0g2ItZpiqB4=; b=j9cubYh6kKkbGsqGVgAwuAGaNMBUbvVOFA/ShgOm72eXNDhraZJdHg+d5wb499j8KpCllWxwqVNBLQXEckT/Qr4bSsVVaIJqvKTK1XR5sD1AwqqVqs1BeNMS/970sQe/1jp866LsxDvtcmnT4JwfSxRCV2OElLHyqVrnXCCcNJ4= 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 1729872636548514.5297088940941; Fri, 25 Oct 2024 09:10:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mp6-00065i-23; Fri, 25 Oct 2024 12:06:02 -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 1t4Mo4-0004uj-Co for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:05:05 -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 1t4Mo1-0004zU-Iy for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:04:55 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-221-KA-g50cTM4-ESIitmzBNXg-1; Fri, 25 Oct 2024 12:04:51 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a99fc3e2285so146514666b.0 for ; Fri, 25 Oct 2024 09:04:51 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b3a084ae4sm84618366b.197.2024.10.25.09.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872292; 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=qVfnkITdEn2MeEyLCW+ZaeMcn0OTk4tm0g2ItZpiqB4=; b=TUuWDgI5wcoEXdLidEn98IzGFcIs5s2sokJFlhR/whHMFPK/CFN+v3C2HcXHDMcveMyI8a DNsOzYVBlQYLX6Tw9t7veh93pnqFmjro91W1Onz4+qhIynWsnN8+HnXY65RaKHwLrVlk2B JhWyQBw1ynDO7NEaS76DL/0pImbIIbs= X-MC-Unique: KA-g50cTM4-ESIitmzBNXg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872290; x=1730477090; 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=qVfnkITdEn2MeEyLCW+ZaeMcn0OTk4tm0g2ItZpiqB4=; b=cAGkfOna1+Rjgg3MPxkqPl1bmU7F6aa9HKHdK+WkVfbsPfvOkTxIv/IAqDPrE4I9Xn KmJ0uMb9SCTnbdKvXud6c1hFEcSTiyxMa/h3UON1wPPZ/srs/EX/Oh/m3iaQT3jCuVao U/hBn7FwlZCx53kQistZ7xn/eZhMAvaSr7HdZAKH9Z49PjEYGbVz1219y9erJMwbYtdF 2Ty0wSWLOWixpNizatyyPzjNWazBU1bF7vqMKPMlfNfGXF7tI0TgwvfwnkE5XKE6DK76 WkTNR/tt0r+AGJTzDDqSXcyu2dA0Sdy8R7MSs3AnKbOT2WbvfrEo+RgCR3/AjqQ6F1QQ l18g== X-Gm-Message-State: AOJu0YyNxD6hE0e6FFn/TgdqGXtW7h9/wdcL6MnJwgCAJreZfAfFV8FP cBhIsZWoYR4ux2zvfu1jmIpqciDpOyeK+fHMoxLBOGWnjOtgST9Q7aWhTHyTZEJgr1DvQeG8fCP 0xnDZuZliKpJm/vpGC9URGsb5/R7MdhTowzeRqIxP8MnawYni8E3VAgUNXvF75vPqfQOkZpwCM3 WxAJZuftkD17kDChATgz6R4uQoiHc+QlnjG0AxshQ= X-Received: by 2002:a17:907:7e86:b0:a9a:3f9d:62f8 with SMTP id a640c23a62f3a-a9abf867613mr1005590866b.19.1729872289760; Fri, 25 Oct 2024 09:04:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGuJ0f1bm+cMXyzf1JkOSc/LB6RigVs1wTsRsdqwGgzzrDx3qGBky7YCgwWdxhmW01WCYO+0g== X-Received: by 2002:a17:907:7e86:b0:a9a:3f9d:62f8 with SMTP id a640c23a62f3a-a9abf867613mr1005588066b.19.1729872289335; Fri, 25 Oct 2024 09:04:49 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 21/23] rust: make rustfmt optional Date: Fri, 25 Oct 2024 18:02:06 +0200 Message-ID: <20241025160209.194307-22-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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.697, 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: 1729872638262116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Tested-by: Zhao Liu --- meson.build | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/meson.build b/meson.build index fb0295b312c..3db4dcc8a24 100644 --- a/meson.build +++ b/meson.build @@ -115,6 +115,10 @@ if not bindgen.found() or bindgen.version().version_co= mpare('<0.60.0') endif endif =20 +if have_rust + rustfmt =3D find_program('rustfmt', required: false) +endif + dtrace =3D not_found stap =3D not_found if 'dtrace' in get_option('trace_backends') @@ -3973,6 +3977,13 @@ if have_rust '--allowlist-file', meson.project_source_root() + '/.*', '--allowlist-file', meson.project_build_root() + '/.*' ] + if not rustfmt.found() + if bindgen.version().version_compare('<0.65.0') + bindgen_args +=3D ['--no-rustfmt-bindings'] + else + bindgen_args +=3D ['--formatter', 'none'] + endif + endif if bindgen.version().version_compare('<0.61.0') # default in 0.61+ bindgen_args +=3D ['--size_t-is-usize'] --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872355; cv=none; d=zohomail.com; s=zohoarc; b=KzGLHl2rwBtJX5/cWTIe1el7PGKO15PrP6kigBSTm4UMHa7vqZTxI0ToREZOT1w0DxkBWuOFshjQWHQ7K1rA+81AYzlhnaTzvccZuoMnSLFvb4JMLcob0q1yGZwQkeoyEKH0kv414UtDJxfWZoEzbtG5sZYOH9K++gOd/P+EnTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872355; 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=k/4Em/H4v7wbvnwMZF2nZE5DI93vJeI1Nc1yPo99svY=; b=e1yFTuBdxIg9DQPc1HM3kbn1vFtAbPS4Dp/1FrHR4SrC9FImBOXe0cCWVHIjUtN206+VPQoEytaSExirBu2n/PtTsF8nFkFYYT6FT8f0s0+TmupH16FVauBcA0nlMG04A+8YalYdNhC2tRQ6vqc2c/vJL90co+fxkRw8kkaMaBE= 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 1729872355295708.3298798264786; Fri, 25 Oct 2024 09:05:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mor-000554-Hw; Fri, 25 Oct 2024 12:05:46 -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 1t4Mo9-0004v1-KK for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:05:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4Mo7-000500-TS for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:05:01 -0400 Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-124-X3187xKrMkm1mM9tb16fCA-1; Fri, 25 Oct 2024 12:04:58 -0400 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2fb3f99c9a7so15338891fa.1 for ; Fri, 25 Oct 2024 09:04:57 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb6258683sm757360a12.20.2024.10.25.09.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872299; 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=k/4Em/H4v7wbvnwMZF2nZE5DI93vJeI1Nc1yPo99svY=; b=S3aZaqZZDW5VTntI1JumtHYef9qyIiJz1v/GaYFM30h8HHnmpyDOfunGhaIlBxMYIEDSOO dfgwCgFwMzwo9pvcDPojrSLMtkTYDe9l6KGJZ2Bu99ef1O+fAoc+/sJgQ/Kw7zO6Sol/I5 UrfevjEoRZSJKlzn2N+aBOCyeTnZvqY= X-MC-Unique: X3187xKrMkm1mM9tb16fCA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872296; x=1730477096; 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=k/4Em/H4v7wbvnwMZF2nZE5DI93vJeI1Nc1yPo99svY=; b=gftxbpExwi68kCOjoXQ5J9CzliqRBHYFvSkqMi+3FeHCAOQeBcNlajc3OuTpEAM+W/ j08i7D7ksNz3ouNhwX02FR68A9ccCCe4UM0DK2bYYi3Ez1UcMkFWwUkngTWQtI4qCrJ/ VVKMKI9RCI0KcfkDBGs3HQwUgzmZk6+S/JMZDkk/ZW6PIwR9vcrC6lNJz/EPASiEzUKg ZiTkJlPnxjHpOh+IfsO7/fYWBnmRHexcgH89gKUx4Fam1g6hJKIy/exez9DiD+aaEJc9 zQKDgKxi6Z/6PACLeM1Cc4UyjUcuVQiq8DHHhRVqnrMdQxacGJMJy31FUqxo09OIHq39 coCw== X-Gm-Message-State: AOJu0YxE8ep+pK8nhY4JJ/swS1y3HnNZ2luVRkJJP32HK17TPs2YlfK/ bQmBdQn2ph2lvtjyv6mnBfsFwSjAWsXjJKIZFpXIqn5mu57GJ0YSMxY+LB0Z0ua7xKNXWE4sK3d sJc3JRTB8UpWhS/b3DkfbJme4SdS9HkFqHbQsQffDcoWKUY8b4dTT0CSIwoPyRKEunENi/KDXJB i6785qlpV1/3RuwplWCSa9TnvAfJCZMdw9F7uorwA= X-Received: by 2002:a05:651c:2115:b0:2fa:dadf:aad5 with SMTP id 38308e7fff4ca-2fca825aeb0mr40652461fa.28.1729872295382; Fri, 25 Oct 2024 09:04:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFB/trpaCte10LSF5OMXbss25QEhcpOwLdzH0N5OYTyrCXiT7hYtb14vZIlJ8iKsEuMzTYaWw== X-Received: by 2002:a05:651c:2115:b0:2fa:dadf:aad5 with SMTP id 38308e7fff4ca-2fca825aeb0mr40651921fa.28.1729872294727; Fri, 25 Oct 2024 09:04:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 22/23] dockerfiles: install bindgen from cargo on Ubuntu 22.04 Date: Fri, 25 Oct 2024 18:02:07 +0200 Message-ID: <20241025160209.194307-23-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729872356729116600 Content-Type: text/plain; charset="utf-8" Because Ubuntu 22.04 has a very old version of bindgen, that does not have the important option --allowlist-file, it will not be able to use --enable-rust out of the box. Instead, install the latest version of bindgen-cli via "cargo install" in the container, following QEMU's own documentation. Signed-off-by: Paolo Bonzini Reviewed-by: Pierrick Bouvier Tested-by: Zhao Liu --- tests/docker/dockerfiles/ubuntu2204.docker | 5 +++++ tests/lcitool/mappings.yml | 4 ++++ tests/lcitool/refresh | 11 ++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/docker/dockerfiles/ubuntu2204.docker b/tests/docker/dock= erfiles/ubuntu2204.docker index ce3aa39d4f3..245ac879622 100644 --- a/tests/docker/dockerfiles/ubuntu2204.docker +++ b/tests/docker/dockerfiles/ubuntu2204.docker @@ -149,6 +149,11 @@ ENV LANG "en_US.UTF-8" ENV MAKE "/usr/bin/make" ENV NINJA "/usr/bin/ninja" ENV PYTHON "/usr/bin/python3" +ENV CARGO_HOME=3D/usr/local/cargo +ENV PATH=3D$CARGO_HOME/bin:$PATH +RUN DEBIAN_FRONTEND=3Dnoninteractive eatmydata \ + apt install -y --no-install-recommends cargo +RUN cargo install bindgen-cli # As a final step configure the user (if env is defined) ARG USER ARG UID diff --git a/tests/lcitool/mappings.yml b/tests/lcitool/mappings.yml index 9c5ac87c1c2..c90b23a00f1 100644 --- a/tests/lcitool/mappings.yml +++ b/tests/lcitool/mappings.yml @@ -1,4 +1,8 @@ mappings: + # Too old on Ubuntu 22.04; we install it from cargo instead + bindgen: + Ubuntu2204: + flake8: OpenSUSELeap15: =20 diff --git a/tests/lcitool/refresh b/tests/lcitool/refresh index 0f16f4d525c..a46cbbdca41 100755 --- a/tests/lcitool/refresh +++ b/tests/lcitool/refresh @@ -137,6 +137,14 @@ fedora_rustup_nightly_extras =3D [ 'RUN /usr/local/cargo/bin/rustup run nightly cargo install bindgen-cli= \n', ] =20 +ubuntu2204_bindgen_extras =3D [ + "ENV CARGO_HOME=3D/usr/local/cargo\n", + 'ENV PATH=3D$CARGO_HOME/bin:$PATH\n', + "RUN DEBIAN_FRONTEND=3Dnoninteractive eatmydata \\\n", + " apt install -y --no-install-recommends cargo\n", + 'RUN cargo install bindgen-cli\n', +] + def cross_build(prefix, targets): conf =3D "ENV QEMU_CONFIGURE_OPTS --cross-prefix=3D%s\n" % (prefix) targets =3D "ENV DEF_TARGET_LIST %s\n" % (targets) @@ -157,7 +165,8 @@ try: trailer=3D"".join(debian12_extras)) generate_dockerfile("fedora", "fedora-40") generate_dockerfile("opensuse-leap", "opensuse-leap-15") - generate_dockerfile("ubuntu2204", "ubuntu-2204") + generate_dockerfile("ubuntu2204", "ubuntu-2204", + trailer=3D"".join(ubuntu2204_bindgen_extras)) =20 # # Non-fatal Rust-enabled build --=20 2.47.0 From nobody Sat Nov 23 18:11:20 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=1729872358; cv=none; d=zohomail.com; s=zohoarc; b=TznRELQgvIc45fFnFu0LxMLucwMSl6IAKAbSHcQjIb3wBkA5qfkHViX3WtHlWVvmjEgRpRWb+EY8xwLVb9m0G3Av0tedeS60GabcPCPaA4z4QFLYJ+6f4diSqu9y57SPotgckGwr4IePyuuYPM9mbrPW+cvsqmDkkbo0EC525zk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729872358; 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=F1V6b7WD574xZK3wF/C5mFToVHXs12LTfpeZesQABro=; b=A4RWvoUH5NZwUdg0dOiSrUgZsoliA45NSdbc6EBNo4qS8niyS2byfh6wxykJMkQLs4K4Uxm8YZDasIkBzWofcYvLsK94qLYHETlIKAxOuOziTqjowqJPYMpYFZ78C+Wwx9yASxr3JuJXhsXrMSCrkCfaGupQwugwgHnQmUZQ9Yk= 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 1729872358282613.0971699659003; Fri, 25 Oct 2024 09:05:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t4Mot-00056F-TF; Fri, 25 Oct 2024 12:05:48 -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 1t4MoE-0004w2-KS for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:05:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t4MoC-0005BH-Kj for qemu-devel@nongnu.org; Fri, 25 Oct 2024 12:05:05 -0400 Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-428-rSZzLCADNLG0FmHUfgJteQ-1; Fri, 25 Oct 2024 12:05:02 -0400 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-539fe4e75c4so2420458e87.0 for ; Fri, 25 Oct 2024 09:05:01 -0700 (PDT) Received: from [192.168.10.47] ([151.81.112.43]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f29744esm85403966b.130.2024.10.25.09.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729872303; 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=F1V6b7WD574xZK3wF/C5mFToVHXs12LTfpeZesQABro=; b=OR4T+LtdHoVCNVehgwTpkuFW6ZUm3Tpe0bCpxTMzeCj3ZnbeKXv5yTDHNP716Q41e9Vm7p FegdcCKseho3zyEe9b1/4rZ1/9bh7AHj+I7dd1mWWAwnp0vko443wkhzBwm2uubV8qq/AG NfnF1gEGYM11jvSM7KZF4EpCej9bJZg= X-MC-Unique: rSZzLCADNLG0FmHUfgJteQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729872299; x=1730477099; 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=F1V6b7WD574xZK3wF/C5mFToVHXs12LTfpeZesQABro=; b=wHIj07bhJuPObAUWQCG59yhrrGYRrPNfUyb1FCBmm+SonEpsaMQ5kM1o8w8GVFV3aC sikLFVCL0uFjw9u1jvhuVeLUURZ6M+och6Sy7Yl+dgD3efJF0UkEn7TJd1W2WPUVsw5l V7LuaW1fNj986UwiCS4wm0qTlmNs70nTvsEwei4PlyGZn20jZi2mPV2yDETbjv/RPNQi hbaLeRGBSL1YxSLop8XlHOYLpoFSh/j/I7O1EoaUpDIqwfqC3bfNOPeJKqdNGZ5lccCw VmcOGHyn+pleixSvVNLumRueER4DEmYwh+qkBLkUwOUJUK3Z7q4LglhAvyG75eAfKnO8 Jw7Q== X-Gm-Message-State: AOJu0YwJXd3n4T6IFX62CFPcxCZYRZfarW5mv376UPm+6igYelgL0F0s FwA1u8eoTet97+sE+Wli+TwiokE2JMjvn0X6yoPoEpa4uuiGU9//39DPnVHKzpCSJEKLGy9lGsZ MdpfrXRc+3jms90IKbXiYysGwZrhjVsCmHVe/cFQW5s+T3+C1Ue/mXxnvfisu3ojjg8je12N2e6 Kye3+1k230XZlacF1nNGyR/GacELCbPhtqBkhWmcI= X-Received: by 2002:a05:6512:3d8f:b0:536:542e:ce1f with SMTP id 2adb3069b0e04-53b1a328380mr9416171e87.18.1729872299253; Fri, 25 Oct 2024 09:04:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFBhEYaybodERFQzYyZo/R3yQ6zOsNJ9esSX898Ky280/LlMY6EOd6iPh85NX9pgOofyH6e5g== X-Received: by 2002:a05:6512:3d8f:b0:536:542e:ce1f with SMTP id 2adb3069b0e04-53b1a328380mr9416123e87.18.1729872298671; Fri, 25 Oct 2024 09:04:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: manos.pitsidianakis@linaro.org, zhao1.liu@intel.com, junjie.mao@hotmail.com, berrange@redhat.com Subject: [PATCH 23/23] ci: enable rust in the Debian and Ubuntu system build job Date: Fri, 25 Oct 2024 18:02:08 +0200 Message-ID: <20241025160209.194307-24-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025160209.194307-1-pbonzini@redhat.com> References: <20241025160209.194307-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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.454, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1729872358797116600 Content-Type: text/plain; charset="utf-8" We have fixed all incompatibilities with older versions of rustc and bindgen. Enable Rust on Debian to check that the minimum supported version of Rust is indeed 1.63.0, and 0.60.x for bindgen. Signed-off-by: Paolo Bonzini Reviewed-by: Pierrick Bouvier Tested-by: Zhao Liu --- .gitlab-ci.d/buildtest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml index aba65ff833a..8deaf9627cb 100644 --- a/.gitlab-ci.d/buildtest.yml +++ b/.gitlab-ci.d/buildtest.yml @@ -40,7 +40,7 @@ build-system-ubuntu: job: amd64-ubuntu2204-container variables: IMAGE: ubuntu2204 - CONFIGURE_ARGS: --enable-docs + CONFIGURE_ARGS: --enable-docs --enable-rust TARGETS: alpha-softmmu microblazeel-softmmu mips64el-softmmu MAKE_CHECK_ARGS: check-build =20 @@ -71,7 +71,7 @@ build-system-debian: job: amd64-debian-container variables: IMAGE: debian - CONFIGURE_ARGS: --with-coroutine=3Dsigaltstack + CONFIGURE_ARGS: --with-coroutine=3Dsigaltstack --enable-rust TARGETS: arm-softmmu i386-softmmu riscv64-softmmu sh4-softmmu sparc-softmmu xtensa-softmmu MAKE_CHECK_ARGS: check-build --=20 2.47.0