From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1Efp-0004KL-P4 for qemu-devel@nongnu.org; Mon, 31 Oct 2016 11:38:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1Efo-0004wH-TD for qemu-devel@nongnu.org; Mon, 31 Oct 2016 11:38:57 -0400 From: Fam Zheng Date: Mon, 31 Oct 2016 23:38:24 +0800 Message-Id: <1477928314-11184-5-git-send-email-famz@redhat.com> In-Reply-To: <1477928314-11184-1-git-send-email-famz@redhat.com> References: <1477928314-11184-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH 04/14] qemu-img: Set "share-rw" flag in read-only commands List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Daniel P. Berrange" , Kevin Wolf , Max Reitz , qemu-block@nongnu.org, rjones@redhat.com Checking the status of an image when it is being used by guest is usually useful, and there is no risk of corrupting data, so don't let the upcoming image locking feature limit this use case. Signed-off-by: Fam Zheng --- qemu-img.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index afcd51f..b2f4077 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -679,6 +679,10 @@ static int img_check(int argc, char **argv) break; } } + + if (!(flags & BDRV_O_RDWR)) { + flags |= BDRV_O_SHARE_RW; + } if (optind != argc - 1) { error_exit("Expecting one image file name"); } @@ -1231,6 +1235,7 @@ static int img_compare(int argc, char **argv) goto out3; } + flags |= BDRV_O_SHARE_RW; blk1 = img_open(image_opts, filename1, fmt1, flags, writethrough, quiet); if (!blk1) { ret = 2; @@ -2279,7 +2284,8 @@ static ImageInfoList *collect_image_info_list(bool image_opts, g_hash_table_insert(filenames, (gpointer)filename, NULL); blk = img_open(image_opts, filename, fmt, - BDRV_O_NO_BACKING | BDRV_O_NO_IO, false, false); + BDRV_O_NO_BACKING | BDRV_O_NO_IO | BDRV_O_SHARE_RW, + false, false); if (!blk) { goto err; } @@ -2605,7 +2611,7 @@ static int img_map(int argc, char **argv) return 1; } - blk = img_open(image_opts, filename, fmt, 0, false, false); + blk = img_open(image_opts, filename, fmt, BDRV_O_SHARE_RW, false, false); if (!blk) { return 1; } -- 2.7.4