Received: from eggs.gnu.org ([2001:4830:134:3::10]:54909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP9kE-0001xw-MS for qemu-devel@nongnu.org; Mon, 18 Jul 2016 10:42:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bP9kD-0000rn-L0 for qemu-devel@nongnu.org; Mon, 18 Jul 2016 10:42:06 -0400 References: <1468845016-43468-1-git-send-email-pasic@linux.vnet.ibm.com> From: Max Reitz Message-ID: Date: Mon, 18 Jul 2016 16:41:56 +0200 MIME-Version: 1.0 In-Reply-To: <1468845016-43468-1-git-send-email-pasic@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oVBfBVLXfxd3VUPr2thB98B80vr4Osm8P" 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) --oVBfBVLXfxd3VUPr2thB98B80vr4Osm8P From: Max Reitz To: Halil Pasic , qemu-block@nongnu.org Cc: Kevin Wolf , Cornelia Huck , qemu-devel@nongnu.org Message-ID: Subject: Re: [Qemu-block] [PATCH 1/1] block: improve error handling in raw_open References: <1468845016-43468-1-git-send-email-pasic@linux.vnet.ibm.com> In-Reply-To: <1468845016-43468-1-git-send-email-pasic@linux.vnet.ibm.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 18.07.2016 14:30, Halil Pasic wrote: > Make raw_open for POSIX more consistent in handling errors by setting > the error object also when qemu_open fails. The error object was > generally set in case of errors, but I guess this case was overlooked. > Do the same for win32. >=20 > Signed-off-by: Halil Pasic > Reviewed-by: Cornelia Huck > Reviewed-by: Sascha Silbe > Tested-by: Marc Hartmayer (POSIX only) >=20 > --- >=20 > Stumbled upon this (POSIX) while testing VMs with too many SCSI disks i= n > respect to my nofile limit. When open hits the nofile limit while tryin= g > to hotplug yet another SCSI disk via libvirt we end up with no adequate= > 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 unsure > whats the best way to deal with it. My guess right now is to make sure > we propagate errors at least until reaching code which is called only > QMP in context and handle communicating the error to the requester of > the operation there. Any suggestions or ideas? >=20 > 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(+) >=20 > 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, QD= ict *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? While ot= her 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 > 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 *op= tions, int flags, > } else { > ret =3D -EINVAL; > } > + error_setg_errno(errp, err, "Could not open file"); > goto fail; > } > =20 >=20 --oVBfBVLXfxd3VUPr2thB98B80vr4Osm8P 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 iQEvBAEBCAAZBQJXjOq0EhxtcmVpdHpAcmVkaGF0LmNvbQAKCRA7sUIC6DisrWrf B/oDmf3Is1iJ6B2V9g9NeDqzfGzgXwniQtPhVQRF5parq0fCz671wGnZV9QkCKJj 1R1g+kU26Qh7uLgrLcpp7hTDvgFC5AEWEC9YvVwMD5D0hOex4OeU7Iy8KAeKhwB4 24bSnFXv0ErlyG8v/eEaBB7Nq2uGlkZ0W8EYrzF/vh9CSIvR8UO/QrJCjZ2OhogO u5SBlKCUGspWLKPkLDm9xi0G2BpZO989FpK05LBuxRuwYC+lQsPjpsg5XbUQrnZW CSWvEDTNcz20Uptr7wjEEu6zJHPAS2Yk9Dp+q9ZtI0y9IR3yprHNCOTIXcc+plEP coOfXabO1lwRDSRl+HfQMBUm =m2hr -----END PGP SIGNATURE----- --oVBfBVLXfxd3VUPr2thB98B80vr4Osm8P--