From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8vYk-0002q3-9g for qemu-devel@nongnu.org; Fri, 03 Jun 2016 16:19:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8vYj-0006kn-0t for qemu-devel@nongnu.org; Fri, 03 Jun 2016 16:19:10 -0400 References: <1464982775-13067-1-git-send-email-clord@redhat.com> From: Eric Blake Message-ID: <5751E634.6010606@redhat.com> Date: Fri, 3 Jun 2016 14:19:00 -0600 MIME-Version: 1.0 In-Reply-To: <1464982775-13067-1-git-send-email-clord@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="UtFk0ruIKt7Pb12XhB8CwuSSSj1iMrp8e" Subject: Re: [Qemu-devel] [PATCH v2] blockdev: clean up error handling in do_open_tray List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Colin Lord , qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --UtFk0ruIKt7Pb12XhB8CwuSSSj1iMrp8e Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/03/2016 01:39 PM, Colin Lord wrote: > Returns negative error codes and accompanying error messages in cases w= here > the device has no tray or the tray is locked and isn't forced open. Thi= s > extra information should result in better flexibility in functions that= > call do_open_tray. >=20 > Signed-off-by: Colin Lord > --- > v2: fix function documentation, improve commit wording, and remove > unnecessary null check > blockdev.c | 36 +++++++++++++++++++++--------------- > 1 file changed, 21 insertions(+), 15 deletions(-) >=20 > +++ b/blockdev.c > @@ -2286,17 +2286,14 @@ void qmp_eject(const char *device, bool has_for= ce, bool force, Error **errp) > } > =20 > rc =3D do_open_tray(device, force, &local_err); > - if (local_err) { > + if (rc =3D=3D -ENOSYS) { > + error_free(local_err); > + local_err =3D NULL; > + } else if (local_err) { > error_propagate(errp, local_err); > return; > } > =20 > - if (rc =3D=3D EINPROGRESS) { > - error_setg(errp, "Device '%s' is locked and force was not spec= ified, " > - "wait for tray to open and try again", device); > - return; > - } > - > qmp_x_blockdev_remove_medium(device, errp); > } The local_err =3D NULL line is dead code, since nothing else references local_err before it goes out of scope. Maintainer could fix that on comm= it. > =20 > @@ -2325,10 +2322,9 @@ void qmp_block_passwd(bool has_device, const cha= r *device, > } > =20 > /** > - * returns -errno on fatal error, +errno for non-fatal situations. > - * errp will always be set when the return code is negative. > - * May return +ENOSYS if the device has no tray, > - * or +EINPROGRESS if the tray is locked and the guest has been notifi= ed. > + * returns -errno on all errors, and errp will be set on error > + * May return the non-fatal error codes -ENOSYS if the device has no t= ray, > + * or -EINPROGRESS if the tray is locked and the guest has been notifi= ed. Maybe: Callers may choose whether to treat -ENOSYS (device has no tray) or -EINPROGRESS (tray is locked but guest has been notified) as non-fatal errors. But what you have works, enough that I'm okay with: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --UtFk0ruIKt7Pb12XhB8CwuSSSj1iMrp8e Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXUeY0AAoJEKeha0olJ0NqWaAH/1K2Uj1TAFhrsftjI+EG9fdb 3oELe1JOaebjo6Bma2I06iHttXtQtIiApxtQUWSHieyrUVBkTHkqvVhi1iNATJ3d dgSq124tChK1g2zfVDQH/KLZeGe8ppGcVxEIB0ymFKvpxu1i1W3QNFRHyRAqI6/p /taIhfau4Py6QQrYD2ijRbvL3jhCT7R2u1Q4QNwYMRGnKxcDqg1d1X8GPXOwJKRe Re9gk686BvXftqRm2mPu26DS3H89b1WGeWMCluNeGDqNbkbRKiiipq4Wxf8JJ+Tt TlhGsuKTUMnZL95AVZytF75tNak4obe0ZfVZKchxBuMiD1HiuoYl6QMEEmmT4BM= =iDce -----END PGP SIGNATURE----- --UtFk0ruIKt7Pb12XhB8CwuSSSj1iMrp8e--