From: Zhao Liu <zhao1.liu@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
qemu-rust@nongnu.org, Junjie Mao <junjie.mao@hotmail.com>
Subject: Re: [PATCH 26/26] rust: callbacks: allow passing optional callbacks as ()
Date: Wed, 18 Dec 2024 23:09:55 +0800 [thread overview]
Message-ID: <Z2Llw0dHB6SpGMwr@intel.com> (raw)
In-Reply-To: <CABgObfZJNC2EWsYYSZfTYF8mebRzAmiYwD=d6bdG=10oQ3tQBg@mail.gmail.com>
On Wed, Dec 18, 2024 at 08:32:59AM +0100, Paolo Bonzini wrote:
> Date: Wed, 18 Dec 2024 08:32:59 +0100
> From: Paolo Bonzini <pbonzini@redhat.com>
> Subject: Re: [PATCH 26/26] rust: callbacks: allow passing optional
> callbacks as ()
>
> Il mer 18 dic 2024, 07:50 Zhao Liu <zhao1.liu@intel.com> ha scritto:
>
> > Am I using the wrong terminology? Function pointers in a structure should
> > be called a vtable, rather than callbacks (for example, methods in
> > TypeInfo,
> > read/write methods in MemoryRegionOps). Callbacks are typically function
> > pointers used as function parameters (for example, timer/gpio). So, is the
> > callback implementation here only used for the latter case?
> >
>
> The callback implementation is not used for QOM indeed. In that case, using
> FnCall would require something like
>
> const UNPARENT: impl FnCall((&Self,));
>
> which does not exist as far as I know?
Yes, it's incorrect. (I know you have some magic, so I have this question
to see your idea.)
> MemoryRegionOps is a mix of callbacks and a vtable. From the Rust point of
> view, with the API that uses the builder pattern, MemoryRegionOps (and
> VMStateDescription too) would be closer to callbacks. Instead when you use
> traits and fill in the class object, that's clearly a vtable.
>
> But in this sense MemoryRegionOps do not need optional callbacks. You just
> don't call the ops.read() method if you don't need to set a read callback
> for example. So I am not sure if anything that is planned right now needs
> the optional callbacks. It's good to have the patch for the future but it's
> not necessary right now.
Thanks for your explaination. I agree your plan. I also think it will be
useful in the future.
Regards,
Zhao
next prev parent reply other threads:[~2024-12-18 14:51 UTC|newest]
Thread overview: 81+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-09 12:36 [PATCH 00/26] rust: bundle of prerequisites for HPET implementation Paolo Bonzini
2024-12-09 12:36 ` [PATCH 01/26] bql: check that the BQL is not dropped within marked sections Paolo Bonzini
2024-12-09 12:36 ` [PATCH 02/26] rust: cell: add BQL-enforcing Cell variant Paolo Bonzini
2024-12-09 12:36 ` [PATCH 03/26] rust: cell: add BQL-enforcing RefCell variant Paolo Bonzini
2024-12-09 12:36 ` [PATCH 04/26] rust: define prelude Paolo Bonzini
2024-12-10 7:19 ` Zhao Liu
2024-12-09 12:36 ` [PATCH 05/26] rust: add bindings for interrupt sources Paolo Bonzini
2024-12-10 7:25 ` Zhao Liu
2024-12-09 12:36 ` [PATCH 06/26] rust: add a bit operation module Paolo Bonzini
2024-12-10 8:13 ` Zhao Liu
2024-12-10 9:30 ` Paolo Bonzini
2024-12-09 12:36 ` [PATCH 07/26] rust: qom: add default definitions for ObjectImpl Paolo Bonzini
2024-12-10 8:21 ` Zhao Liu
2024-12-09 12:36 ` [PATCH 08/26] rust: qom: rename Class trait to ClassInitImpl Paolo Bonzini
2024-12-10 8:24 ` Zhao Liu
2024-12-09 12:37 ` [PATCH 09/26] rust: qom: convert type_info! macro to an associated const Paolo Bonzini
2024-12-10 8:30 ` Zhao Liu
2024-12-09 12:37 ` [PATCH 10/26] rust: qom: move ClassInitImpl to the instance side Paolo Bonzini
2024-12-10 16:03 ` Zhao Liu
2024-12-09 12:37 ` [PATCH 11/26] rust: qdev: move device_class_init! body to generic function, ClassInitImpl implementation to macro Paolo Bonzini
2024-12-10 16:06 ` Zhao Liu
2024-12-09 12:37 ` [PATCH 12/26] rust: qdev: move bridge for realize and reset functions out of pl011 Paolo Bonzini
2024-12-10 16:07 ` Zhao Liu
2024-12-09 12:37 ` [PATCH 13/26] rust: qom: automatically use Drop trait to implement instance_finalize Paolo Bonzini
2024-12-10 16:16 ` Zhao Liu
2024-12-11 12:42 ` Paolo Bonzini
2024-12-11 15:37 ` Zhao Liu
2024-12-09 12:37 ` [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011 Paolo Bonzini
2024-12-10 15:50 ` Zhao Liu
2024-12-10 17:38 ` Paolo Bonzini
2024-12-11 7:59 ` Zhao Liu
2024-12-11 9:11 ` Paolo Bonzini
2024-12-11 16:56 ` Zhao Liu
2024-12-12 9:24 ` Paolo Bonzini
2024-12-13 8:53 ` Zhao Liu
2024-12-10 16:02 ` Zhao Liu
2024-12-09 12:37 ` [PATCH 15/26] rust: qom: split ObjectType from ObjectImpl trait Paolo Bonzini
2024-12-11 8:41 ` Zhao Liu
2024-12-09 12:37 ` [PATCH 16/26] rust: qom: change the parent type to an associated type Paolo Bonzini
2024-12-11 8:47 ` Zhao Liu
2024-12-09 12:37 ` [PATCH 17/26] rust: qom: put class_init together from multiple ClassInitImpl<> Paolo Bonzini
2024-12-12 9:15 ` Zhao Liu
2024-12-09 12:37 ` [PATCH 18/26] rust: qom: add possibility of overriding unparent Paolo Bonzini
2024-12-12 9:40 ` Zhao Liu
2024-12-12 11:15 ` Paolo Bonzini
2024-12-09 12:37 ` [PATCH 19/26] rust: rename qemu-api modules to follow C code a bit more Paolo Bonzini
2024-12-12 9:52 ` Zhao Liu
2024-12-12 11:28 ` Paolo Bonzini
2024-12-13 9:19 ` Zhao Liu
2024-12-13 11:24 ` Paolo Bonzini
2024-12-09 12:37 ` [PATCH 20/26] rust: re-export C types from qemu-api submodules Paolo Bonzini
2024-12-12 9:55 ` Zhao Liu
2024-12-09 12:37 ` [PATCH 21/26] rust: tests: allow writing more than one test Paolo Bonzini
2024-12-12 10:04 ` Zhao Liu
2024-12-16 15:07 ` Paolo Bonzini
2024-12-09 12:37 ` [PATCH 22/26] rust: qom: add casting functionality Paolo Bonzini
2024-12-16 12:53 ` Zhao Liu
2024-12-16 15:17 ` Paolo Bonzini
2024-12-09 12:37 ` [PATCH 23/26] rust: qom: add initial subset of methods on Object Paolo Bonzini
2024-12-16 15:18 ` Zhao Liu
2024-12-09 12:37 ` [PATCH 24/26] rust: qom: move device_id to PL011 class side Paolo Bonzini
2024-12-17 3:58 ` Zhao Liu
2024-12-17 16:50 ` Paolo Bonzini
2024-12-18 6:57 ` Zhao Liu
2024-12-18 7:14 ` Paolo Bonzini
2024-12-18 10:26 ` Paolo Bonzini
2024-12-18 14:46 ` Zhao Liu
2024-12-18 16:01 ` Paolo Bonzini
2024-12-18 14:30 ` Zhao Liu
2024-12-18 14:47 ` Zhao Liu
2024-12-09 12:37 ` [PATCH 25/26] rust: qemu-api: add a module to wrap functions and zero-sized closures Paolo Bonzini
2024-12-17 15:03 ` Zhao Liu
2024-12-09 12:37 ` [PATCH 26/26] rust: callbacks: allow passing optional callbacks as () Paolo Bonzini
2024-12-17 16:13 ` Zhao Liu
2024-12-17 16:40 ` Paolo Bonzini
2024-12-18 7:09 ` Zhao Liu
2024-12-18 7:32 ` Paolo Bonzini
2024-12-18 15:09 ` Zhao Liu [this message]
2024-12-09 16:24 ` [PATCH 00/26] rust: bundle of prerequisites for HPET implementation Philippe Mathieu-Daudé
2024-12-09 17:23 ` Paolo Bonzini
2024-12-10 2:38 ` Zhao Liu
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=Z2Llw0dHB6SpGMwr@intel.com \
--to=zhao1.liu@intel.com \
--cc=junjie.mao@hotmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.