Received: from eggs.gnu.org ([2001:4830:134:3::10]:34166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQiVb-0007pN-00 for qemu-devel@nongnu.org; Fri, 22 Jul 2016 18:01:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQiVY-0003oH-Cl for qemu-devel@nongnu.org; Fri, 22 Jul 2016 18:01:26 -0400 References: <1468845016-43468-1-git-send-email-pasic@linux.vnet.ibm.com> <578CFA57.3080806@linux.vnet.ibm.com> <578D0C15.40706@linux.vnet.ibm.com> From: Max Reitz Message-ID: <0cb8e4ee-7f09-a1a9-e86d-adb8c7e4cfb3@redhat.com> Date: Sat, 23 Jul 2016 00:01:13 +0200 MIME-Version: 1.0 In-Reply-To: <578D0C15.40706@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0EGI5Hg5gcmb5gsKuRMXBNdrfBT6cWw8k" Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 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) --0EGI5Hg5gcmb5gsKuRMXBNdrfBT6cWw8k From: Max Reitz To: Halil Pasic , qemu-block@nongnu.org Cc: Kevin Wolf , Cornelia Huck , qemu-devel@nongnu.org Message-ID: <0cb8e4ee-7f09-a1a9-e86d-adb8c7e4cfb3@redhat.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 1/1] block: improve error handling in raw_open References: <1468845016-43468-1-git-send-email-pasic@linux.vnet.ibm.com> <578CFA57.3080806@linux.vnet.ibm.com> <578D0C15.40706@linux.vnet.ibm.com> In-Reply-To: <578D0C15.40706@linux.vnet.ibm.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 18.07.2016 19:04, Halil Pasic wrote: >=20 >=20 > On 07/18/2016 05:57 PM, Max Reitz wrote: >> On 18.07.2016 17:48, Halil Pasic wrote: >>> >>> >>> On 07/18/2016 04:41 PM, Max Reitz wrote: >>>> On 18.07.2016 14:30, Halil Pasic wrote: >>>>> Make raw_open for POSIX more consistent in handling errors by setti= ng >>>>> the error object also when qemu_open fails. The error object was >>>>> generally set in case of errors, but I guess this case was overlook= ed. >>>>> Do the same for win32. >>>>> >>>>> Signed-off-by: Halil Pasic >>>>> Reviewed-by: Cornelia Huck >>>>> Reviewed-by: Sascha Silbe >>>>> Tested-by: Marc Hartmayer (POSIX only= ) >>>>> >>>>> --- >>>>> >>>>> Stumbled upon this (POSIX) while testing VMs with too many SCSI dis= ks in >>>>> respect to my nofile limit. When open hits the nofile limit while t= rying >>>>> to hotplug yet another SCSI disk via libvirt we end up with no adeq= uate >>>>> error message (one stating too many files). Sadly this patch in not= >>>>> sufficient to fix this problem because drive_new (/qemu/blockdev.c)= >>>>> handles errors using error_report_err which is documented as not to= be >>>>> used in QMP context. Do not have a patch for that, because I'm unsu= re >>>>> whats the best way to deal with it. My guess right now is to make s= ure >>>>> we propagate errors at least until reaching code which is called o= nly >>>>> QMP in context and handle communicating the error to the requester = of >>>>> the operation there. Any suggestions or ideas? >>>>> >>>>> The win32 part was not tested, and the sole reason I touched it is >>>>> to not introduce unnecessary divergence. >>>>> --- >>>>> block/raw-posix.c | 1 + >>>>> block/raw-win32.c | 1 + >>>>> 2 files changed, 2 insertions(+) >>>>> >>>>> diff --git a/block/raw-posix.c b/block/raw-posix.c >>>>> index c979ac3..4a7056e 100644 >>>>> --- a/block/raw-posix.c >>>>> +++ b/block/raw-posix.c >>>>> @@ -489,6 +489,7 @@ static int raw_open_common(BlockDriverState *bs= , QDict *options, >>>>> if (ret =3D=3D -EROFS) { >>>>> ret =3D -EACCES; >>>>> } >>>>> + error_setg_errno(errp, -ret, "Could not open file"); >>>> >>>> How about putting this above the "if (ret =3D=3D -EROFS)" block? Whi= le other >>>> parts of qemu may want to treat EROFS and EACCES in the same way, I >>>> think it makes sense to distinguish both cases in messages meant for= a >>>> human user. >>>> >>>> Max >>> >>> >>> Thanks for the comment! >>> >>> Have no strong opinion here. AFAIU the errno argument is only used to= >>> generate a message so there should be no consistency issue, and it wo= uld >>> be more consistent with the win32. How about moving both (posix and >>> win32) before the conditional statements readjusting the return value= >>> and use errno and err directly? >> >> Regarding win32, the issue is that we don't get an errno value but a >> Windows-specific error value from GetLastError(). I don't think >> error_setg_errno() understands those values. Therefore, for win32 we >=20 > Of course you are right regarding the nature of the error code for win3= 2. > Was not aware of that :/, so the win32 part was completely broken.=20 >=20 >> don't have much choice but to use the "preprocessed" errno value. >> >=20 > We could use error_setg_win32 with the return value of GetLastError(). > It basically uses=20 > https://developer.gnome.org/glib/stable/glib-Windows-Compatibility-Func= tions.html#g-win32-error-message > to get a message string from the error code. Would that be OK with you?= Oh, I didn't even know we had that. That's nice. Yes, please go ahead! Max >> I don't really see a consistency issue. It's just a human-readable err= or >> message and I think we should be as specific as we can be; it's just >> that it depends on the OS how much that is. >> >=20 > I agree. Wanted to say the same regarding consistency ;). Sorry if it d= id > not came across. >=20 > Thanks again for the catches! >=20 > Halil > =20 >> Max >> >>> >>> Cheers, >>> Halil >>> >>>> >>>>> goto fail; >>>>> } >>>>> s->fd =3D fd; >>>>> diff --git a/block/raw-win32.c b/block/raw-win32.c >>>>> index 62edb1a..f324f4e 100644 >>>>> --- a/block/raw-win32.c >>>>> +++ b/block/raw-win32.c >>>>> @@ -342,6 +342,7 @@ static int raw_open(BlockDriverState *bs, QDict= *options, int flags, >>>>> } else { >>>>> ret =3D -EINVAL; >>>>> } >>>>> + error_setg_errno(errp, err, "Could not open file"); >>>>> goto fail; >>>>> } >>>>> =20 >>>>> >>>> >>>> >>> >> >> >=20 --0EGI5Hg5gcmb5gsKuRMXBNdrfBT6cWw8k 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 iQEvBAEBCAAZBQJXkpepEhxtcmVpdHpAcmVkaGF0LmNvbQAKCRA7sUIC6DisrQ1O CACItP67BOb3KXP+/07OM+58MgAwqePoGp+nhyyVVKpGIe1zECuXW2b+lYCGEB3B X0m5eNKhTTmyuuF+T6cCPhhM0+cw+SQSIoVSSauOh5X6lcPb+0SaUJGnIgzw7MeC XMDqHEonfGksxynD0EeYSRw4D1vfmd30Xp+ss/d0+VLQyYvGKP3L2+FJGKREIiym WSxpP4Lu3A4s4PGAMH9x6k0oMwBf0mGick4PXSr/h6SUCsoI0EWR0h+iYKmsLDn7 8icuB+NwmJfwTMjGH+3cEYjj9wpE3PDofkdbBqnEYaaJ41ZfQgdbGbEi9bxHs9hf LYJSB4uu1TK+D3QbSnnJlQMv =P7vr -----END PGP SIGNATURE----- --0EGI5Hg5gcmb5gsKuRMXBNdrfBT6cWw8k--