From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M90kj-0007Dq-S0 for qemu-devel@nongnu.org; Tue, 26 May 2009 13:47:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M90kf-000799-Fb for qemu-devel@nongnu.org; Tue, 26 May 2009 13:47:53 -0400 Received: from [199.232.76.173] (port=54731 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M90kf-00078q-8P for qemu-devel@nongnu.org; Tue, 26 May 2009 13:47:49 -0400 Received: from fleet.cs.ualberta.ca ([129.128.22.22]:48077) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M90ke-0003iP-O7 for qemu-devel@nongnu.org; Tue, 26 May 2009 13:47:49 -0400 Received: from fleet.cs.ualberta.ca (localhost.localdomain [127.0.0.1]) by fleet-spampd (Postfix) with ESMTP id 8B7C328012 for ; Tue, 26 May 2009 11:47:38 -0600 (MDT) Message-ID: <4A1C2B3A.7070209@cs.ualberta.ca> Date: Tue, 26 May 2009 11:47:38 -0600 From: Cam Macdonell MIME-Version: 1.0 Subject: Re: [Qemu-devel] Passing fds through a qemu char device References: <4A172800.8080406@cs.ualberta.ca> <4A175B21.6010306@codemonkey.ws> In-Reply-To: <4A175B21.6010306@codemonkey.ws> 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: Anthony Liguori Cc: qemu-devel@nongnu.org Anthony Liguori wrote: > Cam Macdonell wrote: >> >> Hi, >> >> I'm trying to pass eventfds between qemu processes and I'm trying to >> use a qemu char device to do this. AFAICT with a qemu_chr_device the >> polling handler only has support to call read()/write(), not >> send/recvmsg() which are necessary to send and receive fds with >> SCM_RIGHTS through the socket. Is this true or is there support in >> Qemu for recvmsg() that I'm not seeing? > > The TCP/Unix implementations for CharDriverState use send/recv. You can > convert the recv path to always use recvmsg() and introduce an > qemu_chr_ioctl() to pass/recv fds. If I understand you correctly, you are suggesting replacing recv() with recvmsg() for all qemu char devices? I would prefer a way to change a particular char device to use recvmsg instead of recv, and then create qemu_chr_device out of the received fds as needed. I think this would minimize the changes to the existing char device code. Currently, I can't see how to change to recvmsg for an individual char device without changing tcp_chr_read(void * opaque) in qemu-char.c (which would affect all tcp char devices). > You can be smart about storing the recv'd fd in the char driver state > and that would allow qemu_chr_ioctl(CHR_IOCTL_GET_FD) to not block. > qemu_chr_ioctl(CHR_IOCTL_SET_FD) would set the fd to be sent for the > next qemu_chr_write() operation. My goal is to support receiving several fds to support eventfd notification between multiple guests (the list of fds would come from an external server). As I mentioned, I would like the qemu process to create additonal char devices for each recv'd fd as this would save modifying the char driver state. > > Just a thought, other interfaces could also work. > Thanks, it is helpful. Cam