[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [RFC PATCH 38/41] nbd/server: Use real permissions for NBD
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [RFC PATCH 38/41] nbd/server: Use real permissions for NBD exports |
Date: |
Mon, 13 Feb 2017 18:23:00 +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>
---
nbd/server.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/nbd/server.c b/nbd/server.c
index deb4358..4bb37d6 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -889,10 +889,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] [RFC PATCH 24/41] block: Add BdrvChildRole.stay_at_node, (continued)
- [Qemu-block] [RFC PATCH 24/41] block: Add BdrvChildRole.stay_at_node, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 25/41] blockjob: Add permissions to block_job_add_bdrv(), Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 27/41] block: Add bdrv_new_open_driver(), Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 28/41] commit: Use real permissions in commit block job, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 29/41] commit: Use real permissions for HMP 'commit', Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 30/41] backup: Use real permissions in backup block job, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 33/41] block: Allow backing file links in change_parent_backing_link(), Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 36/41] hmp: Request permissions in qemu-io, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 38/41] nbd/server: Use real permissions for NBD exports,
Kevin Wolf <=
- [Qemu-block] [RFC PATCH 26/41] block: Factor out bdrv_open_driver(), Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 31/41] block: Fix pending requests check in bdrv_append(), Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 32/41] block: BdrvChildRole.attach/detach() callbacks, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 35/41] stream: Use real permissions in streaming block job, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 34/41] mirror: Use real permissions in mirror/active commit block job, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 37/41] migration/block: Use real permissions, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 39/41] tests: Remove FIXME comments, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 40/41] block: Pass BdrvChild to bdrv_aligned_preadv/pwritev, Kevin Wolf, 2017/02/13
- [Qemu-block] [RFC PATCH 41/41] block: Assertions for write permissions, Kevin Wolf, 2017/02/13
- Re: [Qemu-block] [Qemu-devel] [RFC PATCH 00/41] New op blocker system, no-reply, 2017/02/13