[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 08/11] rust/block: Add driver module
From: |
Kevin Wolf |
Subject: |
Re: [PATCH 08/11] rust/block: Add driver module |
Date: |
Wed, 12 Feb 2025 18:32:29 +0100 |
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<T: IoBuffer + ?Sized>(&self, offset: u64, buf: &mut
> > T) -> io::Result<()> {
> > + unsafe {
> > + self.read_raw(offset, buf.buffer_len(), buf.buffer_mut_ptr())
> > + .await
> > + }
> > + }
> > +
> > + /// Reads data from the child node into a linear, potentially
> > uninitialised typed buffer.
> > + pub async fn read_uninit<T: SizedIoBuffer>(
> > + &self,
> > + offset: u64,
> > + mut buf: MaybeUninit<T>,
>
> 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?
Or is this more of a theoretical concern?
> pub async fn read_uninit<T: SizedIoBuffer>(
> &self,
> offset: u64,
> buf: &mut MaybeUninit<T>,
> ) -> io::Result<&mut T>
>
> using assume_init_mut().
Are you sure that callers are ok with only getting a &mut T rather than
an owned T?
Kevin
[PATCH 08/11] rust/block: Add driver module, Kevin Wolf, 2025/02/11
[PATCH 10/11] bochs-rs: Add bochs block driver reimplementation in Rust, Kevin Wolf, 2025/02/11
Re: [PATCH 10/11] bochs-rs: Add bochs block driver reimplementation in Rust, Daniel P . Berrangé, 2025/02/12
[PATCH 07/11] block: Add bdrv_open_blockdev_ref_file(), Kevin Wolf, 2025/02/11