From: Eric Blake <eblake@redhat.com>
To: clord@redhat.com, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, armbru@redhat.com, qemu-block@nongnu.org,
mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH] blockdev: fix error handling in do_open_tray
Date: Fri, 3 Jun 2016 13:02:38 -0600 [thread overview]
Message-ID: <5751D44E.4060800@redhat.com> (raw)
In-Reply-To: <1464978048-32189-1-git-send-email-clord@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3750 bytes --]
On 06/03/2016 12:20 PM, clord@redhat.com wrote:
> From: Colin Lord <clord@redhat.com>
You may want to update your ~/.gitconfig to set sendemail.from to list
your name in the same manner in which you add S-o-b. (Not strictly a
problem, as 'git am' does the right thing either way, but it will avoid
this secondary From: line in patch mails you send)
>
> Returns negative error codes and accompanying error messages in cases where
> the device has no tray or the tray is locked and isn't forced open. This
> extra information should result in better flexibility in functions that
> call do_open_tray.
>
> Signed-off-by: Colin Lord <clord@redhat.com>
> ---
> blockdev.c | 29 ++++++++++++++++++-----------
> 1 file changed, 18 insertions(+), 11 deletions(-)
>
> diff --git a/blockdev.c b/blockdev.c
> index 717785e..d10ab35 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -2286,17 +2286,14 @@ void qmp_eject(const char *device, bool has_force, bool force, Error **errp)
> }
>
> rc = do_open_tray(device, force, &local_err);
> - if (local_err) {
> + if (rc == -ENOSYS) {
> + error_free(local_err);
> + local_err = NULL;
> + } else if (local_err) {
> error_propagate(errp, local_err);
> return;
> }
>
> - if (rc == EINPROGRESS) {
> - error_setg(errp, "Device '%s' is locked and force was not specified, "
> - "wait for tray to open and try again", device);
> - return;
> - }
> -
So in this function, we still ignore ENOSYS, and the EINPROGRESS error
message has now moved to the helper function. No change in overall
behavior, good.
> qmp_x_blockdev_remove_medium(device, errp);
> }
>
> @@ -2348,8 +2345,8 @@ static int do_open_tray(const char *device, bool force, Error **errp)
> }
>
> if (!blk_dev_has_tray(blk)) {
> - /* Ignore this command on tray-less devices */
> - return ENOSYS;
> + error_setg(errp, "Device '%s' does not have a tray", device);
> + return -ENOSYS;
> }
>
> if (blk_dev_is_tray_open(blk)) {
> @@ -2366,7 +2363,9 @@ static int do_open_tray(const char *device, bool force, Error **errp)
> }
>
> if (locked && !force) {
> - return EINPROGRESS;
> + error_setg(errp, "Device '%s' is locked and force was not specified, "
> + "wait for tray to open and try again", device);
> + return -EINPROGRESS;
And here, we always return negative error.
Oops, you forgot to update the comments before this function, describing
its new (simpler) semantics.
> }
>
> return 0;
> @@ -2375,10 +2374,18 @@ static int do_open_tray(const char *device, bool force, Error **errp)
> void qmp_blockdev_open_tray(const char *device, bool has_force, bool force,
> Error **errp)
> {
> + Error *local_err = NULL;
> + int rc;
> +
> if (!has_force) {
> force = false;
> }
> - do_open_tray(device, force, errp);
> + rc = do_open_tray(device, force, &local_err);
> + if (local_err && (rc == -EINPROGRESS || rc == -ENOSYS)) {
The 'local_err &&' portion of the conditional is dead code. You could go
straight into the comparison of particular rc values.
> + error_free(local_err);
> + } else {
> + error_propagate(errp, local_err);
> + }
> }
>
> void qmp_blockdev_close_tray(const char *device, Error **errp)
>
This appears to be your first qemu patch - congratulations, and welcome
to the community.
Looking forward to v2.
--
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-06-03 19:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-03 18:20 [Qemu-devel] [PATCH] blockdev: fix error handling in do_open_tray clord
2016-06-03 19:02 ` Eric Blake [this message]
2016-06-03 19:13 ` 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=5751D44E.4060800@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=clord@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.