qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Nir Soffer <nsoffer@redhat.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	Kevin Wolf <kwolf@redhat.com>, qemu-block <qemu-block@nongnu.org>,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH RFC] qemu-io: Prefer stderr for error messages
Date: Wed, 12 Dec 2018 19:26:27 -0600	[thread overview]
Message-ID: <526c4d1c-9ad5-e8dc-d2ba-c043a76749ab@redhat.com> (raw)
In-Reply-To: <CAMRbyyuZ81fyHYTQSHPXhjYoLFz6nzsxc30PNJdWRkqm=14RRA@mail.gmail.com>

On 12/12/18 5:52 PM, Nir Soffer wrote:
> On Thu, Dec 13, 2018 at 12:13 AM Eric Blake <eblake@redhat.com> wrote:
>>
>> When a qemu-io command fails, it's best if the failure message
>> goes to stderr rather than stdout.
> 
> This makes sense, but it will break users like this:
> 
> https://github.com/oVirt/vdsm/blob/a2836b1d58ffaa0f48cc9c814b6002161a81f044/tests/storage/qemuio.py#L45
> 
> We need a way to detect qemu-io verification failures, maybe a special
> exit code?
> 
> 0 - verification succeeded
> 1 - verification failed
> 2 - other error (e.g no such file)
> 
> Or, if qemu-io had a way to read data and write it to stdout, we could
> compare the data and avoid the need for special exit code.
> 

>> @@ -723,8 +725,8 @@ static int read_f(BlockBackend *blk, int argc, char **argv)
>>           print_cvtnum_err(count, argv[optind]);
>>           return count;
>>       } else if (count > BDRV_REQUEST_MAX_BYTES) {
>> -        printf("length cannot exceed %" PRIu64 ", given %s\n",
>> -               (uint64_t)BDRV_REQUEST_MAX_BYTES, argv[optind]);
>> +        fprintf(stderr, "length cannot exceed %" PRIu64 ", given %s\n",
>> +                (uint64_t)BDRV_REQUEST_MAX_BYTES, argv[optind]);
>>           return -EINVAL;
>>       }
>>
>> @@ -738,19 +740,22 @@ static int read_f(BlockBackend *blk, int argc, char **argv)
>>       }
>>
>>       if ((pattern_count < 0) || (pattern_count + pattern_offset > count))  {
>> -        printf("pattern verification range exceeds end of read data\n");
>> +        fprintf(stderr,
>> +                "pattern verification range exceeds end of read data\n");
>>           return -EINVAL;

Note that 'read -P ...' can fail for both pattern verification failure, 
and for other reasons, both before and after this patch. The only thing 
this patch is doing is changing where the failure messages are output. 
Or is your complaint that your existing code is already catering to 
older qemu that had 0 exit status, and parsing stdout for a specific 
string rather than trusting exit status, and now stdout won't have that 
specific string?  qemu-io is not quite as worried about backwards 
compatibility as qemu-img or qemu proper, but at least knowing what 
might break might help us design something more user-friendly.

Can you redirect qemu-io to output both stdout and stderr to the same 
file, if you have to parse the answers to learn if verification has failed?

And your idea of having distinguished error codes for verification fail 
vs. overall failure makes some sense, but it would require some major 
rework (right now, returning -errno codes does not really tell the 
caller what exit status to report).

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

  reply	other threads:[~2018-12-13  1:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-12 22:04 [Qemu-devel] [PATCH RFC] qemu-io: Prefer stderr for error messages Eric Blake
2018-12-12 22:11 ` Richard W.M. Jones
2018-12-12 23:52 ` [Qemu-devel] [Qemu-block] " Nir Soffer
2018-12-13  1:26   ` Eric Blake [this message]
2018-12-13 10:47   ` Daniel P. Berrangé
2018-12-13 14:05     ` Kevin Wolf
2018-12-13 14:23       ` Eric Blake
2018-12-13 14:34         ` Kevin Wolf
2018-12-13 17:44       ` Nir Soffer
2018-12-13 21:27         ` Eric Blake
2018-12-13 22:13           ` Nir Soffer
2018-12-13 17:15     ` Nir Soffer
2018-12-13 10:11 ` [Qemu-devel] " Daniel P. Berrangé
2018-12-13 14:22   ` Kevin Wolf
2018-12-13 16:02     ` Richard W.M. Jones
2018-12-13 12:21 ` Wainer dos Santos Moschetta
2018-12-13 14:04   ` Eric Blake
2018-12-13 14:38 ` Kevin Wolf

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=526c4d1c-9ad5-e8dc-d2ba-c043a76749ab@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=nsoffer@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).