diff options
author | Kevin Wolf <kwolf@redhat.com> | 2017-01-25 11:39:04 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2017-02-28 20:40:37 +0100 |
commit | 4e9e4323d5ec07a07f8db9317e1842a5e00a14e2 (patch) | |
tree | 64553f45bd929623f75d394f1bbbe131fd67b22f /block/backup.c | |
parent | d3f06759222e70979965e3afccfd88eddd3cc454 (diff) | |
download | qemu-4e9e4323d5ec07a07f8db9317e1842a5e00a14e2.zip qemu-4e9e4323d5ec07a07f8db9317e1842a5e00a14e2.tar.gz qemu-4e9e4323d5ec07a07f8db9317e1842a5e00a14e2.tar.bz2 |
backup: Use real permissions in backup block job
The backup block job doesn't have very complicated requirements: It
needs to read from the source and write to the target, but it's fine
with either side being changed. The only restriction is that we can't
resize the image because the job uses a cached value.
qemu-iotests 055 needs to be changed because it used a target which was
already attached to a virtio-blk device. The permission system correctly
forbids this (virtio-blk can't accept another writer with its default
share-rw=off).
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Acked-by: Fam Zheng <famz@redhat.com>
Diffstat (limited to 'block/backup.c')
-rw-r--r-- | block/backup.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/block/backup.c b/block/backup.c index 405f271..d1ab617 100644 --- a/block/backup.c +++ b/block/backup.c @@ -618,15 +618,20 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, goto error; } - /* FIXME Use real permissions */ - job = block_job_create(job_id, &backup_job_driver, bs, 0, BLK_PERM_ALL, + /* job->common.len is fixed, so we can't allow resize */ + job = block_job_create(job_id, &backup_job_driver, bs, + BLK_PERM_CONSISTENT_READ, + BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | + BLK_PERM_WRITE_UNCHANGED | BLK_PERM_GRAPH_MOD, speed, creation_flags, cb, opaque, errp); if (!job) { goto error; } - /* FIXME Use real permissions */ - job->target = blk_new(0, BLK_PERM_ALL); + /* The target must match the source in size, so no resize here either */ + job->target = blk_new(BLK_PERM_WRITE, + BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | + BLK_PERM_WRITE_UNCHANGED | BLK_PERM_GRAPH_MOD); ret = blk_insert_bs(job->target, target, errp); if (ret < 0) { goto error; @@ -657,7 +662,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, job->cluster_size = MAX(BACKUP_CLUSTER_SIZE_DEFAULT, bdi.cluster_size); } - /* FIXME Use real permissions */ + /* Required permissions are already taken with target's blk_new() */ block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL, &error_abort); job->common.len = len; |