Skip to contentSkip to conversation

block/io: Comment out permission assertions

PATCH Applied Max Reitz 4 participants 7 messages Apr 11, 2017 – Apr 12, 2017 Block layer

lore
Share & tools
lore

Max Reitz

author
#0 lore raw

PATCH 1/1 block/io: Comment out permission assertions

In case of block migration, there may be writes to BlockBackends that do not have the write permission taken. Before this issue is fixed (which is not going to happen in 2.9), we therefore cannot assert that this is the case.

---
 block.c    |  6 +++++-
 block/io.c | 12 ++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)
block.c +5 -1
index 086a12df97..1fbbb8d606 100644
@@ -3274,7 +3274,11 @@ int bdrv_truncate(BdrvChild *child, int64_t offset)
     BlockDriver *drv = bs->drv;
     int ret;
 
-    assert(child->perm & BLK_PERM_RESIZE);
+    /* FIXME: Some format block drivers use this function instead of implicitly
+     *        growing their file by writing beyond its end.
+     *        See bdrv_aligned_pwritev() for an explanation why we currently
+     *        cannot assert this permission in that case. */
+    // assert(child->perm & BLK_PERM_RESIZE);
 
     if (!drv)
         return -ENOMEDIUM;
block/io.c +10 -2
index bae6947032..8706bfa578 100644
@@ -1345,8 +1345,16 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
     assert(!waited || !req->serialising);
     assert(req->overlap_offset <= offset);
     assert(offset + bytes <= req->overlap_offset + req->overlap_bytes);
-    assert(child->perm & BLK_PERM_WRITE);
-    assert(end_sector <= bs->total_sectors || child->perm & BLK_PERM_RESIZE);
+    /* FIXME: Block migration uses the BlockBackend of the guest device at a
+     *        point when it has not yet taken write permissions. This will be
+     *        fixed by a future patch, but for now we have to bypass this
+     *        assertion for block migration to work. */
+    // assert(child->perm & BLK_PERM_WRITE);
+    /* FIXME: Because of the above, we also cannot guarantee that all format
+     *        BDS take the BLK_PERM_RESIZE permission on their file BDS, since
+     *        they are not obligated to do so if they do not have any parent
+     *        that has taken the permission to write to them. */
+    // assert(end_sector <= bs->total_sectors || child->perm & BLK_PERM_RESIZE);
 
     ret = notifier_with_return_list_notify(&bs->before_write_notifiers, req);
 
Signature · 1 line
2.12.2
author
#1 lore raw
Quoted 11 lines · Max Reitz

In case of block migration, there may be writes to BlockBackends that do not have the write permission taken. Before this issue is fixed (which is not going to happen in 2.9), we therefore cannot assert that this is the case.

---
 block.c    |  6 +++++-
 block/io.c | 12 ++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

I'll send a revert for 2.10 if/when this is merged.

Max

Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Max Reitz

Am 11.04.2017 um 16:50 hat Max Reitz geschrieben:

Quoted 7 lines

In case of block migration, there may be writes to BlockBackends that do not have the write permission taken. Before this issue is fixed (which is not going to happen in 2.9), we therefore cannot assert that this is the case.

I tested block migration (migrate -b). Leaving postcopy migration, which is apparently also broken, to Laurent.

Tested-by
#3 lore raw
Quoted 6 lines · Kevin Wolf

Am 11.04.2017 um 16:50 hat Max Reitz geschrieben:

Quoted 5 lines

In case of block migration, there may be writes to BlockBackends that do not have the write permission taken. Before this issue is fixed (which is not going to happen in 2.9), we therefore cannot assert that this is the case.

Quoted 9 lines
Quoted 2 lines

I tested block migration (migrate -b). Leaving postcopy migration, which is apparently also broken, to Laurent.

With postcopy migration

#4 lore raw

Am 11.04.2017 um 17:07 hat Laurent Vivier geschrieben:

Quoted 13 lines · Kevin Wolf
Quoted 12 lines

Am 11.04.2017 um 16:50 hat Max Reitz geschrieben:

Quoted 7 lines

In case of block migration, there may be writes to BlockBackends that do not have the write permission taken. Before this issue is fixed (which is not going to happen in 2.9), we therefore cannot assert that this is the case.

I tested block migration (migrate -b). Leaving postcopy migration, which is apparently also broken, to Laurent.

Quoted 6 lines
Quoted 2 lines

With postcopy migration

I think the following is the real fix for postcopy migration, in case someone wants to give it a test before I send it as a proper patch (the bug is a result of duplicating code between precopy/postcopy migration instead of sharing it - commit d35ff5e6 only updated one of both).

Kevin

migration/savevm.c +8 -0
index 3b19a4a..43fa9bf 100644
@@ -1623,6 +1623,14 @@ static void loadvm_postcopy_handle_run_bh(void *opaque)
         error_report_err(local_err);
     }
 
+    /* If we get an error here, just don't restart the VM yet. */
+    blk_resume_after_migration(&local_err);
+    if (local_err) {
+        error_free(local_err);
+        local_err = NULL;
+        autostart = false;
+    }
+
     trace_loadvm_postcopy_handle_run_cpu_sync();
     cpu_synchronize_all_post_init();
#5 lore raw
Quoted 17 lines · Kevin Wolf

Am 11.04.2017 um 17:07 hat Laurent Vivier geschrieben:

Quoted 16 lines · Kevin Wolf
Quoted 14 lines

Am 11.04.2017 um 16:50 hat Max Reitz geschrieben:

Quoted 7 lines

In case of block migration, there may be writes to BlockBackends that do not have the write permission taken. Before this issue is fixed (which is not going to happen in 2.9), we therefore cannot assert that this is the case.

I tested block migration (migrate -b). Leaving postcopy migration, which is apparently also broken, to Laurent.

Quoted 8 lines
Quoted 3 lines

With postcopy migration

I think the following is the real fix for postcopy migration, in case someone wants to give it a test before I send it as a proper patch (the bug is a result of duplicating code between precopy/postcopy migration instead of sharing it - commit d35ff5e6 only updated one of both).

Tested with my test case and it works fine.

Thanks,
Laurent