[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 37/43] nbd/server: Use real permissions for NBD e
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PATCH v2 37/43] nbd/server: Use real permissions for NBD exports |
Date: |
Mon, 27 Feb 2017 21:09:38 +0100 |
NBD can't cope with device size changes, so resize must be forbidden,
but otherwise we can tolerate anything. Depending on whether the export
is writable or not, we only require consistent reads and writes.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
nbd/server.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/nbd/server.c b/nbd/server.c
index 89362ba..924a1fe 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -891,10 +891,17 @@ NBDExport *nbd_export_new(BlockDriverState *bs, off_t
dev_offset, off_t size,
{
BlockBackend *blk;
NBDExport *exp = g_malloc0(sizeof(NBDExport));
+ uint64_t perm;
int ret;
- /* FIXME Use real permissions */
- blk = blk_new(0, BLK_PERM_ALL);
+ /* Don't allow resize while the NBD server is running, otherwise we don't
+ * care what happens with the node. */
+ perm = BLK_PERM_CONSISTENT_READ;
+ if ((nbdflags & NBD_FLAG_READ_ONLY) == 0) {
+ perm |= BLK_PERM_WRITE;
+ }
+ blk = blk_new(perm, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED |
+ BLK_PERM_WRITE | BLK_PERM_GRAPH_MOD);
ret = blk_insert_bs(blk, bs, errp);
if (ret < 0) {
goto fail;
--
1.8.3.1
- [Qemu-block] [PATCH v2 27/43] backup: Use real permissions in backup block job, (continued)
- [Qemu-block] [PATCH v2 27/43] backup: Use real permissions in backup block job, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 28/43] block: Fix pending requests check in bdrv_append(), Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 29/43] block: BdrvChildRole.attach/detach() callbacks, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 30/43] block: Allow backing file links in change_parent_backing_link(), Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 32/43] stream: Use real permissions in streaming block job, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 31/43] mirror: Use real permissions in mirror/active commit block job, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 33/43] mirror: Add filter-node-name to blockdev-mirror, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 34/43] commit: Add filter-node-name to block-commit, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 35/43] hmp: Request permissions in qemu-io, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 36/43] migration/block: Use real permissions, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 37/43] nbd/server: Use real permissions for NBD exports,
Kevin Wolf <=
- [Qemu-block] [PATCH v2 38/43] tests: Remove FIXME comments, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 39/43] block: Pass BdrvChild to bdrv_aligned_preadv/pwritev and copy-on-read, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 40/43] block: Assertions for write permissions, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 41/43] block: Assertions for resize permission, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 42/43] block: Add Error parameter to bdrv_set_backing_hd(), Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 43/43] block: Add Error parameter to bdrv_append(), Kevin Wolf, 2017/02/27