[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/2] qemu-img: info: try -U automatically
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PATCH 2/2] qemu-img: info: try -U automatically |
Date: |
Fri, 5 Jan 2018 14:55:38 +0800 |
The error message we had didn't have a hint about "-U" when locking the
image failed, which is not friendly. Also it is imaginable that the
reaction to that error by the user would be a retry with '-U'.
So the reason we require "-U" for "qemu-img info" if the image is used
is to raise the awareness about what could be wrong. A warning would do
just fine, especially since it is a little more informative.
The test case reference output is updated accordingly.
Signed-off-by: Fam Zheng <address@hidden>
---
qemu-img.c | 14 ++++++++++++++
tests/qemu-iotests/153.out | 3 +--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 7d3171c20c..9684937425 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2605,6 +2605,20 @@ static int img_info(int argc, char **argv)
list = collect_image_info_list(image_opts, filename, fmt, chain,
force_share, &local_err);
+ if (!list && !force_share) {
+ Error *local_err2 = NULL;
+ list = collect_image_info_list(image_opts, filename, fmt, chain,
+ true, &local_err2);
+ if (list) {
+ error_report("WARNING: --force-share (-U) is not used but it "
+ "seems the image is attached to a running guest; "
+ "the information may be inaccurate if it is being "
+ "updated.");
+ error_free(local_err);
+ } else {
+ error_free(local_err2);
+ }
+ }
if (!list) {
error_reportf_err(local_err, "Could not open '%s': ", filename);
return 1;
diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out
index 5b917b177c..4de35184ba 100644
--- a/tests/qemu-iotests/153.out
+++ b/tests/qemu-iotests/153.out
@@ -41,8 +41,7 @@ Is another process using the image?
no file open, try 'help open'
_qemu_img_wrapper info TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
-Is another process using the image?
+qemu-img: WARNING: --force-share (-U) is not used but it seems the image is
attached to a running guest; the information may be inaccurate if it is being
updated.
_qemu_img_wrapper check TEST_DIR/t.qcow2
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
--
2.14.3
- [Qemu-devel] [PATCH 0/2] qemu-img: Let "info" warn and go ahead without -U, Fam Zheng, 2018/01/05
- [Qemu-devel] [PATCH 2/2] qemu-img: info: try -U automatically,
Fam Zheng <=
- [Qemu-devel] [PATCH 1/2] qemu-img: Move img_open error reporting to callers, Fam Zheng, 2018/01/05
- Re: [Qemu-devel] [PATCH 0/2] qemu-img: Let "info" warn and go ahead without -U, Kevin Wolf, 2018/01/08
- Re: [Qemu-devel] [Qemu-block] [PATCH 0/2] qemu-img: Let "info" warn and go ahead without -U, Nir Soffer, 2018/01/08
- Re: [Qemu-devel] [Qemu-block] [PATCH 0/2] qemu-img: Let "info" warn and go ahead without -U, Kevin Wolf, 2018/01/08
- Re: [Qemu-devel] [Qemu-block] [PATCH 0/2] qemu-img: Let "info" warn and go ahead without -U, Fam Zheng, 2018/01/09
- Re: [Qemu-devel] [Qemu-block] [PATCH 0/2] qemu-img: Let "info" warn and go ahead without -U, Kevin Wolf, 2018/01/09
- Re: [Qemu-devel] [Qemu-block] [PATCH 0/2] qemu-img: Let "info" warn and go ahead without -U, Ala Hino, 2018/01/09
- Re: [Qemu-devel] [Qemu-block] [PATCH 0/2] qemu-img: Let "info" warn and go ahead without -U, Eric Blake, 2018/01/09