[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 20/43] blockjob: Add permissions to block_job_cre
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PATCH v2 20/43] blockjob: Add permissions to block_job_create() |
Date: |
Mon, 27 Feb 2017 21:09:21 +0100 |
This functions creates a BlockBackend internally, so the block jobs need
to tell it what they want to do with the BB.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block/backup.c | 5 +++--
block/commit.c | 5 +++--
block/mirror.c | 5 +++--
block/stream.c | 5 +++--
blockjob.c | 6 +++---
include/block/blockjob_int.h | 4 +++-
tests/test-blockjob-txn.c | 6 +++---
tests/test-blockjob.c | 5 +++--
8 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/block/backup.c b/block/backup.c
index f38d1d0..c759684 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -618,8 +618,9 @@ BlockJob *backup_job_create(const char *job_id,
BlockDriverState *bs,
goto error;
}
- job = block_job_create(job_id, &backup_job_driver, bs, speed,
- creation_flags, cb, opaque, errp);
+ /* FIXME Use real permissions */
+ job = block_job_create(job_id, &backup_job_driver, bs, 0, BLK_PERM_ALL,
+ speed, creation_flags, cb, opaque, errp);
if (!job) {
goto error;
}
diff --git a/block/commit.c b/block/commit.c
index 2ad8138..60d29a9 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -235,8 +235,9 @@ void commit_start(const char *job_id, BlockDriverState *bs,
return;
}
- s = block_job_create(job_id, &commit_job_driver, bs, speed,
- BLOCK_JOB_DEFAULT, NULL, NULL, errp);
+ /* FIXME Use real permissions */
+ s = block_job_create(job_id, &commit_job_driver, bs, 0, BLK_PERM_ALL,
+ speed, BLOCK_JOB_DEFAULT, NULL, NULL, errp);
if (!s) {
return;
}
diff --git a/block/mirror.c b/block/mirror.c
index 7eeeb97..cd4e7db 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1015,8 +1015,9 @@ static void mirror_start_job(const char *job_id,
BlockDriverState *bs,
buf_size = DEFAULT_MIRROR_BUF_SIZE;
}
- s = block_job_create(job_id, driver, bs, speed, creation_flags,
- cb, opaque, errp);
+ /* FIXME Use real permissions */
+ s = block_job_create(job_id, driver, bs, 0, BLK_PERM_ALL, speed,
+ creation_flags, cb, opaque, errp);
if (!s) {
return;
}
diff --git a/block/stream.c b/block/stream.c
index 1523ba7..7f49279 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -229,8 +229,9 @@ void stream_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *iter;
int orig_bs_flags;
- s = block_job_create(job_id, &stream_job_driver, bs, speed,
- BLOCK_JOB_DEFAULT, NULL, NULL, errp);
+ /* FIXME Use real permissions */
+ s = block_job_create(job_id, &stream_job_driver, bs, 0, BLK_PERM_ALL,
+ speed, BLOCK_JOB_DEFAULT, NULL, NULL, errp);
if (!s) {
return;
}
diff --git a/blockjob.c b/blockjob.c
index 72b7d4c..27833c7 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -123,7 +123,8 @@ void block_job_add_bdrv(BlockJob *job, BlockDriverState *bs)
}
void *block_job_create(const char *job_id, const BlockJobDriver *driver,
- BlockDriverState *bs, int64_t speed, int flags,
+ BlockDriverState *bs, uint64_t perm,
+ uint64_t shared_perm, int64_t speed, int flags,
BlockCompletionFunc *cb, void *opaque, Error **errp)
{
BlockBackend *blk;
@@ -160,8 +161,7 @@ void *block_job_create(const char *job_id, const
BlockJobDriver *driver,
}
}
- /* FIXME Use real permissions */
- blk = blk_new(0, BLK_PERM_ALL);
+ blk = blk_new(perm, shared_perm);
ret = blk_insert_bs(blk, bs, errp);
if (ret < 0) {
blk_unref(blk);
diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h
index 8223822..3f86cc5 100644
--- a/include/block/blockjob_int.h
+++ b/include/block/blockjob_int.h
@@ -119,6 +119,7 @@ struct BlockJobDriver {
* generated automatically.
* @job_type: The class object for the newly-created job.
* @bs: The block
+ * @perm, @shared_perm: Permissions to request for @bs
* @speed: The maximum speed, in bytes per second, or 0 for unlimited.
* @cb: Completion function for the job.
* @opaque: Opaque pointer value passed to @cb.
@@ -134,7 +135,8 @@ struct BlockJobDriver {
* called from a wrapper that is specific to the job type.
*/
void *block_job_create(const char *job_id, const BlockJobDriver *driver,
- BlockDriverState *bs, int64_t speed, int flags,
+ BlockDriverState *bs, uint64_t perm,
+ uint64_t shared_perm, int64_t speed, int flags,
BlockCompletionFunc *cb, void *opaque, Error **errp);
/**
diff --git a/tests/test-blockjob-txn.c b/tests/test-blockjob-txn.c
index f6dfd08..4ccbda1 100644
--- a/tests/test-blockjob-txn.c
+++ b/tests/test-blockjob-txn.c
@@ -101,9 +101,9 @@ static BlockJob *test_block_job_start(unsigned int
iterations,
g_assert_nonnull(bs);
snprintf(job_id, sizeof(job_id), "job%u", counter++);
- s = block_job_create(job_id, &test_block_job_driver, bs, 0,
- BLOCK_JOB_DEFAULT, test_block_job_cb,
- data, &error_abort);
+ s = block_job_create(job_id, &test_block_job_driver, bs,
+ 0, BLK_PERM_ALL, 0, BLOCK_JOB_DEFAULT,
+ test_block_job_cb, data, &error_abort);
s->iterations = iterations;
s->use_timer = use_timer;
s->rc = rc;
diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
index 143ce96..1afe17b 100644
--- a/tests/test-blockjob.c
+++ b/tests/test-blockjob.c
@@ -30,8 +30,9 @@ static BlockJob *do_test_id(BlockBackend *blk, const char *id,
BlockJob *job;
Error *errp = NULL;
- job = block_job_create(id, &test_block_job_driver, blk_bs(blk), 0,
- BLOCK_JOB_DEFAULT, block_job_cb, NULL, &errp);
+ job = block_job_create(id, &test_block_job_driver, blk_bs(blk),
+ 0, BLK_PERM_ALL, 0, BLOCK_JOB_DEFAULT, block_job_cb,
+ NULL, &errp);
if (should_succeed) {
g_assert_null(errp);
g_assert_nonnull(job);
--
1.8.3.1
- [Qemu-block] [PATCH v2 10/43] block: Require .bdrv_child_perm() with child nodes, (continued)
- [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
- [Qemu-block] [PATCH v2 20/43] blockjob: Add permissions to block_job_create(),
Kevin Wolf <=
- [Qemu-block] [PATCH v2 21/43] block: Add BdrvChildRole.get_parent_desc(), Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 22/43] block: Include details on permission errors in message, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 23/43] block: Add BdrvChildRole.stay_at_node, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 24/43] blockjob: Add permissions to block_job_add_bdrv(), Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 25/43] commit: Use real permissions in commit block job, Kevin Wolf, 2017/02/27
- [Qemu-block] [PATCH v2 26/43] commit: Use real permissions for HMP 'commit', Kevin Wolf, 2017/02/27
- [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