Skip to content
  • Hanna Reitz's avatar
    a1c62436
    qemu-img: Allow target be aligned to sector size · a1c62436
    Hanna Reitz authored
    We cannot write to images opened with O_DIRECT unless we allow them to
    be resized so they are aligned to the sector size: Since 9c60a5d1,
    bdrv_node_refresh_perm() ensures that for nodes whose length is not
    aligned to the request alignment and where someone has taken a WRITE
    permission, the RESIZE permission is taken, too).
    
    Let qemu-img convert pass the BDRV_O_RESIZE flag (which causes
    blk_new_open() to take the RESIZE permission) when using cache=none for
    the target, so that when writing to it, it can be aligned to the target
    sector size.
    
    Without this patch, an error is returned:
    
    $ qemu-img convert -f raw -O raw -t none foo.img /mnt/tmp/foo.img
    qemu-img: Could not open '/mnt/tmp/foo.img': Cannot get 'write'
    permission without 'resize': Image size is not a multiple of request
    alignment
    
    Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1994266
    
    
    Signed-off-by: default avatarHanna Reitz <hreitz@redhat.com>
    Message-Id: <20210819101200.64235-1-hreitz@redhat.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
    a1c62436
    qemu-img: Allow target be aligned to sector size
    Hanna Reitz authored
    We cannot write to images opened with O_DIRECT unless we allow them to
    be resized so they are aligned to the sector size: Since 9c60a5d1,
    bdrv_node_refresh_perm() ensures that for nodes whose length is not
    aligned to the request alignment and where someone has taken a WRITE
    permission, the RESIZE permission is taken, too).
    
    Let qemu-img convert pass the BDRV_O_RESIZE flag (which causes
    blk_new_open() to take the RESIZE permission) when using cache=none for
    the target, so that when writing to it, it can be aligned to the target
    sector size.
    
    Without this patch, an error is returned:
    
    $ qemu-img convert -f raw -O raw -t none foo.img /mnt/tmp/foo.img
    qemu-img: Could not open '/mnt/tmp/foo.img': Cannot get 'write'
    permission without 'resize': Image size is not a multiple of request
    alignment
    
    Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1994266
    
    
    Signed-off-by: default avatarHanna Reitz <hreitz@redhat.com>
    Message-Id: <20210819101200.64235-1-hreitz@redhat.com>
    Reviewed-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Loading