[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 39/46] migration/block: Use real permissions
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 39/46] migration/block: Use real permissions |
Date: |
Tue, 28 Feb 2017 21:36:38 +0100 |
Request BLK_PERM_CONSISTENT_READ for the source of block migration, and
handle potential permission errors as good as we can in this place
(which is not very good, but it matches the other failure cases).
Signed-off-by: Kevin Wolf <address@hidden>
Acked-by: Fam Zheng <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
migration/block.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/migration/block.c b/migration/block.c
index d259936..1941bc2 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -379,7 +379,7 @@ static void unset_dirty_tracking(void)
}
}
-static void init_blk_migration(QEMUFile *f)
+static int init_blk_migration(QEMUFile *f)
{
BlockDriverState *bs;
BlkMigDevState *bmds;
@@ -390,6 +390,8 @@ static void init_blk_migration(QEMUFile *f)
BlkMigDevState *bmds;
BlockDriverState *bs;
} *bmds_bs;
+ Error *local_err = NULL;
+ int ret;
block_mig_state.submitted = 0;
block_mig_state.read_done = 0;
@@ -411,12 +413,12 @@ static void init_blk_migration(QEMUFile *f)
sectors = bdrv_nb_sectors(bs);
if (sectors <= 0) {
+ ret = sectors;
goto out;
}
bmds = g_new0(BlkMigDevState, 1);
- /* FIXME Use real permissions */
- bmds->blk = blk_new(0, BLK_PERM_ALL);
+ bmds->blk = blk_new(BLK_PERM_CONSISTENT_READ, BLK_PERM_ALL);
bmds->blk_name = g_strdup(bdrv_get_device_name(bs));
bmds->bulk_completed = 0;
bmds->total_sectors = sectors;
@@ -446,7 +448,11 @@ static void init_blk_migration(QEMUFile *f)
BlockDriverState *bs = bmds_bs[i].bs;
if (bmds) {
- blk_insert_bs(bmds->blk, bs, &error_abort);
+ ret = blk_insert_bs(bmds->blk, bs, &local_err);
+ if (ret < 0) {
+ error_report_err(local_err);
+ goto out;
+ }
alloc_aio_bitmap(bmds);
error_setg(&bmds->blocker, "block device is in use by migration");
@@ -454,8 +460,10 @@ static void init_blk_migration(QEMUFile *f)
}
}
+ ret = 0;
out:
g_free(bmds_bs);
+ return ret;
}
/* Called with no lock taken. */
@@ -706,7 +714,11 @@ static int block_save_setup(QEMUFile *f, void *opaque)
block_mig_state.submitted, block_mig_state.transferred);
qemu_mutex_lock_iothread();
- init_blk_migration(f);
+ ret = init_blk_migration(f);
+ if (ret < 0) {
+ qemu_mutex_unlock_iothread();
+ return ret;
+ }
/* start track dirty blocks */
ret = set_dirty_tracking();
--
1.8.3.1
- [Qemu-devel] [PULL 27/46] commit: Use real permissions in commit block job, (continued)
- [Qemu-devel] [PULL 27/46] commit: Use real permissions in commit block job, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 26/46] blockjob: Add permissions to block_job_add_bdrv(), Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 32/46] block: Allow backing file links in change_parent_backing_link(), Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 30/46] block: Fix pending requests check in bdrv_append(), Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 31/46] block: BdrvChildRole.attach/detach() callbacks, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 33/46] blockjob: Factor out block_job_remove_all_bdrv(), Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 35/46] stream: Use real permissions in streaming block job, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 36/46] mirror: Add filter-node-name to blockdev-mirror, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 37/46] commit: Add filter-node-name to block-commit, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 34/46] mirror: Use real permissions in mirror/active commit block job, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 39/46] migration/block: Use real permissions,
Kevin Wolf <=
- [Qemu-devel] [PULL 38/46] hmp: Request permissions in qemu-io, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 40/46] nbd/server: Use real permissions for NBD exports, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 41/46] tests: Remove FIXME comments, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 42/46] block: Pass BdrvChild to bdrv_aligned_preadv/pwritev and copy-on-read, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 43/46] block: Assertions for write permissions, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 44/46] block: Assertions for resize permission, Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 45/46] block: Add Error parameter to bdrv_set_backing_hd(), Kevin Wolf, 2017/02/28
- [Qemu-devel] [PULL 46/46] block: Add Error parameter to bdrv_append(), Kevin Wolf, 2017/02/28