[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 41/43] block: Assertions for resize permission
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH v2 41/43] block: Assertions for resize permission |
Date: |
Mon, 27 Feb 2017 21:09:42 +0100 |
This adds an assertion that ensures that the necessary resize permission
has been granted before bdrv_truncate() is called.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block.c | 3 +++
block/io.c | 1 +
2 files changed, 4 insertions(+)
diff --git a/block.c b/block.c
index af2b8ff..5118828 100644
--- a/block.c
+++ b/block.c
@@ -3110,6 +3110,9 @@ int bdrv_truncate(BdrvChild *child, int64_t offset)
BlockDriverState *bs = child->bs;
BlockDriver *drv = bs->drv;
int ret;
+
+ assert(child->perm & BLK_PERM_RESIZE);
+
if (!drv)
return -ENOMEDIUM;
if (!drv->bdrv_truncate)
diff --git a/block/io.c b/block/io.c
index 4c79745..8f38d46 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1339,6 +1339,7 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild
*child,
assert(req->overlap_offset <= offset);
assert(offset + bytes <= req->overlap_offset + req->overlap_bytes);
assert(child->perm & BLK_PERM_WRITE);
+ assert(end_sector <= bs->total_sectors || child->perm & BLK_PERM_RESIZE);
ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req);
--
1.8.3.1
- [Qemu-devel] [PATCH v2 31/43] mirror: Use real permissions in mirror/active commit block job, (continued)
- [Qemu-devel] [PATCH v2 31/43] mirror: Use real permissions in mirror/active commit block job, Kevin Wolf, 2017/02/27
- [Qemu-devel] [PATCH v2 32/43] stream: Use real permissions in streaming block job, Kevin Wolf, 2017/02/27
- [Qemu-devel] [PATCH v2 33/43] mirror: Add filter-node-name to blockdev-mirror, Kevin Wolf, 2017/02/27
- [Qemu-devel] [PATCH v2 34/43] commit: Add filter-node-name to block-commit, Kevin Wolf, 2017/02/27
- [Qemu-devel] [PATCH v2 35/43] hmp: Request permissions in qemu-io, Kevin Wolf, 2017/02/27
- [Qemu-devel] [PATCH v2 36/43] migration/block: Use real permissions, Kevin Wolf, 2017/02/27
- [Qemu-devel] [PATCH v2 37/43] nbd/server: Use real permissions for NBD exports, Kevin Wolf, 2017/02/27
- [Qemu-devel] [PATCH v2 38/43] tests: Remove FIXME comments, Kevin Wolf, 2017/02/27
- [Qemu-devel] [PATCH v2 39/43] block: Pass BdrvChild to bdrv_aligned_preadv/pwritev and copy-on-read, Kevin Wolf, 2017/02/27
- [Qemu-devel] [PATCH v2 40/43] block: Assertions for write permissions, Kevin Wolf, 2017/02/27
- [Qemu-devel] [PATCH v2 41/43] block: Assertions for resize permission,
Kevin Wolf <=
- [Qemu-devel] [PATCH v2 42/43] block: Add Error parameter to bdrv_set_backing_hd(), Kevin Wolf, 2017/02/27
- [Qemu-devel] [PATCH v2 43/43] block: Add Error parameter to bdrv_append(), Kevin Wolf, 2017/02/27