Skip to content
Snippets Groups Projects
  • Vladimir Sementsov-Ogievskiy's avatar
    a13de40a
    block: bdrv_inactivate_recurse(): check for permissions and fix crash · a13de40a
    Vladimir Sementsov-Ogievskiy authored
    
    We must not inactivate child when parent has write permissions on
    it.
    
    Calling .bdrv_inactivate() doesn't help: actually only qcow2 has this
    handler and it is used to flush caches, not for permission
    manipulations.
    
    So, let's simply check cumulative parent permissions before
    inactivating the node.
    
    This commit fixes a crash when we do migration during backup: prior to
    the commit nothing prevents all nodes inactivation at migration finish
    and following backup write to the target crashes on assertion
    "assert(!(bs->open_flags & BDRV_O_INACTIVE));" in
    bdrv_co_write_req_prepare().
    
    After the commit, we rely on the fact that copy-before-write filter
    keeps write permission on target node to be able to write to it. So
    inactivation fails and migration fails as expected.
    
    Corresponding test now passes, so, enable it.
    
    Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
    Reviewed-by: default avatarHanna Reitz <hreitz@redhat.com>
    Message-Id: <20210911120027.8063-3-vsementsov@virtuozzo.com>
    Signed-off-by: default avatarHanna Reitz <hreitz@redhat.com>
    a13de40a
    History
    block: bdrv_inactivate_recurse(): check for permissions and fix crash
    Vladimir Sementsov-Ogievskiy authored
    
    We must not inactivate child when parent has write permissions on
    it.
    
    Calling .bdrv_inactivate() doesn't help: actually only qcow2 has this
    handler and it is used to flush caches, not for permission
    manipulations.
    
    So, let's simply check cumulative parent permissions before
    inactivating the node.
    
    This commit fixes a crash when we do migration during backup: prior to
    the commit nothing prevents all nodes inactivation at migration finish
    and following backup write to the target crashes on assertion
    "assert(!(bs->open_flags & BDRV_O_INACTIVE));" in
    bdrv_co_write_req_prepare().
    
    After the commit, we rely on the fact that copy-before-write filter
    keeps write permission on target node to be able to write to it. So
    inactivation fails and migration fails as expected.
    
    Corresponding test now passes, so, enable it.
    
    Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
    Reviewed-by: default avatarHanna Reitz <hreitz@redhat.com>
    Message-Id: <20210911120027.8063-3-vsementsov@virtuozzo.com>
    Signed-off-by: default avatarHanna Reitz <hreitz@redhat.com>