All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/2] qemu-img: info: try -U automatically
Date: Fri, 5 Jan 2018 10:08:18 -0600	[thread overview]
Message-ID: <75051aa2-5544-449d-0659-4460a9de5554@redhat.com> (raw)
In-Reply-To: <20180105065538.13375-3-famz@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2890 bytes --]

On 01/05/2018 12:55 AM, Fam Zheng wrote:
> 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 <famz@redhat.com>
> ---
>  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 "

We have warn_report() for use in this situation (in which case, you do
not want the leading "WARNING:" in your message).

> +                         "seems the image is attached to a running guest; "
> +                         "the information may be inaccurate if it is being "
> +                         "updated.");

For consistency, I'd prefer no trailing dot.

> +            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.

and those changes tweak this line.

But the idea makes sense, so with the changes,
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

  reply	other threads:[~2018-01-05 16:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-05  6:55 [Qemu-devel] [PATCH 0/2] qemu-img: Let "info" warn and go ahead without -U Fam Zheng
2018-01-05  6:55 ` [Qemu-devel] [PATCH 1/2] qemu-img: Move img_open error reporting to callers Fam Zheng
2018-01-05 16:03   ` Eric Blake
2018-01-05  6:55 ` [Qemu-devel] [PATCH 2/2] qemu-img: info: try -U automatically Fam Zheng
2018-01-05 16:08   ` Eric Blake [this message]
2018-01-08 14:41 ` [Qemu-devel] [PATCH 0/2] qemu-img: Let "info" warn and go ahead without -U Kevin Wolf
2018-01-08 17:07   ` [Qemu-devel] [Qemu-block] " Nir Soffer
2018-01-08 17:57     ` Kevin Wolf
2018-01-09  6:24       ` Fam Zheng
2018-01-09  9:58         ` Kevin Wolf
2018-01-09 19:58           ` Ala Hino
2018-01-09 20:11             ` Eric Blake
2018-01-09 20:29               ` Ala Hino
2018-01-10 12:51       ` Daniel P. Berrange
2018-01-10 12:49   ` [Qemu-devel] " Daniel P. Berrange
2018-01-10 14:07     ` Kevin Wolf
2018-01-10 14:13       ` Daniel P. Berrange
2018-01-10 14:03   ` Kashyap Chamarthy
2018-01-10 16:43     ` [Qemu-devel] [Qemu-block] " Nir Soffer
2018-01-11  9:26       ` Kashyap Chamarthy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=75051aa2-5544-449d-0659-4460a9de5554@redhat.com \
    --to=eblake@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.