From nobody Mon Feb 9 04:11:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1749986551; cv=none; d=zohomail.com; s=zohoarc; b=hkk2SorZ9O+x1KbdAAEYw22jeSYL5cQQFI3FJi7J2KPrhKNheExVOITMF1JScs7kXinbN2rpzu/xnJp33AheFWAgGWQ4yAK3ZUVhwsU4kb2XUz3PqxZIf0g3syHiCilFTBw1mr2DKsnMwDLEvXdwS+ZjFAOOSwXOheEdJH71+e4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749986551; 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=GOSazWwN655AIgokLtohZGPN+qL0XFCzquoeB/U0TnE=; b=D1jSJ+upPYQkDIRW5u/VoT8YVsGu9OPe6q2r5c+tC2tISUsIfyqPm85bH/eXT1rxNHG0WiVgG//fPHiHekyktFhBiL1BTMB6rXcdNhjXY+sL6quNppjvMBG4/iaDTnDV6IEGSQXLlCK8T8PfPNCGXlWMC4gQ2ZZbXhRqts2+0qM= 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 174998655145342.092092888019806; Sun, 15 Jun 2025 04:22:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uQlQO-0003eo-6I; Sun, 15 Jun 2025 07:21:20 -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 1uQlQK-0003dv-Ld; Sun, 15 Jun 2025 07:21:16 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uQlQH-0007xw-U7; Sun, 15 Jun 2025 07:21:16 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3a4ef2c2ef3so2952077f8f.2; Sun, 15 Jun 2025 04:21:13 -0700 (PDT) Received: from Provence.localdomain (dynamic-2a02-3100-231b-9b00-0219-99ff-feb2-2458.310.pool.telefonica.de. [2a02:3100:231b:9b00:219:99ff:feb2:2458]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a568b5c372sm7327099f8f.89.2025.06.15.04.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jun 2025 04:21:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749986471; x=1750591271; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GOSazWwN655AIgokLtohZGPN+qL0XFCzquoeB/U0TnE=; b=LweUYbxypWkWvyuHKma4O5xBFKl9wQiX0EsPpF6JaMnQRlch60xfAcmj2FhwuRwKSe mNJD2uGEDCGnQXigXLkCBmFZpm0G8Pz3C1bgx81dqvydq7/HsfUmrq4M6Ms78oq8B6n3 jb99ioPySMiEYid/Kwl9P6g9X2bgzTSOxNdSkJm0B7XSmGk9MOybDRyHGr39EFmi/uSP sWErApPJ3y3z6uQ8HH70pAQoVV0aLi0mZQ6srLnp3aW0bD2Iri6x9439uYR2js5N5kA1 Ha+fGpyvdQneVxvzXhoJIu/PkiTmAWyzCxz0S4/lsU3U5f7SzpWUYoIvgJM1Jx+eAyBE AVtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749986471; x=1750591271; 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=GOSazWwN655AIgokLtohZGPN+qL0XFCzquoeB/U0TnE=; b=mluymFCNUww8lok4tE7PyrZ2q5jVwMrAAni5T/+JbBQBuNuuVAHzXi3diwJ7WUoRQI Mf4oyJaSNbTdUf0D2Xg7ugr6HC+TP9dd9RAkSO+AJ3R8Ss7pgRZ8I7Fm89/OS/0OzgBZ ZpIIANnWfqXRq9/MraInPJ+YKrDG3FkVJtzmYw9d0Q5AfoPWAT01RmNZMG80n4qtkWZb Bm/OWBVVSlP2mUZQwUwfrgeFhx8KLWioUCVqRAZXu1jXAB8cX1J4TJJc3cy8VFECgdZm H/A4JQRMTs0+x6g17zuAuIb8U43hD/sDg4Cb6aRRcByE0oBNSS4e47M2mb043wd0+qDx TTDQ== X-Forwarded-Encrypted: i=1; AJvYcCXoo9OBgtS1famHev8eFf7BYukt7BopeaVP0yMjCxaCSxJPX1hhQYW6LmHlSg4VDTPxljK9AtwWioU=@nongnu.org X-Gm-Message-State: AOJu0Yw7+bL5xSq0WykLCT/iTrjvfKOyprc/5VsbSzcv5e84d5rwPslU qzC5fwoFDe0Kk5Mb1FI9dbp23NrGWJsyJrxZO5QQt1pYyCxUZ0Gz0xu4/OAJZQ== X-Gm-Gg: ASbGncuGHZk5WnXLHY88aVV0I+ij+V0/b59SSLg6AJor5gMc//sdXD4IPMsVH5AhXuF 3M43Nd2pQ33GOcAU9z78AEa9RgB3/qL1dTVhqZ4LpphY2+v55WBJaH2k11qa0C+muNZTS/floW/ 6v8dsGAUt0yVJp6PRTnvTGJcTytTwALNh4qedz9uGBUe6Hz9UmlgFQwsXF2otAlNKTraa9xGb8u CnMRBuAqQrhTjdPJzGIQWdxgcFmbiJe/6IJbx5y8TTenYj3CuJc21DREA2nlaQ8lvmlCxcHCu9e NA4/pgfjcOn9mcEo2bqBZ8rcRrlJ12QyrNsP2hGHKp06DfBMi4i/2355xDdPgADVoi5PU6D791H POHCBRsTWnwFeazuNbCuLQI9963Z/OvSrICJRqFBzfWeb8GWkCxXMfYuyNISR2SWUoj3CaFRmy0 8//Y1x1g== X-Google-Smtp-Source: AGHT+IHRcKJm2uEfjPxwsJtfrZob2XRVen8PUExl2auoG8Byuob7lnyGPPHm9Q+KXzHbnGibo5Wx7w== X-Received: by 2002:a05:6000:2dc3:b0:3a5:1471:d885 with SMTP id ffacd0b85a97d-3a572e58cb3mr4350729f8f.56.1749986471301; Sun, 15 Jun 2025 04:21:11 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Paolo Bonzini , qemu-rust@nongnu.org, Bernhard Beschow Subject: [PATCH v3 1/4] rust/qemu-api: Add initial logging support based on C API Date: Sun, 15 Jun 2025 13:20:34 +0200 Message-ID: <20250615112037.11992-2-shentey@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250615112037.11992-1-shentey@gmail.com> References: <20250615112037.11992-1-shentey@gmail.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=2a00:1450:4864:20::429; envelope-from=shentey@gmail.com; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 @gmail.com) X-ZM-MESSAGEID: 1749986552083116600 Content-Type: text/plain; charset="utf-8" A log_mask_ln!() macro is provided which expects similar arguments as the C version. However, the formatting works as one would expect from Rust. To maximize code reuse the macro is just a thin wrapper around qemu_log(). Also, just the bare minimum of logging masks is provided which should suffice for the current use case of Rust in QEMU. Signed-off-by: Bernhard Beschow --- docs/devel/rust.rst | 1 + rust/wrapper.h | 2 + rust/qemu-api/meson.build | 1 + rust/qemu-api/src/lib.rs | 1 + rust/qemu-api/src/log.rs | 78 ++++++++++++++++++++++++++++++++++++ rust/qemu-api/src/prelude.rs | 2 + 6 files changed, 85 insertions(+) create mode 100644 rust/qemu-api/src/log.rs diff --git a/docs/devel/rust.rst b/docs/devel/rust.rst index 47e9677fcb..dc8c44109e 100644 --- a/docs/devel/rust.rst +++ b/docs/devel/rust.rst @@ -162,6 +162,7 @@ module status ``errno`` complete ``error`` stable ``irq`` complete +``log`` proof of concept ``memory`` stable ``module`` complete ``qdev`` stable diff --git a/rust/wrapper.h b/rust/wrapper.h index 6060d3ba1a..15a1b19847 100644 --- a/rust/wrapper.h +++ b/rust/wrapper.h @@ -48,6 +48,8 @@ typedef enum memory_order { #endif /* __CLANG_STDATOMIC_H */ =20 #include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/log-for-trace.h" #include "qemu/module.h" #include "qemu-io.h" #include "system/system.h" diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index cac8595a14..33caee3c4f 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -21,6 +21,7 @@ _qemu_api_rs =3D static_library( 'src/errno.rs', 'src/error.rs', 'src/irq.rs', + 'src/log.rs', 'src/memory.rs', 'src/module.rs', 'src/prelude.rs', diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index 93902fc94b..e20be35460 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -21,6 +21,7 @@ pub mod errno; pub mod error; pub mod irq; +pub mod log; pub mod memory; pub mod module; pub mod qdev; diff --git a/rust/qemu-api/src/log.rs b/rust/qemu-api/src/log.rs new file mode 100644 index 0000000000..0d7f06e63c --- /dev/null +++ b/rust/qemu-api/src/log.rs @@ -0,0 +1,78 @@ +// Copyright 2025 Bernhard Beschow +// SPDX-License-Identifier: GPL-2.0-or-later + +//! Bindings for QEMU's logging infrastructure + +#[repr(u32)] +/// Represents specific error categories within QEMU's logging system. +/// +/// The `Log` enum provides a Rust abstraction for logging errors, corresp= onding +/// to a subset of the error categories defined in the C implementation. +pub enum Log { + /// Log invalid access caused by the guest. + /// Corresponds to `LOG_GUEST_ERROR` in the C implementation. + GuestError =3D crate::bindings::LOG_GUEST_ERROR, + + /// Log guest access of unimplemented functionality. + /// Corresponds to `LOG_UNIMP` in the C implementation. + Unimp =3D crate::bindings::LOG_UNIMP, +} + +/// A macro to log messages conditionally based on a provided mask. +/// +/// The `log_mask_ln` macro checks whether the given mask matches the curr= ent +/// log level and, if so, formats and logs the message. It is the Rust +/// counterpart of the `qemu_log_mask()` macro in the C implementation. +/// +/// # Parameters +/// +/// - `$mask`: A log level mask. This should be a variant of the `Log` enu= m. +/// - `$fmt`: A format string following the syntax and rules of the `forma= t!` +/// macro. It specifies the structure of the log message. +/// - `$args`: Optional arguments to be interpolated into the format strin= g. +/// +/// # Example +/// +/// ``` +/// use qemu_api::log::Log; +/// use qemu_api::log_mask_ln; +/// +/// let error_address =3D 0xbad; +/// log_mask_ln!( +/// Log::GuestError, +/// "Address 0x{error_address:x} out of range" +/// ); +/// ``` +/// +/// It is also possible to use printf-style formatting, as well as having a +/// trailing `,`: +/// +/// ``` +/// use qemu_api::log::Log; +/// use qemu_api::log_mask_ln; +/// +/// let error_address =3D 0xbad; +/// log_mask_ln!( +/// Log::GuestError, +/// "Address 0x{:x} out of range", +/// error_address, +/// ); +/// ``` +#[macro_export] +macro_rules! log_mask_ln { + ($mask:expr, $fmt:tt $($args:tt)*) =3D> {{ + // Type assertion to enforce type `Log` for $mask + let _: Log =3D $mask; + + if unsafe { + (::qemu_api::bindings::qemu_loglevel & ($mask as std::os::raw:= :c_int)) !=3D 0 + } { + let formatted_string =3D format!("{}\n", format_args!($fmt $($= args)*)); + let c_string =3D std::ffi::CString::new(formatted_string).unwr= ap(); + + unsafe { + ::qemu_api::bindings::qemu_log(c_string.as_ptr()); + } + } + }}; +} diff --git a/rust/qemu-api/src/prelude.rs b/rust/qemu-api/src/prelude.rs index 43bfcd5fca..8f9e23ee2c 100644 --- a/rust/qemu-api/src/prelude.rs +++ b/rust/qemu-api/src/prelude.rs @@ -11,6 +11,8 @@ =20 pub use crate::errno; =20 +pub use crate::log_mask_ln; + pub use crate::qdev::DeviceMethods; =20 pub use crate::qom::InterfaceType; --=20 2.49.0 From nobody Mon Feb 9 04:11:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1749986517; cv=none; d=zohomail.com; s=zohoarc; b=MYB+82nQc0Ojtq0lAvix0iJ5cru667NUQkpEpqebPZM/h17FWIRSSr5V7l7OPI39bZYcrE7E4CobUl+ihIHDnYahek6LVuCTmIamEzbc5haYeIbg6y+ukHN91dSgwcv695tQBr9zljomNPB5A3T5tgEI1/6zPOPOBKXPFH1lfgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749986517; 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=P8ZAY6eIGVrJzx52bkDggMM638/7q1R15DHDcagaO4c=; b=d6wiqBIGxFAY/W+6y/mT2bQ+DXYJ6hhUmswZL+eaShTPNIeZHM9eucpSqY+o9OU0LA7Q7+GCCfTTnWOj/gKvILVZCiip7PO8r4+9ut9A4RwXhGe1ANk+fr3fs7UrPaNQ5gtmNTv6i87h96HSHhyBziFook0E8mU68HmQQnv/Rcs= 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 1749986517916978.2260196566807; Sun, 15 Jun 2025 04:21:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uQlQT-0003gE-RR; Sun, 15 Jun 2025 07:21:27 -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 1uQlQL-0003eG-Ly; Sun, 15 Jun 2025 07:21:17 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uQlQI-0007y2-U3; Sun, 15 Jun 2025 07:21:17 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-450d668c2a1so31189935e9.0; Sun, 15 Jun 2025 04:21:14 -0700 (PDT) Received: from Provence.localdomain (dynamic-2a02-3100-231b-9b00-0219-99ff-feb2-2458.310.pool.telefonica.de. [2a02:3100:231b:9b00:219:99ff:feb2:2458]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a568b5c372sm7327099f8f.89.2025.06.15.04.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jun 2025 04:21:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749986472; x=1750591272; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P8ZAY6eIGVrJzx52bkDggMM638/7q1R15DHDcagaO4c=; b=bBouAGmjp+EKpkQUAvuw3YMu+LsmZqesjGKBezJ0Lvop1ieZC64pf6vKc/wfBAUJVL ZIqjt2ETfUQkpxRfIDOnvUMv2FlPwIIK4n00e4nFriguEDoKAPE6YUvDo79ev1/Pwu5W IIRT56NG2+e0kScMF30D2dtOQlfg3PkGWieVsIWhP6Uzz4ATnBayQ6i/hSWzTUTCPJbB 3c55CLVnZoCuq9pcu3pi6Oz08ayBKupWn1NFCAkKDxKsP3DvDc+4m+K87Ln0iFx6ylXz D8N9E8Hxb3AvgA9WRvusGk3dfXwr30xilBmvX/DzPfW4Lb4FrDC//dxE+mjl3g/n0nNS POdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749986472; x=1750591272; 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=P8ZAY6eIGVrJzx52bkDggMM638/7q1R15DHDcagaO4c=; b=aOcsxOctRhehxFg4ue3LVEQGkkySpAfTsRDbMVzlBylRaheeVC4EB9rHB4weyPpFGo FSDVAaHX6iMct473h+vjdYfBc0AY1rl8xWsegLYUu1P2jDkudbWz5hfl65llXLc55o+1 f+YoBy95z4enUSgRqA5ZN6mlbpqTuUzWkZzE98ojfVGegEj+92WZdMeQtt1APOsZ0YCn QheWwFriXGTpZkPA8hFdgDpyZZsTPdaAX1dxjGMT/1CARlVQuESrRyqWzPbWTzBYIWvC R3F3/CV4Lhapu/sbTsWGpSuWh47v7uPVOwLnoGjvemFyAvagjXbe12EzYMyX6ODixbQ8 Uqqg== X-Forwarded-Encrypted: i=1; AJvYcCVuvN23sM6s9NTYnb5MZLbfDPBPjM7nBJfrFaqatPC4kGVSx8mbd6weU7z59iq7BMvnsMwzCh+qzvo=@nongnu.org X-Gm-Message-State: AOJu0Yx0JYzB7vlcVSXkcQZPn2pZUJLZS6Z4JT5oSo3LqwON4cDWZ0Bu 6LAJoUWyI8nfoTaKPQxJRv9mXXINkTYIprBNLVLK5omLF3cVPZSvde9HGQQdoQ== X-Gm-Gg: ASbGncsJzdihlHDTBhJVxmVWWvYg1VKwsuaboJxTylnvfV7xFW2oMXXajR93fU1HPWM qVaS8M38/BvtzaosBpvxDEsqZ9EKSNcfI2pSsAsCDGlQ+8T8miSN3fhHvDsYvPS+i/66VT89/W4 NcSt73OSZM00B4uKhDAQgHxZRTnek9t1pfOdUYoO3eFR04aKBKHzks7X/bdsV9HHpfXI8X1sxhR GNENbZReVJf8fIS7f1feaPGHoJQscf2Yg68xXl2MkIHH6adRIoO+kihzYtTT5gcle4A9ANNS548 0MI5/UTF4/0XUg+doMIKnfbfZmGy7w1632WfwUFR72wF2hsoNMTAFPac/sWwYhvwHSI/KquTjWQ rkQ9mdQ5APuzsar2gxBpytmxPuS1tcErQ3FW3UrpH6ptCi8YCvZV2rvKceKxRgmhmg6D0Z8S3OY YxmbWCjuRYi6KThdFY X-Google-Smtp-Source: AGHT+IFScch2F8u1V6k+XUxgjGw6Hq6dhWt9obagz53Lc3uwHX9XfJhcJloREcz49cMl0bqImtWC8w== X-Received: by 2002:adf:9d92:0:b0:3a5:7895:7f6b with SMTP id ffacd0b85a97d-3a578958019mr2801870f8f.7.1749986472088; Sun, 15 Jun 2025 04:21:12 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Paolo Bonzini , qemu-rust@nongnu.org, Bernhard Beschow Subject: [PATCH v3 2/4] rust/hw/char/pl011/src/device: Implement logging Date: Sun, 15 Jun 2025 13:20:35 +0200 Message-ID: <20250615112037.11992-3-shentey@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250615112037.11992-1-shentey@gmail.com> References: <20250615112037.11992-1-shentey@gmail.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=2a00:1450:4864:20::32a; envelope-from=shentey@gmail.com; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 @gmail.com) X-ZM-MESSAGEID: 1749986519818116600 Content-Type: text/plain; charset="utf-8" Now that there is logging support in Rust for QEMU, use it in the pl011 device. Signed-off-by: Bernhard Beschow --- rust/hw/char/pl011/src/device.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index be8387f6f2..fa591c3ef6 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -8,6 +8,8 @@ chardev::{CharBackend, Chardev, Event}, impl_vmstate_forward, irq::{IRQState, InterruptSource}, + log::Log, + log_mask_ln, memory::{hwaddr, MemoryRegion, MemoryRegionOps, MemoryRegionOpsBuilder= }, prelude::*, qdev::{Clock, ClockEvent, DeviceImpl, DeviceState, Property, ResetType= , ResettablePhasesImpl}, @@ -275,8 +277,7 @@ pub(self) fn write( DMACR =3D> { self.dmacr =3D value; if value & 3 > 0 { - // qemu_log_mask(LOG_UNIMP, "pl011: DMA not implemente= d\n"); - eprintln!("pl011: DMA not implemented"); + log_mask_ln!(Log::Unimp, "pl011: DMA not implemented"); } } } @@ -538,7 +539,7 @@ fn read(&self, offset: hwaddr, _size: u32) -> u64 { u64::from(device_id[(offset - 0xfe0) >> 2]) } Err(_) =3D> { - // qemu_log_mask(LOG_GUEST_ERROR, "pl011_read: Bad offset = 0x%x\n", (int)offset); + log_mask_ln!(Log::GuestError, "PL011State::read: Bad offse= t {offset}"); 0 } Ok(field) =3D> { @@ -570,7 +571,10 @@ fn write(&self, offset: hwaddr, value: u64, _size: u32= ) { .borrow_mut() .write(field, value as u32, &self.char_backend); } else { - eprintln!("write bad offset {offset} value {value}"); + log_mask_ln!( + Log::GuestError, + "PL011State::write: Bad offset {offset} value {value}" + ); } if update_irq { self.update(); --=20 2.49.0 From nobody Mon Feb 9 04:11:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1749986559; cv=none; d=zohomail.com; s=zohoarc; b=nqjizbcYlWPuw/9w+oEVwzt3W01vAAdA6+H4HSwF3VzG/pDBHf9ZV9imllVRNpamfDm1Iy/wNGlATNtfBSM7xgrRRvCyLa5G7I9dv/48gFdO10BxcU3h/QclkzW51z304efPF1e2lYUolbcWwG2dt6i6JL3zihfEjHv1/UxAQZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749986559; 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=1PAd+Ag09Z1RtE6nSLbu8MU1jQdIfYloyvGbcP1uNwY=; b=eIpxuFmoQCwYTG3YfM3Ef6DKhmp35ndYrKfAIyBobxNer5DRtknq+N9bBpY1nnUnH6JcvK1RO6VXIdxHpSUU6rWxNkoKmpxfDqiB3WvgNpvqpHyi7QoZ5dvsXjegSBQmJnbEvo79h2AU7Bst5XZA319+9JiiJI0vY9cgScoJIvk= 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 1749986559121946.710648666411; Sun, 15 Jun 2025 04:22:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uQlQZ-0003nr-Pi; Sun, 15 Jun 2025 07:21: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 1uQlQM-0003eL-15; Sun, 15 Jun 2025 07:21:18 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uQlQK-0007y8-Gr; Sun, 15 Jun 2025 07:21:17 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3a507e88b0aso3492212f8f.1; Sun, 15 Jun 2025 04:21:14 -0700 (PDT) Received: from Provence.localdomain (dynamic-2a02-3100-231b-9b00-0219-99ff-feb2-2458.310.pool.telefonica.de. [2a02:3100:231b:9b00:219:99ff:feb2:2458]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a568b5c372sm7327099f8f.89.2025.06.15.04.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jun 2025 04:21:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749986473; x=1750591273; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1PAd+Ag09Z1RtE6nSLbu8MU1jQdIfYloyvGbcP1uNwY=; b=FnJqbTuJqQao/hZC6gPbNUF1RMpUSlGE2adBMmu4r3cj6O/spFGW4yOCR9sH7ldhif 2wCd/UocmHH76g54pjnwehq+0gRXEzQ2ldG3ykc6bIYiiWlywHz8q0fE0C6ndr1Svwlo koI/AF/6q6Kt2X5k/EJxaWIRzYzVuyNevog6eRWnaDnUOLrYSTP8AayVn+an3GxZ/d+q GHTWx4nrixQTOV1HbAfGBvgDac/X/3tOdRxXO79eMTk6yg99qV2SibWv7OBv1QpaGA1h QB/aZtBCVPaCaBG0QSC9+7Wa8vLuF0twmCisaVeLXYypQ9qplFG8HfoOveP9e86GAZpt ATjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749986473; x=1750591273; 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=1PAd+Ag09Z1RtE6nSLbu8MU1jQdIfYloyvGbcP1uNwY=; b=YwY0TxHnOwNEuBqXMIYxQR1uhuojMqoIMCTjKugtFRzL2QbQD8x0er1gGu0ySC2oS3 7+9CXcwbWZ1w6/kNs40NgvKDp0eQm/+P5RYtRNxI000Jb51oM0pvpbCkwKnSxZLjehfE AmFY+PwhAh223XmbjKQ/KZb7CQW3Qk26ZBz27K5h242rmtR0rwyexOadWTwgpYqGf92r RRfmyg1uH2/4ZBMs6+e0MdiuQD2QQtTVDEcvAYLhiivwSNOOveLKnbpu4N8P7SE/uiR/ sQXq8Hj4HEJz9iEh+gC/NtEwMVwdaSNgKbp183Be9irZVm5ZH2yLJ0OqD7Wk5VglzVWJ mfFQ== X-Forwarded-Encrypted: i=1; AJvYcCXTEwthdNLerWKpQ6BHED2/rXdTroMqMeSK3ocTzZy8syZW3ybMUhf9rn2aEZboPgiitzNX+fWhR2I=@nongnu.org X-Gm-Message-State: AOJu0Yw4szZ6S2a+odThntvmI+qMHjcfLu+B2L09Uhtn5bF2wu/EqucM nQF45StCrkXS00Q3wIs+iqym7ClJwGPJfwk4oyBKk2qY8q+v/0fyVUT/X4AxeA== X-Gm-Gg: ASbGncvGGEOngRcwvASSWUEhQDMz04NXCxAwKr7ICkqZmMhLTUfGUgFZmLVE1wrn9b/ k4sYbbjfc/cqKS1zjMTaCTpkXfuEVCswdBmpqCtIyM1spBMV6sQlAaO4PL9no51812O3BTHmh2q mo1rWI8xgCdztp7bEZcPfg4Q5anRiXYupTfnfS+jJP0xHfuHzRsCOir/02F2RuzXjnxnnqBcx+v vAx5kqfyOtBiwiyKb6nMOhDtT8V7keqYaejtUjDsqyM1+GvFO66Z2C0ilCW+IxwgyFLOePMeaEN x7DECuz9a7vRBxP/az1pbhogmoQraEDhAod0Y+MvLvuI8clWFLGM0g02kEjQ0pCVff/jY5amK1L 0tTyW8mw0iNDQgaMkKaiv6Y5BjHhHe9ZoyKo5Al3E2RFPmT8MM9MawPZQe/PaG88JBJyAAxQvp0 cx1ymosQ== X-Google-Smtp-Source: AGHT+IGqFpEiTIg7K7tEux/BOI4K4o2CpLwSw+ng+8y1WcXpcuD9s52EVtO5umVxRJCb8D31lJmMnw== X-Received: by 2002:a05:6000:2884:b0:3a5:2ef8:3512 with SMTP id ffacd0b85a97d-3a572373cdamr5418243f8f.14.1749986472881; Sun, 15 Jun 2025 04:21:12 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Paolo Bonzini , qemu-rust@nongnu.org, Bernhard Beschow Subject: [PATCH v3 3/4] rust/hw/char/pl011/src/device: Add missing logging to match C version Date: Sun, 15 Jun 2025 13:20:36 +0200 Message-ID: <20250615112037.11992-4-shentey@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250615112037.11992-1-shentey@gmail.com> References: <20250615112037.11992-1-shentey@gmail.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=2a00:1450:4864:20::42b; envelope-from=shentey@gmail.com; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 @gmail.com) X-ZM-MESSAGEID: 1749986560142116600 Content-Type: text/plain; charset="utf-8" Co-developed-by: Paolo Bonzini Signed-off-by: Bernhard Beschow --- rust/hw/char/pl011/src/device.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index fa591c3ef6..48b4bca6b8 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -304,6 +304,12 @@ fn read_data_register(&mut self, update: &mut bool) ->= u32 { } =20 fn write_data_register(&mut self, value: u32) -> bool { + if !self.control.enable_uart() { + log_mask_ln!(Log::GuestError, "PL011 data written to disabled = UART"); + } + if !self.control.enable_transmit() { + log_mask_ln!(Log::GuestError, "PL011 data written to disabled = TX UART"); + } // interrupts always checked let _ =3D self.loopback_tx(value.into()); self.int_level |=3D Interrupt::TX; --=20 2.49.0 From nobody Mon Feb 9 04:11:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1749986536; cv=none; d=zohomail.com; s=zohoarc; b=ivKjBK5lDixc0kQUOnorHs4SbtwF/fLKPYyCQj4Rwgur8TUzDKwxBGrUFkexkWaJ1IIvYWFfaiYEIXpeegxnNKi5UnwWzAG8dTA5GeAJvGn+2+3xl+I7gQz3FNGWImZCVSnhkcanji84gfPjlmsitVrqf2Ub9k0jsWkZF89G/l0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749986536; 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=2c5qfKZcmwYpDnUHRh6s6NpbcxxLoJdjpMU5BVDJlAk=; b=mGW1lHwTSK7SMRN6yATJJEfMe4D03Hm6nGXIYa6ODZl/6kaq70RpLeFmW3Lxa8jvESxN9J0LrcWSjfBNVDB8Esq9Zbi1m8PjqPMeF0CaFJpWXLZBkibv9korvfspnXo7vzeB0SVc8GV3WlwiPeTzlFhnJ72PQxThqvkYvVVZomA= 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 1749986536203661.0454374948278; Sun, 15 Jun 2025 04:22:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uQlQb-0003pV-3W; Sun, 15 Jun 2025 07:21: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 1uQlQM-0003en-Gk; Sun, 15 Jun 2025 07:21:19 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uQlQL-0007z5-1K; Sun, 15 Jun 2025 07:21:18 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-451e2f0d9c2so29486905e9.1; Sun, 15 Jun 2025 04:21:16 -0700 (PDT) Received: from Provence.localdomain (dynamic-2a02-3100-231b-9b00-0219-99ff-feb2-2458.310.pool.telefonica.de. [2a02:3100:231b:9b00:219:99ff:feb2:2458]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a568b5c372sm7327099f8f.89.2025.06.15.04.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jun 2025 04:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749986474; x=1750591274; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2c5qfKZcmwYpDnUHRh6s6NpbcxxLoJdjpMU5BVDJlAk=; b=LrqmGHg5WmX09giCpVzHt/4ga0b2kC3j8bvaQvTs0iUUmbITM6VlnAjec0o/tievWg SzKLLcxjaxhq1kcyU4VrCsdJWvB5EhBvxuMKIOerMwrBcIF7dZ82YTXIWOhRpB/cajFy JQiXj4x9knrw2S4i4mXazPMg6e3LnZlpo5LGV83HlvJ5FpqTUhSetJ5U4eIosOKIxdA0 2vifg9KK0brPITn3NzGg6b326+cjWQXgoO/XhVyTaWeTEDHGYFKsE+k2dLQH/Ua413nr PcwBWmMcBACAt4dNDPR6tGqmbM3N0js16OjoK1knyrWOY7ZExEW3TsJEFS7BRRPlaPjc WdAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749986474; x=1750591274; 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=2c5qfKZcmwYpDnUHRh6s6NpbcxxLoJdjpMU5BVDJlAk=; b=s2+N3w8/SZvx5U/EitMW0/YzQbiVdqtCyFdpoX+PAUF3Vm2Cxnn8ktBu53QfMRQTpL zict1M2qgRE9mn01Q6X/evCPtpaMMeRpHFtT783pZcQNyzvYiM2CUnIyEiI95RUqoqq6 K+J027FRcrZDVSFqzveOsZhDWYbVlfDCF3PoPP3DBmSxS6GFxFyx+4cpsXGZ+oPrqXF+ 5ELyCiSudrHnweb09LABD0M68NWh5+hyhL7RCdl/Rb7WHPLVnj2yAUubCqBWYX0MAiFN xIF9H8Sx2KTBeDomjQggo7OWXpMD+KNcWakoVfptHnEiI1skeUOjSMeh8BnDs5G10oiE ek5Q== X-Forwarded-Encrypted: i=1; AJvYcCVXSDWb9gJiHqAjkg/7Z90nsuUr3KWYSa3M/tYxkiCtAO3xTKR0QzVi6JWIUPq/nrWKNAKlicyZtzY=@nongnu.org X-Gm-Message-State: AOJu0YzVzgNgRTCI7Cv8SDIM0HfViYznCA5saGTxz36/kq+hsG6mSLUk KmJdtdwLBQf8umYT8Jv4GCxgdsl8kMpxDp6NFiCqUbp+hCasU83BmkrXxA9C9Q== X-Gm-Gg: ASbGncvwW66vzSJcoX5OiYxqk5oncsTddptkiPcIH8Xr2E/EzgPSJqo0WHb9AfBNweE ClsePEWy6JvhooRzeEM5yWGKCVAo2wgQNgJHvehSLxokaEoBfdO+gfeuyqK9px186E34ESgdKP7 Gljdwx2dFf2QF/ZVodTNwUJv+PSnrSDTMA0KI5rIEnxLCFg1FNJD5h+INrezc2EGwPramgjYYJC ixdgnmWJeAvU7EY87+XY3YCsNkBIlw3bbBchiL2B+G/ahx3SMsIQ3h6bnXA1VJXkv+Quy4i5T2y cWXLkyp5baWDHF6M0i20J/vTf10ac+Z0vr4huEHkVBaL9ty5oWBlv81LhbVJYOgdDOju3bbOzWx aUS0uPL5VEDGVSXUn6VkIACZrRoylcCIyOXEQXHs2Hyg9iDbH0aCYlqmxkG94me0jj0vbTqJ3FP 4YmhRHkg== X-Google-Smtp-Source: AGHT+IHAaIVSOBh7QurW4GdAIH3p1GVLkLBB77gQHQfwKB0esk0dVHziuPn65jh5CqXEGevpKUa2lQ== X-Received: by 2002:a05:600c:4f4b:b0:439:5f04:4f8d with SMTP id 5b1f17b1804b1-453449ea4b5mr22834735e9.12.1749986473941; Sun, 15 Jun 2025 04:21:13 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Paolo Bonzini , qemu-rust@nongnu.org, Bernhard Beschow Subject: [PATCH v3 4/4] rust/qemu-api: Fix clippy lint `missing_const_for_fn` Date: Sun, 15 Jun 2025 13:20:37 +0200 Message-ID: <20250615112037.11992-5-shentey@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250615112037.11992-1-shentey@gmail.com> References: <20250615112037.11992-1-shentey@gmail.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=2a00:1450:4864:20::32d; envelope-from=shentey@gmail.com; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 @gmail.com) X-ZM-MESSAGEID: 1749986537842116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Bernhard Beschow --- rust/qemu-api/src/cell.rs | 2 +- rust/qemu-api/src/qom.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/qemu-api/src/cell.rs b/rust/qemu-api/src/cell.rs index 27063b049d..851573f8ef 100644 --- a/rust/qemu-api/src/cell.rs +++ b/rust/qemu-api/src/cell.rs @@ -965,7 +965,7 @@ impl Opaque { /// # Safety /// /// The pointer must be valid, though it need not point to a valid val= ue. - pub unsafe fn from_raw<'a>(ptr: *mut T) -> &'a Self { + pub const unsafe fn from_raw<'a>(ptr: *mut T) -> &'a Self { let ptr =3D NonNull::new(ptr).unwrap().cast::(); // SAFETY: Self is a transparent wrapper over T unsafe { ptr.as_ref() } diff --git a/rust/qemu-api/src/qom.rs b/rust/qemu-api/src/qom.rs index 14f98fee60..29d1b02720 100644 --- a/rust/qemu-api/src/qom.rs +++ b/rust/qemu-api/src/qom.rs @@ -634,7 +634,7 @@ impl Owned { /// back to `from_raw()` (assuming the original `Owned` was valid!), /// since the owned reference remains there between the calls to /// `into_raw()` and `from_raw()`. - pub unsafe fn from_raw(ptr: *const T) -> Self { + pub const unsafe fn from_raw(ptr: *const T) -> Self { // SAFETY NOTE: while NonNull requires a mutable pointer, only // Deref is implemented so the pointer passed to from_raw // remains const --=20 2.49.0