Skip to content
Snippets Groups Projects
  • Kevin Wolf's avatar
    0b8fb55c
    qemu-img convert: Unshare write permission for source · 0b8fb55c
    Kevin Wolf authored
    
    For a successful conversion of an image, we must make sure that its
    content doesn't change during the conversion.
    
    A special case of this is using the same image file both as the source
    and as the destination. If both input and output format are raw, the
    operation would just be useless work, with other formats it is a sure
    way to destroy the image. This will now fail because the image file
    can't be opened a second time for the output when opening it for the
    input has already acquired file locks to unshare BLK_PERM_WRITE.
    
    Nevertheless, if there is some reason in a special case why it is
    actually okay to allow writes to the image while it is being converted,
    -U can still be used to force sharing all permissions.
    
    Note that for most image formats, BLK_PERM_WRITE would already be
    unshared by the format driver, so this only really makes a difference
    for raw source images (but any output format).
    
    Reported-by: default avatarXueqiang Wei <xuwei@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    Reviewed-by: default avatarEric Blake <eblake@redhat.com>
    Message-Id: <20210422164344.283389-3-kwolf@redhat.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    0b8fb55c
    History
    qemu-img convert: Unshare write permission for source
    Kevin Wolf authored
    
    For a successful conversion of an image, we must make sure that its
    content doesn't change during the conversion.
    
    A special case of this is using the same image file both as the source
    and as the destination. If both input and output format are raw, the
    operation would just be useless work, with other formats it is a sure
    way to destroy the image. This will now fail because the image file
    can't be opened a second time for the output when opening it for the
    input has already acquired file locks to unshare BLK_PERM_WRITE.
    
    Nevertheless, if there is some reason in a special case why it is
    actually okay to allow writes to the image while it is being converted,
    -U can still be used to force sharing all permissions.
    
    Note that for most image formats, BLK_PERM_WRITE would already be
    unshared by the format driver, so this only really makes a difference
    for raw source images (but any output format).
    
    Reported-by: default avatarXueqiang Wei <xuwei@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    Reviewed-by: default avatarEric Blake <eblake@redhat.com>
    Message-Id: <20210422164344.283389-3-kwolf@redhat.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>