Re: [PATCH 02/10] rust: qom: add reference counting functionality

2025-02-05 Thread Zhao Liu
On Fri, Jan 17, 2025 at 08:39:55PM +0100, Paolo Bonzini wrote: > Date: Fri, 17 Jan 2025 20:39:55 +0100 > From: Paolo Bonzini > Subject: [PATCH 02/10] rust: qom: add reference counting functionality > X-Mailer: git-send-email 2.47.1 > > Add a smart pointer that allows to add and

Re: [PATCH 02/10] rust: qom: add reference counting functionality

2025-02-05 Thread Zhao Liu
On Wed, Feb 05, 2025 at 10:10:01AM +0100, Paolo Bonzini wrote: > Date: Wed, 5 Feb 2025 10:10:01 +0100 > From: Paolo Bonzini > Subject: Re: [PATCH 02/10] rust: qom: add reference counting functionality > > On 2/5/25 10:13, Zhao Liu wrote: > >

Re: [PATCH 02/10] rust: qom: add reference counting functionality

2025-02-05 Thread Paolo Bonzini
On 2/5/25 10:13, Zhao Liu wrote: * The use of from(): let clk = bindings::qdev_init_clock_in(...) Owned::from(&*clk) In this case the C side wants to manage the reference that qdev_init_clock_in() returns; it is dropped in qdev_finalize_clocklist(). So Rust co

Re: [PATCH 02/10] rust: qom: add reference counting functionality

2025-02-05 Thread Zhao Liu
> > * The use of from(): > > > > let clk = bindings::qdev_init_clock_in(...) > > Owned::from(&*clk) > > In this case the C side wants to manage the reference that > qdev_init_clock_in() returns; it is dropped in > qdev_finalize_clocklist(). So Rust code needs to inc

Re: [PATCH 02/10] rust: qom: add reference counting functionality

2025-02-05 Thread Zhao Liu
On Wed, Jan 29, 2025 at 11:03:31AM +0100, Paolo Bonzini wrote: > Date: Wed, 29 Jan 2025 11:03:31 +0100 > From: Paolo Bonzini > Subject: Re: [PATCH 02/10] rust: qom: add reference counting functionality > > On Sun, Jan 26, 2025 at 3:56 PM Zhao Liu wrote: > > > > Hi Pa

Re: [PATCH 02/10] rust: qom: add reference counting functionality

2025-01-29 Thread Paolo Bonzini
On Mon, Jan 27, 2025 at 8:38 AM Zhao Liu wrote: > > > +impl Owned { > > +/// Convert a raw C pointer into an owned reference to the QOM > > +/// object it points to. The object's reference count will be > > +/// decreased when the `Owned` is dropped. > > +/// > > +/// # Panics

Re: [PATCH 02/10] rust: qom: add reference counting functionality

2025-01-29 Thread Paolo Bonzini
On Sun, Jan 26, 2025 at 3:56 PM Zhao Liu wrote: > > Hi Paolo, > > On Fri, Jan 17, 2025 at 08:39:55PM +0100, Paolo Bonzini wrote: > > Date: Fri, 17 Jan 2025 20:39:55 +0100 > > From: Paolo Bonzini > > Subject: [PATCH 02/10] rust: qom: add reference counting functi

Re: [PATCH 02/10] rust: qom: add reference counting functionality

2025-01-26 Thread Zhao Liu
> +impl Owned { > +/// Convert a raw C pointer into an owned reference to the QOM > +/// object it points to. The object's reference count will be > +/// decreased when the `Owned` is dropped. > +/// > +/// # Panics > +/// > +/// Panics if `ptr` is NULL. > +/// > +

Re: [PATCH 02/10] rust: qom: add reference counting functionality

2025-01-26 Thread Zhao Liu
Hi Paolo, On Fri, Jan 17, 2025 at 08:39:55PM +0100, Paolo Bonzini wrote: > Date: Fri, 17 Jan 2025 20:39:55 +0100 > From: Paolo Bonzini > Subject: [PATCH 02/10] rust: qom: add reference counting functionality > X-Mailer: git-send-email 2.47.1 > > Add a smart pointer that allows

[PATCH 02/10] rust: qom: add reference counting functionality

2025-01-17 Thread Paolo Bonzini
Add a smart pointer that allows to add and remove references from QOM objects. It's important to note that while all QOM objects have a reference count, in practice not all of them have their lifetime guarded by it. Embedded objects, specifically, are confined to the lifetime of the owner. When