Re: [PATCH 10/11] bochs-rs: Add bochs block driver reimplementation in Rust

2025-02-12 Thread Daniel P . Berrangé
On Tue, Feb 11, 2025 at 10:43:27PM +0100, Kevin Wolf wrote: > This adds a separate block driver for the bochs image format called > 'bochs-rs' so that for the moment both the C implementation and the Rust > implementation can be present in the same build. The intention is to > remove the C implemen

Re: [PATCH 10/11] bochs-rs: Add bochs block driver reimplementation in Rust

2025-02-12 Thread Daniel P . Berrangé
On Wed, Feb 12, 2025 at 09:14:57AM +, Daniel P. Berrangé wrote: > On Tue, Feb 11, 2025 at 10:43:27PM +0100, Kevin Wolf wrote: > > This adds a separate block driver for the bochs image format called > > 'bochs-rs' so that for the moment both the C implementation and the Rust > > implementation c

[PATCH] block/rbd: Do not use BDS's AioContext

2025-02-12 Thread Hanna Czenczek
RBD schedules the request completion code (qemu_rbd_finish_bh()) to run in the BDS's AioContext. The intent seems to be to run it in the same context that the original request coroutine ran in, i.e. the thread on whose stack the RBDTask object exists (see qemu_rbd_start_co()). However, with multi

Re: [PATCH 04/11] rust/qemu-api: Add wrappers to run futures in QEMU

2025-02-12 Thread Kevin Wolf
Am 12.02.2025 um 10:28 hat Paolo Bonzini geschrieben: > On 2/11/25 22:43, Kevin Wolf wrote: > > +/// Use QEMU's event loops to run a Rust [`Future`] to completion and > > return its result. > > +/// > > +/// This function must be called in coroutine context. If the future isn't > > ready yet, it

Re: [PATCH 10/11] bochs-rs: Add bochs block driver reimplementation in Rust

2025-02-12 Thread Kevin Wolf
Am 12.02.2025 um 10:41 hat Daniel P. Berrangé geschrieben: > On Wed, Feb 12, 2025 at 09:14:57AM +, Daniel P. Berrangé wrote: > > On Tue, Feb 11, 2025 at 10:43:27PM +0100, Kevin Wolf wrote: > > > This adds a separate block driver for the bochs image format called > > > 'bochs-rs' so that for the

Re: [PATCH 10/11] bochs-rs: Add bochs block driver reimplementation in Rust

2025-02-12 Thread Daniel P . Berrangé
On Wed, Feb 12, 2025 at 01:58:15PM +0100, Kevin Wolf wrote: > Am 12.02.2025 um 10:41 hat Daniel P. Berrangé geschrieben: > > On Wed, Feb 12, 2025 at 09:14:57AM +, Daniel P. Berrangé wrote: > > > On Tue, Feb 11, 2025 at 10:43:27PM +0100, Kevin Wolf wrote: > > > > This adds a separate block drive

Re: [PATCH 03/11] rust: Add some block layer bindings

2025-02-12 Thread Kevin Wolf
Am 12.02.2025 um 10:29 hat Paolo Bonzini geschrieben: > On 2/11/25 22:43, Kevin Wolf wrote: > > Signed-off-by: Kevin Wolf > > --- > > rust/wrapper.h| 4 > > meson.build | 1 + > > rust/qemu-api/src/zeroable.rs | 5 +++-- > > 3 files changed, 8 insertions

Re: [PATCH 04/11] rust/qemu-api: Add wrappers to run futures in QEMU

2025-02-12 Thread Paolo Bonzini
On Wed, Feb 12, 2025 at 1:47 PM Kevin Wolf wrote: > > > +pub fn qemu_co_run_future(future: F) -> F::Output { > > > +let waker = Arc::new(RunFutureWaker { > > > +co: unsafe { bindings::qemu_coroutine_self() }, > > > +}) > > > +.into(); > > > > into what? :) Maybe you can add th

Re: [PATCH 10/11] bochs-rs: Add bochs block driver reimplementation in Rust

2025-02-12 Thread Kevin Wolf
Am 12.02.2025 um 08:45 hat Philippe Mathieu-Daudé geschrieben: > On 11/2/25 22:43, Kevin Wolf wrote: > > This adds a separate block driver for the bochs image format called > > 'bochs-rs' so that for the moment both the C implementation and the Rust > > implementation can be present in the same bui

Re: [PATCH] block/rbd: Do not use BDS's AioContext

2025-02-12 Thread Kevin Wolf
Am 12.02.2025 um 10:32 hat Hanna Czenczek geschrieben: > RBD schedules the request completion code (qemu_rbd_finish_bh()) to run > in the BDS's AioContext. The intent seems to be to run it in the same > context that the original request coroutine ran in, i.e. the thread on > whose stack the RBDTas

Re: [PATCH 03/11] rust: Add some block layer bindings

2025-02-12 Thread Paolo Bonzini
On Wed, Feb 12, 2025 at 2:13 PM Kevin Wolf wrote: > Yes, we definitely need some proper bindings there. I'm already tired of > writing things like this: > > return -(bindings::EINVAL as std::os::raw::c_int) > > Or even: > > return e > .raw_os_error() > .unwrap_or(-(bindings

Re: [PATCH 10/11] bochs-rs: Add bochs block driver reimplementation in Rust

2025-02-12 Thread Philippe Mathieu-Daudé
On 12/2/25 13:59, Kevin Wolf wrote: Am 12.02.2025 um 08:45 hat Philippe Mathieu-Daudé geschrieben: On 11/2/25 22:43, Kevin Wolf wrote: This adds a separate block driver for the bochs image format called 'bochs-rs' so that for the moment both the C implementation and the Rust implementation can

Re: [PATCH] block/rbd: Do not use BDS's AioContext

2025-02-12 Thread Hanna Czenczek
On 12.02.25 14:26, Kevin Wolf wrote: Am 12.02.2025 um 10:32 hat Hanna Czenczek geschrieben: RBD schedules the request completion code (qemu_rbd_finish_bh()) to run in the BDS's AioContext. The intent seems to be to run it in the same context that the original request coroutine ran in, i.e. the

[PATCH] qapi: merge common parts of NbdServerOptions and nbd-server-start data

2025-02-12 Thread Vladimir Sementsov-Ogievskiy
Instead of comment "Keep this type consistent with the nbd-server-start arguments", we can simply merge these things. Signed-off-by: Vladimir Sementsov-Ogievskiy --- No problem for me to rebase on top of [PATCH 0/2] nbd: Allow debugging tuning of handshake limit if it goes earlier. Also, not th

Re: [PATCH 2/2] nbd/server: Allow users to adjust handshake limit in QMP

2025-02-12 Thread Vladimir Sementsov-Ogievskiy
On 11.02.25 00:46, Eric Blake wrote: On Thu, Feb 06, 2025 at 10:20:09AM +0300, Vladimir Sementsov-Ogievskiy wrote: --- qapi/block-export.json | 10 ++ include/block/nbd.h| 6 +++--- [..] @@ -52,6 +57,10 @@ # # @addr: Address on which to listen. # +#

Re: [PATCH 01/11] rust: Build separate qemu_api_tools and qemu_api_system

2025-02-12 Thread Paolo Bonzini
On 2/11/25 22:43, Kevin Wolf wrote: The existing qemu_api library can't be linked into tools because it contains a few bindings for things that only exist in the system emulator. This adds a new "system" feature to the qemu_api crate that enables the system emulator parts in it, and build the cr

Re: [PATCH 03/11] rust: Add some block layer bindings

2025-02-12 Thread Paolo Bonzini
On 2/11/25 22:43, Kevin Wolf wrote: Signed-off-by: Kevin Wolf --- rust/wrapper.h| 4 meson.build | 1 + rust/qemu-api/src/zeroable.rs | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rust/wrapper.h b/rust/wrapper.h index 41be87

Re: [PATCH 04/11] rust/qemu-api: Add wrappers to run futures in QEMU

2025-02-12 Thread Paolo Bonzini
On 2/11/25 22:43, Kevin Wolf wrote: +/// Use QEMU's event loops to run a Rust [`Future`] to completion and return its result. +/// +/// This function must be called in coroutine context. If the future isn't ready yet, it yields. +pub fn qemu_co_run_future(future: F) -> F::Output { +let wake

Re: [PATCH 01/11] rust: Build separate qemu_api_tools and qemu_api_system

2025-02-12 Thread Kevin Wolf
Am 12.02.2025 um 11:01 hat Paolo Bonzini geschrieben: > On 2/11/25 22:43, Kevin Wolf wrote: > > The existing qemu_api library can't be linked into tools because it > > contains a few bindings for things that only exist in the system > > emulator. > > > > This adds a new "system" feature to the qem

Re: [PATCH 03/11] rust: Add some block layer bindings

2025-02-12 Thread Kevin Wolf
Am 12.02.2025 um 14:47 hat Paolo Bonzini geschrieben: > On Wed, Feb 12, 2025 at 2:13 PM Kevin Wolf wrote: > > Yes, we definitely need some proper bindings there. I'm already tired of > > writing things like this: > > > > return -(bindings::EINVAL as std::os::raw::c_int) > > > > Or even: > > >

Re: [PATCH 06/11] rust/block: Add I/O buffer traits

2025-02-12 Thread Paolo Bonzini
On 2/11/25 22:43, Kevin Wolf wrote: +/// Implementing `SizedIoBuffer` provides an implementation for [`IoBuffer`] without having to +/// implement any functions manually. +/// +/// # Safety +/// +/// Types implementing `SizedIoBuffer` guarantee that the whole object can be accessed as an I/O +/

Re: [PATCH 09/11] rust/block: Add read support for block drivers

2025-02-12 Thread Paolo Bonzini
On 2/11/25 22:43, Kevin Wolf wrote: +/// A request to a block driver +pub enum Request { +Read { offset: u64, len: u64 }, +} + Maybe add flags already? +#[allow(dead_code)] +pub enum MappingTarget { +/// The described blocks are unallocated. Reading from them yields zeros. +Unmappe

Re: [PATCH 01/11] rust: Build separate qemu_api_tools and qemu_api_system

2025-02-12 Thread Paolo Bonzini
On 2/12/25 16:29, Kevin Wolf wrote: Am 12.02.2025 um 11:01 hat Paolo Bonzini geschrieben: On 2/11/25 22:43, Kevin Wolf wrote: The existing qemu_api library can't be linked into tools because it contains a few bindings for things that only exist in the system emulator. This adds a new "system"

Re: [PATCH 06/11] rust/block: Add I/O buffer traits

2025-02-12 Thread Kevin Wolf
Am 12.02.2025 um 17:48 hat Paolo Bonzini geschrieben: > On 2/11/25 22:43, Kevin Wolf wrote: > > +/// Implementing `SizedIoBuffer` provides an implementation for > > [`IoBuffer`] without having to > > +/// implement any functions manually. > > +/// > > +/// # Safety > > +/// > > +/// Types implemen

Re: [PATCH 08/11] rust/block: Add driver module

2025-02-12 Thread Paolo Bonzini
Il mer 12 feb 2025, 18:32 Kevin Wolf ha scritto: > > > +mut buf: MaybeUninit, > > > > I think Rust doesn't guarantee no copies here, so maybe this could be > > Do you think that in practice the compiler won't optimise the copy away? > It's possiblr that it does not, because it has to bui

Re: [PATCH 03/11] rust: Add some block layer bindings

2025-02-12 Thread Paolo Bonzini
On 2/12/25 16:13, Kevin Wolf wrote: Or if you have to define the constants anyway - you currently do this only for Windows, but for into_negative_errno() you might need it on Linux, too - and it wouldn't be a problem for the constants to be signed (that they are unsigned is the main reason why it

Re: [PATCH 03/11] rust: Add some block layer bindings

2025-02-12 Thread Kevin Wolf
Am 12.02.2025 um 18:16 hat Paolo Bonzini geschrieben: > On 2/12/25 16:13, Kevin Wolf wrote: > > Or if you have to define the constants anyway - you currently do this > > only for Windows, but for into_negative_errno() you might need it on > > Linux, too - and it wouldn't be a problem for the consta

Re: [PATCH 09/11] rust/block: Add read support for block drivers

2025-02-12 Thread Kevin Wolf
Am 12.02.2025 um 16:05 hat Paolo Bonzini geschrieben: > On 2/11/25 22:43, Kevin Wolf wrote: > > +/// A request to a block driver > > +pub enum Request { > > +Read { offset: u64, len: u64 }, > > +} > > + > > Maybe add flags already? > > +#[allow(dead_code)] > > +pub enum MappingTarget { > > +

Re: [PATCH 08/11] rust/block: Add driver module

2025-02-12 Thread Kevin Wolf
Am 12.02.2025 um 17:43 hat Paolo Bonzini geschrieben: > On 2/11/25 22:43, Kevin Wolf wrote: > > +/// Reads data from the child node into a linear typed buffer. > > +pub async fn read(&self, offset: u64, buf: &mut > > T) -> io::Result<()> { > > +unsafe { > > +self.read_r

Re: [PATCH 08/11] rust/block: Add driver module

2025-02-12 Thread Paolo Bonzini
On 2/11/25 22:43, Kevin Wolf wrote: +/// Reads data from the child node into a linear typed buffer. +pub async fn read(&self, offset: u64, buf: &mut T) -> io::Result<()> { +unsafe { +self.read_raw(offset, buf.buffer_len(), buf.buffer_mut_ptr()) +.await

Re: [PATCH 06/11] rust/block: Add I/O buffer traits

2025-02-12 Thread Paolo Bonzini
Il mer 12 feb 2025, 18:23 Kevin Wolf ha scritto: > Am 12.02.2025 um 17:48 hat Paolo Bonzini geschrieben: > > On 2/11/25 22:43, Kevin Wolf wrote: > > > +/// Implementing `SizedIoBuffer` provides an implementation for > [`IoBuffer`] without having to > > > +/// implement any functions manually. > >

Re: [PATCH] qapi: merge common parts of NbdServerOptions and nbd-server-start data

2025-02-12 Thread Eric Blake
On Wed, Feb 12, 2025 at 05:33:51PM +0300, Vladimir Sementsov-Ogievskiy wrote: > Instead of comment > "Keep this type consistent with the nbd-server-start arguments", we > can simply merge these things. > > Signed-off-by: Vladimir Sementsov-Ogievskiy > --- > > No problem for me to rebase on top o