From: Eric Blake <eblake@redhat.com>
To: Fam Zheng <famz@redhat.com>, John Snow <jsnow@redhat.com>
Cc: armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org,
mreitz@redhat.com
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] block: clarify error message for qmp-eject
Date: Tue, 17 May 2016 20:34:57 -0600 [thread overview]
Message-ID: <573BD4D1.8090103@redhat.com> (raw)
In-Reply-To: <20160518021825.GB1864@ad.usersys.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1824 bytes --]
On 05/17/2016 08:18 PM, Fam Zheng wrote:
> On Tue, 05/17 20:42, John Snow wrote:
>> If you use HMP's eject but the CDROM tray is locked, you may get a
>> confusing error message informing you that the "tray isn't open."
>>
>> As this is the point of eject, we can do a little better and help
>> clarify that the tray was locked and that it (might) open up later,
>> so try again.
>>
>> It's not ideal, but it makes the semantics of the (legacy) eject
>> command more understandable to end users when they try to use it.
>>
>> if (!blk_dev_has_removable_media(blk)) {
>> error_setg(errp, "Device '%s' is not removable", device);
>> - return;
>> + return -ENOTSUP;
>> }
>>
>> if (!blk_dev_has_tray(blk)) {
>> /* Ignore this command on tray-less devices */
>> - return;
>> + return -ENOSYS;
>
> I'm not sure how acceptable it is to leave errp untouched while setting ret
> code to non-zero. Markus?
You're basically returning a tri-state: errp set (fatal, error issued),
0 (success, no error needed), or errp clear and negative (potential
error, but caller must decide). It's unusual enough that you probably
ought to document it at the top of the function, and it may mess with
Markus' pending work to return status codes from functions taking Error **.
It might also be worth considering using a POSITIVE return value when
not setting an error code, so that a quick <0 check is synonymous with
error set, 0 remains the code for complete success, and the locked tray
with a retry now has an identifiable sentinel - particularly since you
don't care about what errno values were in use except for EINPROGRESS.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2016-05-18 2:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-18 0:42 [Qemu-devel] [PATCH] block: clarify error message for qmp-eject John Snow
2016-05-18 2:18 ` Fam Zheng
2016-05-18 2:34 ` Eric Blake [this message]
2016-05-18 5:36 ` [Qemu-devel] [Qemu-block] " Markus Armbruster
2016-05-18 6:36 ` Fam Zheng
2016-05-18 13:01 ` Markus Armbruster
2016-05-18 14:13 ` John Snow
2016-05-18 14:21 ` John Snow
2016-05-19 17:15 ` Markus Armbruster
2016-05-18 2:31 ` [Qemu-devel] " Eric Blake
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=573BD4D1.8090103@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=famz@redhat.com \
--cc=jsnow@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 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).