From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTycO-0001Le-SE for qemu-devel@nongnu.org; Tue, 16 Sep 2014 15:40:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XTycK-0003PM-CJ for qemu-devel@nongnu.org; Tue, 16 Sep 2014 15:40:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47185) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTycK-0003NS-4U for qemu-devel@nongnu.org; Tue, 16 Sep 2014 15:40:48 -0400 Message-ID: <54189228.6090907@redhat.com> Date: Tue, 16 Sep 2014 13:40:24 -0600 From: Eric Blake MIME-Version: 1.0 References: <1410890642-6704-1-git-send-email-cnanakos@grnet.gr> <1410890642-6704-2-git-send-email-cnanakos@grnet.gr> In-Reply-To: <1410890642-6704-2-git-send-email-cnanakos@grnet.gr> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="bQJlTh8fOK8e3NTTsoiOti1BxoB1JImVX" Subject: Re: [Qemu-devel] [PATCH v3] async: aio_context_new(): Handle event_notifier_init failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chrysostomos Nanakos , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pingfank@linux.vnet.ibm.com, famz@redhat.com, benoit@irqsave.net, jan.kiszka@siemens.com, stefanha@redhat.com, mjt@tls.msk.ru, kroosec@gmail.com, sw@weilnetz.de, pbonzini@redhat.com, afaerber@suse.de, aliguori@amazon.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --bQJlTh8fOK8e3NTTsoiOti1BxoB1JImVX Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/16/2014 12:04 PM, Chrysostomos Nanakos wrote: > If event_notifier_init fails QEMU exits without printing > any error information to the user. This commit adds an error > message on failure: >=20 > # qemu [...] Showing the actual command line you used would be helpful. > qemu: Failed to initialize event notifier: Too many open files in syst= em >=20 > Signed-off-by: Chrysostomos Nanakos > --- > async.c | 16 +++++++++++----- > include/block/aio.h | 2 +- > include/qemu/main-loop.h | 2 +- > iothread.c | 11 ++++++++++- > main-loop.c | 9 +++++++-- > qemu-img.c | 8 +++++++- > qemu-io.c | 7 ++++++- > qemu-nbd.c | 6 +++++- > tests/test-aio.c | 10 +++++++++- > tests/test-thread-pool.c | 10 +++++++++- > tests/test-throttle.c | 10 +++++++++- > vl.c | 5 +++-- > 12 files changed, 78 insertions(+), 18 deletions(-) >=20 > -AioContext *aio_context_new(void) > +AioContext *aio_context_new(Error **errp) > { > + int ret; > AioContext *ctx; > ctx =3D (AioContext *) g_source_new(&aio_source_funcs, sizeof(AioC= ontext)); > + ret =3D event_notifier_init(&ctx->notifier, false); > + if (ret < 0) { > + g_source_destroy(&ctx->source); Does g_source_destroy() guarantee that errno is unmolested? If not, > + error_setg_errno(errp, -ret, "Failed to initialize event notif= ier"); then this logs the wrong error. Swap the lines to be safe. > + return NULL; > + } > + aio_set_event_notifier(ctx, &ctx->notifier, > + (EventNotifierHandler *) > + event_notifier_test_and_clear); > ctx->pollfds =3D g_array_new(FALSE, FALSE, sizeof(GPollFD)); > ctx->thread_pool =3D NULL; > qemu_mutex_init(&ctx->bh_lock); > rfifolock_init(&ctx->lock, aio_rfifolock_cb, ctx); > - event_notifier_init(&ctx->notifier, false); Is hoisting the event notifier init to occur before the mutex init going to cause any grief? > +++ b/main-loop.c > @@ -138,8 +139,12 @@ int qemu_init_main_loop(void) > return ret; > } > =20 > + qemu_aio_context =3D aio_context_new(&local_error); > + if (!qemu_aio_context) { > + error_propagate(errp, local_error); > + return -1; > + } Can the earlier call to qemu_signal_init() consume any resources that are now leaked? > @@ -205,10 +206,17 @@ static void test_cancel(void) > int main(int argc, char **argv) > { > int ret; > + Error *local_error; > =20 > init_clocks(); > =20 > - ctx =3D aio_context_new(); > + ctx =3D aio_context_new(&local_error); > + if (!ctx) { > + error_report("Failed to create AIO Context: \'%s\'", Use of \' inside "" is unusual. (Multiple times in your patch) --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --bQJlTh8fOK8e3NTTsoiOti1BxoB1JImVX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJUGJIoAAoJEKeha0olJ0NqYHQIAINNqKLvrv4HoK9SeDZubKuf DHSbZ4kSGQIYt/1B4cNSchGQtj+pvHPkA/Xd+gqXcmNb1e1CP0kfYzqA4eo3bgAk jmRQCqCfQl8uAqi3unzQ9VOW26sS9FuRZ6t5SPhnHhMfxnJg2kRwwUNFspeAcXEo 53iNjjG4mZTqWEVwQCEID4UnX+ROkrocxYcjhDGm2K56k2SjC2jXLzyQTvfjuzm/ LwsD1TwLL3Kk3M0Ex1UxHzPJe8ZChMICHAf4hq9IEv+xbe2iDNDzSEPIhZ5MUEr/ 7TD+gLzuGhvZo64MhUBGX8vLGfOiitzqDkd3cJ+lpgz/kZTZ12ugSN5KO4D3m7I= =UhnJ -----END PGP SIGNATURE----- --bQJlTh8fOK8e3NTTsoiOti1BxoB1JImVX--