From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0xKH-0003zy-0e for qemu-devel@nongnu.org; Mon, 13 Aug 2012 12:17:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T0xKB-0004kL-KZ for qemu-devel@nongnu.org; Mon, 13 Aug 2012 12:17:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60597) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0xKB-0004jn-CX for qemu-devel@nongnu.org; Mon, 13 Aug 2012 12:17:03 -0400 Message-ID: <50292876.60808@redhat.com> Date: Mon, 13 Aug 2012 10:16:54 -0600 From: Eric Blake MIME-Version: 1.0 References: <1344690878-1555-1-git-send-email-coreyb@linux.vnet.ibm.com> <1344690878-1555-7-git-send-email-coreyb@linux.vnet.ibm.com> <50266C28.6070908@redhat.com> <502904C6.6050903@linux.vnet.ibm.com> In-Reply-To: <502904C6.6050903@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig41FCBE905E13CCB2CD201336" Subject: Re: [Qemu-devel] [PATCH v9 6/7] block: Enable qemu_open/close to work with fd sets List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Corey Bryant Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com, libvir-list@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig41FCBE905E13CCB2CD201336 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 08/13/2012 07:44 AM, Corey Bryant wrote: > I'll send a new version shortly with these updates also. >=20 >>> + >>> + ret =3D monitor_fdset_dup_fd_add(fdset_id, dupfd); >>> + if (ret =3D=3D -1) { >>> + close(dupfd); >>> + return -1; >> >> This function appears to promise a reasonable errno on failure. Actually, looking at that function again, +int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd) +{ + MonFdset *mon_fdset; + MonFdsetFd *mon_fdset_fd_dup; + + QLIST_FOREACH(mon_fdset, &mon_fdsets, next) { + if (mon_fdset->id !=3D fdset_id) { + continue; + } + QLIST_FOREACH(mon_fdset_fd_dup, &mon_fdset->dup_fds, next) { + if (mon_fdset_fd_dup->fd =3D=3D dup_fd) { + return -1; + } + } + mon_fdset_fd_dup =3D g_malloc0(sizeof(*mon_fdset_fd_dup)); + mon_fdset_fd_dup->fd =3D dup_fd; + QLIST_INSERT_HEAD(&mon_fdset->dup_fds, mon_fdset_fd_dup, next); + return 0; + } + return -1; +} The only way it could fail is if we are trying to add an fd that is already in the set, or if we don't find mon_fdset; both of which would indicate logic bugs earlier in our program. Would it be worth asserting that these conditions are impossible, and making this function return void (the addition is always successful if it returns, since g_malloc0 aborts rather than failing with ENOMEM)? And the more I think about it, the more I think that qemu_open MUST provide a sane errno value on exit, so you need to make sure that all exit paths out of qemu_open have a sensible errno (whether or not the helper functions also have to leave errno sane is a matter of taste). --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig41FCBE905E13CCB2CD201336 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.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEbBAEBCAAGBQJQKSh2AAoJEKeha0olJ0NqChgH9R66feyJLETaBtAeE5JHpBsU QIlcWfZCoPKjfhjzjwiIIjdad8D1yoNp46ZeX7jiJ4iSe/jFG7n+nz41ZS4cMMP6 hcSKefaeE9mYN+SFqml/hVFvt1z9lE6VQ0et7VMKuWAfoxdIlYEDAJXS3LkWMpXS HW2Cl+4jAW+mHpQ+0+1w0vijjYU2IzASLVN3lxZBJrEAIBbH1Mo6t/gB/Ucs3HM+ 5u+Qks/xa7R6//u937MY0+aSXmPR6LIC8ookySglv+1N2ct73DNrqIKls2nRcfy6 4UsvZ+DqXJz9CTKwNXaHvsttRLn9/iRG+qdBNB/FJEId+Xbo/hRtiQ1XMHO/xg== =KK9C -----END PGP SIGNATURE----- --------------enig41FCBE905E13CCB2CD201336--