[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 38/39] qemu-img convert: Unshare write permission for source
From: |
Kevin Wolf |
Subject: |
[PULL 38/39] qemu-img convert: Unshare write permission for source |
Date: |
Fri, 30 Apr 2021 12:51:46 +0200 |
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: Xueqiang Wei <xuwei@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210422164344.283389-3-kwolf@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qemu-img.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qemu-img.c b/qemu-img.c
index babb5573ab..a5993682aa 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2146,7 +2146,7 @@ static void set_rate_limit(BlockBackend *blk, int64_t
rate_limit)
static int img_convert(int argc, char **argv)
{
- int c, bs_i, flags, src_flags = 0;
+ int c, bs_i, flags, src_flags = BDRV_O_NO_SHARE;
const char *fmt = NULL, *out_fmt = NULL, *cache = "unsafe",
*src_cache = BDRV_DEFAULT_CACHE, *out_baseimg = NULL,
*out_filename, *out_baseimg_param, *snapshot_name = NULL;
--
2.30.2
- [PULL 34/39] block: refactor bdrv_child_set_perm_safe() transaction action, (continued)
- [PULL 34/39] block: refactor bdrv_child_set_perm_safe() transaction action, Kevin Wolf, 2021/04/30
- [PULL 33/39] block: inline bdrv_replace_child(), Kevin Wolf, 2021/04/30
- [PULL 27/39] block: make bdrv_refresh_limits() to be a transaction action, Kevin Wolf, 2021/04/30
- [PULL 36/39] block: refactor bdrv_node_check_perm(), Kevin Wolf, 2021/04/30
- [PULL 30/39] block: bdrv_reopen_multiple: refresh permissions on updated graph, Kevin Wolf, 2021/04/30
- [PULL 31/39] block: drop unused permission update functions, Kevin Wolf, 2021/04/30
- [PULL 39/39] vhost-user-blk: Fail gracefully on too large queue size, Kevin Wolf, 2021/04/30
- [PULL 32/39] block: inline bdrv_check_perm_common(), Kevin Wolf, 2021/04/30
- [PULL 35/39] block: rename bdrv_replace_child_safe() to bdrv_replace_child(), Kevin Wolf, 2021/04/30
- [PULL 37/39] block: Add BDRV_O_NO_SHARE for blk_new_open(), Kevin Wolf, 2021/04/30
- [PULL 38/39] qemu-img convert: Unshare write permission for source,
Kevin Wolf <=
- Re: [PULL 00/39] Block layer patches, Peter Maydell, 2021/04/30