[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 18/46] block: Request real permissions in blk_new_ope
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 18/46] block: Request real permissions in blk_new_open() |
Date: |
Tue, 28 Feb 2017 21:36:17 +0100 |
We can figure out the necessary permissions from the flags that the
caller passed.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Acked-by: Fam Zheng <address@hidden>
---
block/block-backend.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index 299948f..03d5495 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -166,17 +166,33 @@ BlockBackend *blk_new_open(const char *filename, const
char *reference,
{
BlockBackend *blk;
BlockDriverState *bs;
+ uint64_t perm;
+
+ /* blk_new_open() is mainly used in .bdrv_create implementations and the
+ * tools where sharing isn't a concern because the BDS stays private, so we
+ * just request permission according to the flags.
+ *
+ * The exceptions are xen_disk and blockdev_init(); in these cases, the
+ * caller of blk_new_open() doesn't make use of the permissions, but they
+ * shouldn't hurt either. We can still share everything here because the
+ * guest devices will add their own blockers if they can't share. */
+ perm = BLK_PERM_CONSISTENT_READ;
+ if (flags & BDRV_O_RDWR) {
+ perm |= BLK_PERM_WRITE;
+ }
+ if (flags & BDRV_O_RESIZE) {
+ perm |= BLK_PERM_RESIZE;
+ }
- blk = blk_new(0, BLK_PERM_ALL);
+ blk = blk_new(perm, BLK_PERM_ALL);
bs = bdrv_open(filename, reference, options, flags, errp);
if (!bs) {
blk_unref(blk);
return NULL;
}
- /* FIXME Use real permissions */
blk->root = bdrv_root_attach_child(bs, "root", &child_root,
- 0, BLK_PERM_ALL, blk, &error_abort);
+ perm, BLK_PERM_ALL, blk, &error_abort);
return blk;
}
--
1.8.3.1
- [Qemu-devel] [PULL 07/46] block: Default .bdrv_child_perm() for filter drivers, (continued)
- [Qemu-devel] [PULL 07/46] block: Default .bdrv_child_perm() for filter drivers, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 06/46] block: Involve block drivers in permission granting, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 08/46] block: Request child permissions in filter drivers, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 09/46] block: Default .bdrv_child_perm() for format drivers, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 10/46] block: Request child permissions in format drivers, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 11/46] vvfat: Implement .bdrv_child_perm(), Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 12/46] block: Require .bdrv_child_perm() with child nodes, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 13/46] block: Request real permissions in bdrv_attach_child(), Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 14/46] block: Add permissions to BlockBackend, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 15/46] block: Add permissions to blk_new(), Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 18/46] block: Request real permissions in blk_new_open(),
Kevin Wolf <=
- [Qemu-devel] [PULL 19/46] block: Allow error return in BlockDevOps.change_media_cb(), Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 17/46] block: Add BDRV_O_RESIZE for blk_new_open(), Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 16/46] block: Add error parameter to blk_insert_bs(), Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 20/46] hw/block: Request permissions, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 21/46] hw/block: Introduce share-rw qdev property, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 22/46] blockjob: Add permissions to block_job_create(), Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 23/46] block: Add BdrvChildRole.get_parent_desc(), Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 28/46] commit: Use real permissions for HMP 'commit', Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 25/46] block: Add BdrvChildRole.stay_at_node, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 29/46] backup: Use real permissions in backup block job, Kevin Wolf, 2017/02/28