[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 09/43] vvfat: Implement .bdrv_child_perm()
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PATCH v2 09/43] vvfat: Implement .bdrv_child_perm() |
Date: |
Mon, 27 Feb 2017 21:09:10 +0100 |
vvfat is the last remaining driver that can have children, but doesn't
implement .bdrv_child_perm() yet. The default handlers aren't suitable
here, so let's implement a very simple driver-specific one that protects
the internal child from being used by other users as good as our
permissions permit.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block.c | 2 +-
block/vvfat.c | 22 ++++++++++++++++++++++
include/block/block_int.h | 1 +
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index 20dd1c5..7ae8264 100644
--- a/block.c
+++ b/block.c
@@ -823,7 +823,7 @@ static void bdrv_backing_options(int *child_flags, QDict
*child_options,
*child_flags = flags;
}
-static const BdrvChildRole child_backing = {
+const BdrvChildRole child_backing = {
.inherit_options = bdrv_backing_options,
.drained_begin = bdrv_child_cb_drained_begin,
.drained_end = bdrv_child_cb_drained_end,
diff --git a/block/vvfat.c b/block/vvfat.c
index 7f230be..72b482c 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -3052,6 +3052,27 @@ err:
return ret;
}
+static void vvfat_child_perm(BlockDriverState *bs, BdrvChild *c,
+ const BdrvChildRole *role,
+ uint64_t perm, uint64_t shared,
+ uint64_t *nperm, uint64_t *nshared)
+{
+ BDRVVVFATState *s = bs->opaque;
+
+ assert(c == s->qcow || role == &child_backing);
+
+ if (c == s->qcow) {
+ /* This is a private node, nobody should try to attach to it */
+ *nperm = BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE;
+ *nshared = BLK_PERM_WRITE_UNCHANGED;
+ } else {
+ /* The backing file is there so 'commit' can use it. vvfat doesn't
+ * access it in any way. */
+ *nperm = 0;
+ *nshared = BLK_PERM_ALL;
+ }
+}
+
static void vvfat_close(BlockDriverState *bs)
{
BDRVVVFATState *s = bs->opaque;
@@ -3077,6 +3098,7 @@ static BlockDriver bdrv_vvfat = {
.bdrv_file_open = vvfat_open,
.bdrv_refresh_limits = vvfat_refresh_limits,
.bdrv_close = vvfat_close,
+ .bdrv_child_perm = vvfat_child_perm,
.bdrv_co_preadv = vvfat_co_preadv,
.bdrv_co_pwritev = vvfat_co_pwritev,
diff --git a/include/block/block_int.h b/include/block/block_int.h
index eb0598e..63d5446 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -466,6 +466,7 @@ struct BdrvChildRole {
extern const BdrvChildRole child_file;
extern const BdrvChildRole child_format;
+extern const BdrvChildRole child_backing;
struct BdrvChild {
BlockDriverState *bs;
--
1.8.3.1
- [Qemu-block] [PATCH v2 00/43] New op blocker system, part 1, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 01/43] block: Add op blocker permission constants, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 02/43] block: Add Error argument to bdrv_attach_child(), Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 03/43] block: Let callers request permissions when attaching a child node, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 04/43] block: Involve block drivers in permission granting, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 05/43] block: Default .bdrv_child_perm() for filter drivers, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 06/43] block: Request child permissions in filter drivers, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 07/43] block: Default .bdrv_child_perm() for format drivers, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 08/43] block: Request child permissions in format drivers, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 09/43] vvfat: Implement .bdrv_child_perm(),
Kevin Wolf <=
- [Qemu-block] [PATCH v2 10/43] block: Require .bdrv_child_perm() with child nodes, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 11/43] block: Request real permissions in bdrv_attach_child(), Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 12/43] block: Add permissions to BlockBackend, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 13/43] block: Add permissions to blk_new(), Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 14/43] block: Add error parameter to blk_insert_bs(), Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 15/43] block: Add BDRV_O_RESIZE for blk_new_open(), Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 16/43] block: Request real permissions in blk_new_open(), Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 17/43] block: Allow error return in BlockDevOps.change_media_cb(), Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 18/43] hw/block: Request permissions, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 19/43] hw/block: Introduce share-rw qdev property, Kevin Wolf, 2017/02/27