diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2023-04-07 17:33:01 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2023-04-11 16:40:54 +0200 |
commit | e5203a3b5db1fb1328f104a4863284198b551ce0 (patch) | |
tree | bab35261ea24e9f8d0cddc340b875ffbaac39bc9 /block | |
parent | 2c5451ca523fc2b757e1e5b4e0b9fc84dbd58f97 (diff) | |
download | qemu-e5203a3b5db1fb1328f104a4863284198b551ce0.zip qemu-e5203a3b5db1fb1328f104a4863284198b551ce0.tar.gz qemu-e5203a3b5db1fb1328f104a4863284198b551ce0.tar.bz2 |
block-backend: inline bdrv_co_get_geometry
bdrv_co_get_geometry is only used in blk_co_get_geometry. Inline it in
there, to reduce the number of wrappers for bs->total_sectors.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20230407153303.391121-7-pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/block-backend.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/block/block-backend.c b/block/block-backend.c index 2ee3922..36e3a67 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1615,16 +1615,20 @@ int64_t coroutine_fn blk_co_getlength(BlockBackend *blk) return bdrv_co_getlength(blk_bs(blk)); } +/* return 0 as number of sectors if no device present or error */ void coroutine_fn blk_co_get_geometry(BlockBackend *blk, uint64_t *nb_sectors_ptr) { + BlockDriverState *bs = blk_bs(blk); + IO_CODE(); GRAPH_RDLOCK_GUARD(); - if (!blk_bs(blk)) { + if (!bs) { *nb_sectors_ptr = 0; } else { - bdrv_co_get_geometry(blk_bs(blk), nb_sectors_ptr); + int64_t nb_sectors = bdrv_co_nb_sectors(bs); + *nb_sectors_ptr = nb_sectors < 0 ? 0 : nb_sectors; } } |