qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, tanishdesai37@gmail.com,
	stefanha@redhat.com, mads@ynddal.dk
Subject: Re: [PATCH 10/14] tracetool/simple: add Rust support
Date: Tue, 26 Aug 2025 12:53:49 +0100	[thread overview]
Message-ID: <aK2gTWBwHpOY4iwm@redhat.com> (raw)
In-Reply-To: <20250822122655.1353197-11-pbonzini@redhat.com>

On Fri, Aug 22, 2025 at 02:26:51PM +0200, Paolo Bonzini wrote:
> From: Tanish Desai <tanishdesai37@gmail.com>
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  scripts/tracetool/__init__.py       |  2 +-
>  scripts/tracetool/backend/simple.py |  7 +++++
>  tests/tracetool/simple.rs           | 41 +++++++++++++++++++++++++++++
>  tests/tracetool/tracetool-test.py   |  2 ++
>  4 files changed, 51 insertions(+), 1 deletion(-)
>  create mode 100644 tests/tracetool/simple.rs
> 
> diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
> index 0b8ec707332..7542757799e 100644
> --- a/scripts/tracetool/__init__.py
> +++ b/scripts/tracetool/__init__.py
> @@ -336,7 +336,7 @@ def rust_call_extern(self):
>          def rust_cast(name, type_):
>              if type_ == "const char *":
>                  return f"_{name}.as_ptr()"
> -            return "_{name}"
> +            return f"_{name}"
>  
>          return ", ".join((rust_cast(name, type_) for type_, name in self._args))
>

This should be squashed into the earlier patch that introduced the mistake

> diff --git a/tests/tracetool/simple.rs b/tests/tracetool/simple.rs
> new file mode 100644
> index 00000000000..895096088dc
> --- /dev/null
> +++ b/tests/tracetool/simple.rs
> @@ -0,0 +1,41 @@
> +// This file is autogenerated by tracetool, do not edit.
> +
> +#[allow(unused_imports)]
> +use std::ffi::c_char;
> +#[allow(unused_imports)]
> +use qemu_api::bindings;
> +
> +#[inline(always)]
> +fn trace_event_get_state_dynamic_by_id(_id: u16) -> bool {
> +    unsafe { (trace_events_enabled_count != 0) && (_id != 0) }
> +}
> +
> +extern "C" {
> +    static mut trace_events_enabled_count: u32;
> +}
> +extern "C" {
> +    static mut _TRACE_TEST_BLAH_DSTATE: u16;
> +    static mut _TRACE_TEST_WIBBLE_DSTATE: u16;
> +}
> +const _TRACE_TEST_BLAH_ENABLED: bool = true;
> +const _TRACE_TEST_WIBBLE_ENABLED: bool = true;

Does rust have any policy reserving use of leading underscore in
identifiers  ?


> +
> +#[inline(always)]
> +#[allow(dead_code)]
> +pub fn trace_test_blah(_context: *mut (), _filename: &std::ffi::CStr)
> +{
> +    if trace_event_get_state_dynamic_by_id(unsafe { _TRACE_TEST_BLAH_DSTATE}) {
> +        extern "C" { fn _simple_trace_test_blah(_context: *mut (), _filename: *const std::ffi::c_char); }
> +        unsafe { _simple_trace_test_blah(_context, _filename.as_ptr()); }
> +    }
> +}
> +
> +#[inline(always)]
> +#[allow(dead_code)]
> +pub fn trace_test_wibble(_context: *mut (), _value: std::ffi::c_int)
> +{
> +    if trace_event_get_state_dynamic_by_id(unsafe { _TRACE_TEST_WIBBLE_DSTATE}) {
> +        extern "C" { fn _simple_trace_test_wibble(_context: *mut (), _value: std::ffi::c_int); }
> +        unsafe { _simple_trace_test_wibble(_context, _value); }
> +    }
> +}

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2025-08-26 11:54 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-22 12:26 [RFC PATCH 00/14] tracetool: add Rust support Paolo Bonzini
2025-08-22 12:26 ` [PATCH 01/14] treewide: write "unsigned long int" instead of "long unsigned int" Paolo Bonzini
2025-08-25  6:40   ` Manos Pitsidianakis
2025-08-25  9:18     ` Paolo Bonzini
2025-08-25  7:24   ` Zhao Liu
2025-08-26 11:15     ` Daniel P. Berrangé
2025-08-26 11:33       ` Peter Maydell
2025-08-22 12:26 ` [PATCH 02/14] rust: move dependencies to rust/Cargo.toml Paolo Bonzini
2025-08-25  7:04   ` Manos Pitsidianakis
2025-08-25  7:24   ` Zhao Liu
2025-08-27 19:12   ` Stefan Hajnoczi
2025-08-22 12:26 ` [PATCH 03/14] trace/ftrace: move snprintf+write from tracepoints to ftrace.c Paolo Bonzini
2025-08-25  7:09   ` Manos Pitsidianakis
2025-08-25  9:00   ` Zhao Liu
2025-08-26 11:40   ` Daniel P. Berrangé
2025-08-26 11:45     ` Peter Maydell
2025-08-26 11:58       ` Daniel P. Berrangé
2025-08-27 19:12   ` Stefan Hajnoczi
2025-08-22 12:26 ` [PATCH 04/14] tracetool: add CHECK_TRACE_EVENT_GET_STATE Paolo Bonzini
2025-08-26 11:44   ` Daniel P. Berrangé
2025-08-27 19:13   ` Stefan Hajnoczi
2025-08-22 12:26 ` [PATCH 05/14] tracetool/backend: remove redundant trace event checks Paolo Bonzini
2025-08-26 11:44   ` Daniel P. Berrangé
2025-08-27 19:15   ` Stefan Hajnoczi
2025-08-22 12:26 ` [PATCH 06/14] tracetool: Add Rust format support Paolo Bonzini
2025-08-25  7:03   ` Manos Pitsidianakis
2025-08-25  9:42     ` Paolo Bonzini
2025-08-25  7:22   ` Manos Pitsidianakis
2025-08-26 11:49   ` Daniel P. Berrangé
2025-08-22 12:26 ` [PATCH 07/14] rust: add trace crate Paolo Bonzini
2025-08-25  7:18   ` Manos Pitsidianakis
2025-08-25  9:54   ` Zhao Liu
2025-08-22 12:26 ` [PATCH 08/14] rust: qdev: add minimal clock bindings Paolo Bonzini
2025-08-25  7:50   ` Zhao Liu
2025-08-25  7:32     ` Manos Pitsidianakis
2025-08-25  9:58       ` Paolo Bonzini
2025-08-22 12:26 ` [PATCH 09/14] rust: pl011: add tracepoints Paolo Bonzini
2025-08-22 12:26 ` [PATCH 10/14] tracetool/simple: add Rust support Paolo Bonzini
2025-08-26 11:53   ` Daniel P. Berrangé [this message]
2025-09-19 10:51     ` Paolo Bonzini
2025-08-22 12:26 ` [PATCH 11/14] log: change qemu_loglevel to unsigned Paolo Bonzini
2025-08-25  7:07   ` Manos Pitsidianakis
2025-08-25  7:56   ` Zhao Liu
2025-08-26 13:52   ` Philippe Mathieu-Daudé
2025-08-22 12:26 ` [PATCH 12/14] tracetool/log: add Rust support Paolo Bonzini
2025-08-22 12:26 ` [PATCH 13/14] tracetool/ftrace: " Paolo Bonzini
2025-08-22 12:26 ` [PATCH 14/14] tracetool/syslog: " Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aK2gTWBwHpOY4iwm@redhat.com \
    --to=berrange@redhat.com \
    --cc=mads@ynddal.dk \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=tanishdesai37@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).