yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
4ec855
From f551451a4b9975121424cb0837df67d31d2528dc Mon Sep 17 00:00:00 2001
4ec855
From: Max Reitz <mreitz@redhat.com>
4ec855
Date: Tue, 23 Jul 2019 14:45:45 +0100
4ec855
Subject: [PATCH 07/14] block: Add bdrv_get_request_alignment()
4ec855
4ec855
RH-Author: Max Reitz <mreitz@redhat.com>
4ec855
Message-id: <20190723144546.23701-7-mreitz@redhat.com>
4ec855
Patchwork-id: 89653
4ec855
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 6/7] block: Add bdrv_get_request_alignment()
4ec855
Bugzilla: 1678979
4ec855
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
4ec855
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
4ec855
RH-Acked-by: John Snow <jsnow@redhat.com>
4ec855
4ec855
From: Eric Blake <eblake@redhat.com>
4ec855
4ec855
The next patch needs access to a device's minimum permitted
4ec855
alignment, since NBD wants to advertise this to clients. Add
4ec855
an accessor function, borrowing from blk_get_max_transfer()
4ec855
for accessing a backend's block limits.
4ec855
4ec855
Signed-off-by: Eric Blake <eblake@redhat.com>
4ec855
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
4ec855
Message-Id: <20190329042750.14704-6-eblake@redhat.com>
4ec855
(cherry picked from commit 4841211e0d1628cd386b35835676d7f6f9a4fa9d)
4ec855
Signed-off-by: Max Reitz <mreitz@redhat.com>
4ec855
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
4ec855
---
4ec855
 block/block-backend.c          | 7 +++++++
4ec855
 include/sysemu/block-backend.h | 1 +
4ec855
 2 files changed, 8 insertions(+)
4ec855
4ec855
diff --git a/block/block-backend.c b/block/block-backend.c
4ec855
index 7ae5832..0d623e4 100644
4ec855
--- a/block/block-backend.c
4ec855
+++ b/block/block-backend.c
4ec855
@@ -1807,6 +1807,13 @@ int blk_get_flags(BlockBackend *blk)
4ec855
     }
4ec855
 }
4ec855
 
4ec855
+/* Returns the minimum request alignment, in bytes; guaranteed nonzero */
4ec855
+uint32_t blk_get_request_alignment(BlockBackend *blk)
4ec855
+{
4ec855
+    BlockDriverState *bs = blk_bs(blk);
4ec855
+    return bs ? bs->bl.request_alignment : BDRV_SECTOR_SIZE;
4ec855
+}
4ec855
+
4ec855
 /* Returns the maximum transfer length, in bytes; guaranteed nonzero */
4ec855
 uint32_t blk_get_max_transfer(BlockBackend *blk)
4ec855
 {
4ec855
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
4ec855
index 830d873..20f8bbb 100644
4ec855
--- a/include/sysemu/block-backend.h
4ec855
+++ b/include/sysemu/block-backend.h
4ec855
@@ -176,6 +176,7 @@ bool blk_is_available(BlockBackend *blk);
4ec855
 void blk_lock_medium(BlockBackend *blk, bool locked);
4ec855
 void blk_eject(BlockBackend *blk, bool eject_flag);
4ec855
 int blk_get_flags(BlockBackend *blk);
4ec855
+uint32_t blk_get_request_alignment(BlockBackend *blk);
4ec855
 uint32_t blk_get_max_transfer(BlockBackend *blk);
4ec855
 int blk_get_max_iov(BlockBackend *blk);
4ec855
 void blk_set_guest_block_size(BlockBackend *blk, int align);
4ec855
-- 
4ec855
1.8.3.1
4ec855