Message ID | 20220504074051.90-3-xieyongji@bytedance.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Support exporting BDSs via VDUSE | expand |
On Wed, May 04, 2022 at 03:40:45PM +0800, Xie Yongji wrote: > Support getting the guest block size for the block backend. > It's needed for the following commit. > > Signed-off-by: Xie Yongji <xieyongji@bytedance.com> > --- > block/block-backend.c | 6 ++++++ > include/sysemu/block-backend-io.h | 1 + > 2 files changed, 7 insertions(+) > > diff --git a/block/block-backend.c b/block/block-backend.c > index 35457a6a1d..1582ff81c9 100644 > --- a/block/block-backend.c > +++ b/block/block-backend.c > @@ -2106,6 +2106,12 @@ void blk_set_guest_block_size(BlockBackend *blk, int align) > blk->guest_block_size = align; > } > > +int blk_get_guest_block_size(BlockBackend *blk) > +{ > + IO_CODE(); > + return blk->guest_block_size; I have sent a patch to remove blk->guest_block_size because this field is currently unused. I think there is a cleaner way for this patch series to store the guest logical_block_size (see next patch). Stashing it in BlockBackend was attractive because virtio-blk-handler.c lacks a struct to store its parameters (writable, serial, logical_block_size), but if such a struct is introduced then there's no need to stash it in BlockBackend. Stefan
On Wed, May 18, 2022 at 9:17 PM Stefan Hajnoczi <stefanha@redhat.com> wrote: > > On Wed, May 04, 2022 at 03:40:45PM +0800, Xie Yongji wrote: > > Support getting the guest block size for the block backend. > > It's needed for the following commit. > > > > Signed-off-by: Xie Yongji <xieyongji@bytedance.com> > > --- > > block/block-backend.c | 6 ++++++ > > include/sysemu/block-backend-io.h | 1 + > > 2 files changed, 7 insertions(+) > > > > diff --git a/block/block-backend.c b/block/block-backend.c > > index 35457a6a1d..1582ff81c9 100644 > > --- a/block/block-backend.c > > +++ b/block/block-backend.c > > @@ -2106,6 +2106,12 @@ void blk_set_guest_block_size(BlockBackend *blk, int align) > > blk->guest_block_size = align; > > } > > > > +int blk_get_guest_block_size(BlockBackend *blk) > > +{ > > + IO_CODE(); > > + return blk->guest_block_size; > > I have sent a patch to remove blk->guest_block_size because this field > is currently unused. > OK. > I think there is a cleaner way for this patch series to store the guest > logical_block_size (see next patch). Stashing it in BlockBackend was > attractive because virtio-blk-handler.c lacks a struct to store its > parameters (writable, serial, logical_block_size), but if such a struct > is introduced then there's no need to stash it in BlockBackend. > Looks good to me. Thanks, Yongji
diff --git a/block/block-backend.c b/block/block-backend.c index 35457a6a1d..1582ff81c9 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2106,6 +2106,12 @@ void blk_set_guest_block_size(BlockBackend *blk, int align) blk->guest_block_size = align; } +int blk_get_guest_block_size(BlockBackend *blk) +{ + IO_CODE(); + return blk->guest_block_size; +} + void *blk_try_blockalign(BlockBackend *blk, size_t size) { IO_CODE(); diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backend-io.h index 6517c39295..7600822196 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -73,6 +73,7 @@ void blk_iostatus_set_err(BlockBackend *blk, int error); int blk_get_max_iov(BlockBackend *blk); int blk_get_max_hw_iov(BlockBackend *blk); void blk_set_guest_block_size(BlockBackend *blk, int align); +int blk_get_guest_block_size(BlockBackend *blk); void blk_io_plug(BlockBackend *blk); void blk_io_unplug(BlockBackend *blk);
Support getting the guest block size for the block backend. It's needed for the following commit. Signed-off-by: Xie Yongji <xieyongji@bytedance.com> --- block/block-backend.c | 6 ++++++ include/sysemu/block-backend-io.h | 1 + 2 files changed, 7 insertions(+)