From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MOYyj-0005tG-8w for qemu-devel@nongnu.org; Wed, 08 Jul 2009 11:22:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MOYye-0005nT-Gl for qemu-devel@nongnu.org; Wed, 08 Jul 2009 11:22:36 -0400 Received: from [199.232.76.173] (port=60126 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MOYye-0005nH-BQ for qemu-devel@nongnu.org; Wed, 08 Jul 2009 11:22:32 -0400 Received: from mx2.redhat.com ([66.187.237.31]:47317) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MOYyd-0005AW-VA for qemu-devel@nongnu.org; Wed, 08 Jul 2009 11:22:32 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n68FMUEf008820 for ; Wed, 8 Jul 2009 11:22:30 -0400 Message-ID: <4A54BA4D.4040809@redhat.com> Date: Wed, 08 Jul 2009 18:25:01 +0300 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/5] Add SCM_RIGHTS support to unix socket character devices References: <1247064963.3270.63.camel@blaa> <1247065048-15706-1-git-send-email-markmc@redhat.com> <1247065048-15706-2-git-send-email-markmc@redhat.com> In-Reply-To: <1247065048-15706-2-git-send-email-markmc@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark McLoughlin Cc: qemu-devel@nongnu.org On 07/08/2009 05:57 PM, Mark McLoughlin wrote: > If a file descriptor is passed via a message with SCM_RIGHTS ancillary > data on a unix socket, store the file descriptor for use in the > chr_read() handler. Close the file descriptor if it was not used. > > The qemu_chr_get_msgfd() API provides access to the passed descriptor. > > Signed-off-by: Mark McLoughlin > --- > qemu-char.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ > qemu-char.h | 2 ++ > 2 files changed, 52 insertions(+), 0 deletions(-) > > diff --git a/qemu-char.c b/qemu-char.c > index e0d7220..f06a614 100644 > --- a/qemu-char.c > +++ b/qemu-char.c > @@ -168,6 +168,11 @@ void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len) > s->chr_read(s->handler_opaque, buf, len); > } > > +int qemu_chr_get_msgfd(CharDriverState *s) > +{ > + return s->get_msgfd ? s->get_msgfd(s) : -1; > +} > + > void qemu_chr_accept_input(CharDriverState *s) > { > if (s->chr_accept_input) > @@ -1832,6 +1837,7 @@ typedef struct { > int do_telnetopt; > int do_nodelay; > int is_unix; > + int msgfd; > } TCPCharDriver; > SCM_RIGHTS messages can contain multiple fds, and multiple messages can arrive. I think you need to queue fds here in case the client sends two getfd commands back-to-back and does buffering. -- error compiling committee.c: too many arguments to function