blockjob: Add permissions to block_job_create()
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 <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Acked-by: Fam Zheng <famz@redhat.com>
This commit is contained in:
parent
dabd18f64c
commit
c6cc12bfa7
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user