]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: Add bdrv_get_request_alignment()
authorEric Blake <eblake@redhat.com>
Fri, 29 Mar 2019 04:27:49 +0000 (23:27 -0500)
committerEric Blake <eblake@redhat.com>
Mon, 1 Apr 2019 13:46:52 +0000 (08:46 -0500)
The next patch needs access to a device's minimum permitted
alignment, since NBD wants to advertise this to clients. Add
an accessor function, borrowing from blk_get_max_transfer()
for accessing a backend's block limits.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20190329042750.14704-6-eblake@redhat.com>

block/block-backend.c
include/sysemu/block-backend.h

index edad02a0f2a3a0b18bbe174fc7f8ec33aa7ed988..f78e82a707fdc032485ad7d36ec23ddd72d2e076 100644 (file)
@@ -1764,6 +1764,13 @@ int blk_get_flags(BlockBackend *blk)
     }
 }
 
+/* Returns the minimum request alignment, in bytes; guaranteed nonzero */
+uint32_t blk_get_request_alignment(BlockBackend *blk)
+{
+    BlockDriverState *bs = blk_bs(blk);
+    return bs ? bs->bl.request_alignment : BDRV_SECTOR_SIZE;
+}
+
 /* Returns the maximum transfer length, in bytes; guaranteed nonzero */
 uint32_t blk_get_max_transfer(BlockBackend *blk)
 {
index e2066eb06b2e2bea3ac72bc24bc782b9e4ccb147..3be05c2d689cd7ae5142a04a1524f207dea624ca 100644 (file)
@@ -177,6 +177,7 @@ bool blk_is_available(BlockBackend *blk);
 void blk_lock_medium(BlockBackend *blk, bool locked);
 void blk_eject(BlockBackend *blk, bool eject_flag);
 int blk_get_flags(BlockBackend *blk);
+uint32_t blk_get_request_alignment(BlockBackend *blk);
 uint32_t blk_get_max_transfer(BlockBackend *blk);
 int blk_get_max_iov(BlockBackend *blk);
 void blk_set_guest_block_size(BlockBackend *blk, int align);