Skip to content
  • Kevin Wolf's avatar
    d29d3d1f
    block: Relax restrictions for blockdev-snapshot · d29d3d1f
    Kevin Wolf authored
    
    
    blockdev-snapshot returned an error if the overlay was already in use,
    which it defined as having any BlockBackend parent. This is in fact both
    too strict (some parents can tolerate the change of visible data caused
    by attaching a backing file) and too loose (some non-BlockBackend
    parents may not be happy with it).
    
    One important use case that is prevented by the too strict check is live
    storage migration with blockdev-mirror. Here, the target node is
    usually opened without a backing file so that the active layer is
    mirrored while its backing chain can be copied in the background.
    
    The backing chain should be attached to the mirror target node when
    finalising the job, just before switching the users of the source node
    to the new copy (at which point the mirror job still has a reference to
    the node). drive-mirror did this automatically, but with blockdev-mirror
    this is the job of the QMP client, so it needs a way to do this.
    
    blockdev-snapshot is the obvious way, so this patch makes it work in
    this scenario. The new condition is that no parent uses CONSISTENT_READ
    permissions. This will ensure that the operation will still be blocked
    when the node is attached to the guest device, so blockdev-snapshot
    remains safe.
    
    (For the sake of completeness, x-blockdev-reopen can be used to achieve
    the same, however it is a big hammer, performs the graph change
    completely unchecked and is still experimental. So even with the option
    of using x-blockdev-reopen, there are reasons why blockdev-snapshot
    should be able to perform this operation.)
    
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    Message-Id: <20200310113831.27293-3-kwolf@redhat.com>
    Reviewed-by: default avatarPeter Krempa <pkrempa@redhat.com>
    Tested-by: default avatarPeter Krempa <pkrempa@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    d29d3d1f
    block: Relax restrictions for blockdev-snapshot
    Kevin Wolf authored
    
    
    blockdev-snapshot returned an error if the overlay was already in use,
    which it defined as having any BlockBackend parent. This is in fact both
    too strict (some parents can tolerate the change of visible data caused
    by attaching a backing file) and too loose (some non-BlockBackend
    parents may not be happy with it).
    
    One important use case that is prevented by the too strict check is live
    storage migration with blockdev-mirror. Here, the target node is
    usually opened without a backing file so that the active layer is
    mirrored while its backing chain can be copied in the background.
    
    The backing chain should be attached to the mirror target node when
    finalising the job, just before switching the users of the source node
    to the new copy (at which point the mirror job still has a reference to
    the node). drive-mirror did this automatically, but with blockdev-mirror
    this is the job of the QMP client, so it needs a way to do this.
    
    blockdev-snapshot is the obvious way, so this patch makes it work in
    this scenario. The new condition is that no parent uses CONSISTENT_READ
    permissions. This will ensure that the operation will still be blocked
    when the node is attached to the guest device, so blockdev-snapshot
    remains safe.
    
    (For the sake of completeness, x-blockdev-reopen can be used to achieve
    the same, however it is a big hammer, performs the graph change
    completely unchecked and is still experimental. So even with the option
    of using x-blockdev-reopen, there are reasons why blockdev-snapshot
    should be able to perform this operation.)
    
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    Message-Id: <20200310113831.27293-3-kwolf@redhat.com>
    Reviewed-by: default avatarPeter Krempa <pkrempa@redhat.com>
    Tested-by: default avatarPeter Krempa <pkrempa@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Loading