From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0CUY-00057C-Lx for qemu-devel@nongnu.org; Sat, 11 Aug 2012 10:16:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T0CUV-00067K-UB for qemu-devel@nongnu.org; Sat, 11 Aug 2012 10:16:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T0CUV-00067F-M7 for qemu-devel@nongnu.org; Sat, 11 Aug 2012 10:16:35 -0400 Message-ID: <50266938.7000003@redhat.com> Date: Sat, 11 Aug 2012 08:16:24 -0600 From: Eric Blake MIME-Version: 1.0 References: <1344690878-1555-1-git-send-email-coreyb@linux.vnet.ibm.com> <1344690878-1555-3-git-send-email-coreyb@linux.vnet.ibm.com> In-Reply-To: <1344690878-1555-3-git-send-email-coreyb@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig67DA6C62D5F8235E100C4B48" Subject: Re: [Qemu-devel] [PATCH v9 2/7] qapi: Introduce add-fd, remove-fd, query-fdsets 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) --------------enig67DA6C62D5F8235E100C4B48 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 08/11/2012 07:14 AM, Corey Bryant wrote: > This patch adds support that enables passing of file descriptors > to the QEMU monitor where they will be stored in specified file > descriptor sets. >=20 >=20 > v9: > -Use fdset-id rather than fdset_id. (eblake@redhat.com) > -Update example for query-fdsets. (eblake@redhat.com) > -Close fd immediately on remove-fd. > (kwolf@redhat.com, eblake@redhat.com) > -Drop fdset refcount, and check dup_fds instead (in a later patch). > (eblake@redhat.com) > -Move mon_refcount code to a later patch. (kwolf@redhat.com) >=20 > +AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdset_id, bool has_op= aque, > + const char *opaque, Error **errp) > +{ > + int fd; > + Monitor *mon =3D cur_mon; > + MonFdset *mon_fdset; > + MonFdsetFd *mon_fdset_fd; > + AddfdInfo *fdinfo; > + > + fd =3D qemu_chr_fe_get_msgfd(mon->chr); > + if (fd =3D=3D -1) { > + error_set(errp, QERR_FD_NOT_SUPPLIED); > + goto error; > + } > + > + if (has_fdset_id) { > + QLIST_FOREACH(mon_fdset, &mon_fdsets, next) { > + if (mon_fdset->id =3D=3D fdset_id) { > + break; > + } > + } > + if (mon_fdset =3D=3D NULL) { > + error_set(errp, QERR_INVALID_PARAMETER_VALUE, "fdset-id", > + "an existing fdset-id or no fdset-id"); The 'no fdset-id' portion of this error message doesn't make sense - it can only be reached if has_fdset_id was true. > + > +void qmp_remove_fd(int64_t fdset_id, bool has_fd, int64_t fd, Error **= errp) > +{ > + MonFdset *mon_fdset; > + MonFdsetFd *mon_fdset_fd; > + char fd_str[60]; > + > + QLIST_FOREACH(mon_fdset, &mon_fdsets, next) { =2E.. > + } > + > +error: > + snprintf(fd_str, sizeof(fd_str), > + "fdset-id:%" PRId64 ", fd:%" PRId64, fdset_id, fd); Oops - fd is uninitialized if has_fd is false and the outer loop failed to find fdset_id. You need two separate error messages here, based on whether fd was provided. > +-> { "execute": "query-fdsets" } > +<- { "return": [ > + { > + "fds": [ > + { > + "fd": 30, > + "opaque": "rdonly:/path/to/file" > + }, > + { > + "fd": 24, > + "opaque": "rdwr:/path/to/file" > + } > + ], > + "fdset-id": 1 > + }, > + { > + "fds": [ > + { > + "fd": 28 > + }, > + { > + "fd": 29 > + } > + ], > + "fdset-id": 0 > + }, No trailing comma here. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig67DA6C62D5F8235E100C4B48 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/ iQEcBAEBCAAGBQJQJmk6AAoJEKeha0olJ0Nqdu4IAJNb1xSRqIRFH6QGTr3hVj/U dyW4XmjXmzTX8/k+FcOVjxdbOzLWDncEH0Nhs0FDgkXyUyE5ny25S6E+K2Ublrkk EQABj7lGKmBsmU85vB/AHpnoSVPESeKLF/9VKKkx6fkk0Yi4ZDUEDwEOKs7pC+By LqGLyX5/qfSp/d3ZUDiyGHuKbQmWf3OqfHMCiJz8NLsaAUaOEhIOWvYc+woEzT2Q uZ6cz2NGP5mmXFcZThzYVWFdcJJdFVK27ieowqwxNJtLwD2PwCNyjnZgFcAwaKAs ITElUhyKPJx+DOL96IGwJF4mASa9YsHbx2stJLr11llihgPNfv+OGQsAOaawJN0= =jdbu -----END PGP SIGNATURE----- --------------enig67DA6C62D5F8235E100C4B48--