Received: from eggs.gnu.org ([2001:4830:134:3::10]:34446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bS6SH-0003jN-QM for qemu-devel@nongnu.org; Tue, 26 Jul 2016 13:47:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bS6SF-0005rh-Uz for qemu-devel@nongnu.org; Tue, 26 Jul 2016 13:47:44 -0400 References: <1468845016-43468-1-git-send-email-pasic@linux.vnet.ibm.com> <1469532873-78542-1-git-send-email-pasic@linux.vnet.ibm.com> <7c4bdb1e-f0aa-4a07-2780-37f4f92c6665@redhat.com> <57979B63.1060505@linux.vnet.ibm.com> From: Max Reitz Message-ID: Date: Tue, 26 Jul 2016 19:47:32 +0200 MIME-Version: 1.0 In-Reply-To: <57979B63.1060505@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="3kAGVUROvu2teToXDa5QaRjXM2K2Mk2Dj" Subject: Re: [Qemu-devel] [PATCH v2 1/1] block: improve error handling in raw_open List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Halil Pasic , qemu-block@nongnu.org Cc: Kevin Wolf , Cornelia Huck , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --3kAGVUROvu2teToXDa5QaRjXM2K2Mk2Dj From: Max Reitz To: Halil Pasic , qemu-block@nongnu.org Cc: Kevin Wolf , Cornelia Huck , qemu-devel@nongnu.org Message-ID: Subject: Re: [Qemu-devel] [PATCH v2 1/1] block: improve error handling in raw_open References: <1468845016-43468-1-git-send-email-pasic@linux.vnet.ibm.com> <1469532873-78542-1-git-send-email-pasic@linux.vnet.ibm.com> <7c4bdb1e-f0aa-4a07-2780-37f4f92c6665@redhat.com> <57979B63.1060505@linux.vnet.ibm.com> In-Reply-To: <57979B63.1060505@linux.vnet.ibm.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 26.07.2016 19:18, Halil Pasic wrote: >=20 >=20 > On 07/26/2016 05:42 PM, Max Reitz wrote: >>> +++ b/block/raw-posix.c >>>> @@ -485,6 +485,7 @@ static int raw_open_common(BlockDriverState *bs,= QDict *options, >>>> s->fd =3D -1; >>>> fd =3D qemu_open(filename, s->open_flags, 0644); >>>> if (fd < 0) { >>>> + error_setg_errno(errp, errno, "Could not open file"); >> We don't guarantee that error_setg_errno() does not modify errno. (In >> practice it should not, but we don't guarantee that.) >> >=20 >=20 > Thank you very much for your review. I have double checked, and I > remembered correctly: error_setg_errno saves and restores the original > errno, so that is why I assumed it does not.=20 >=20 >> Therefore, the common pattern is to save the errno value before callin= g >> this function, i.e. to put the function call... >> >>>> ret =3D -errno; >> ...here. >> >> With that fixed, the patch should be good. >> >> Max >> > =20 > But now that you have this pointed out, I understand, it is better to > have no function calls between failure and saving the errno. I will pos= t > a v3 and keep this in mind for the future. Sorry for the extra work. >=20 > Frankly, I'm a bit uncomfortable with asking (do not want to be pushy),= > but do you have an opinion on the 'error_report_err' issue (pointed > out in the cover letter part)? You are using drive_add with QMP? As far as I know, one can only do so with human-monitor-command which returns the error string like so: {"return": "Could not open file: No such file or directory\r\n"} Apart from that, as for QMP, in theory you're supposed to use blockdev-add and device_add, I think (although blockdev-add is still considered experimental...). And blockdev-add will return the error string like so: {"error": {"class": "GenericError", "desc": "Could not open file: No such file or directory"}} Max --3kAGVUROvu2teToXDa5QaRjXM2K2Mk2Dj 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 iQEvBAEBCAAZBQJXl6I0EhxtcmVpdHpAcmVkaGF0LmNvbQAKCRA7sUIC6Disrd3N B/9jfWPvBK1SmqpxSzY19vd0p4YI0mabb9GiilEzSifAS8MgkTzZxh5P9WghLV3x bCj3EX/zT7UMWb4lBlRgxYTOaQ3G2vuGy3ODSeTsJxfzM30DuaTXDI6EJbN+owID qpFplKnhYwiwoytLQYF7tjLeHCOwztQ5frCDtdCDLiabQaYiwflViI38fG0phoHd 8jHgbNtsmJOtNkNPx2SzQCoLb9o9rxQoLDEQHVsdPi/ryNDOwjhTUHLyyjjz45XI LngPtl/1RHHzT3Q+4B5FoSbJLQ6R0fyuCux3e1OamM+P3T2qT0c0svWO4uK6xuCV KqnxTHYTVxjj3OCStPRtelAJ =FiPJ -----END PGP SIGNATURE----- --3kAGVUROvu2teToXDa5QaRjXM2K2Mk2Dj--