From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sz6jV-00019W-SV for qemu-devel@nongnu.org; Wed, 08 Aug 2012 09:55:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sz6jU-00079O-97 for qemu-devel@nongnu.org; Wed, 08 Aug 2012 09:55:33 -0400 Received: from e38.co.us.ibm.com ([32.97.110.159]:37447) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sz6jU-00079I-20 for qemu-devel@nongnu.org; Wed, 08 Aug 2012 09:55:32 -0400 Received: from /spool/local by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 8 Aug 2012 07:55:30 -0600 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 0A5513E40047 for ; Wed, 8 Aug 2012 13:55:12 +0000 (WET) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q78DscAF144448 for ; Wed, 8 Aug 2012 07:54:55 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q78DsMMT031940 for ; Wed, 8 Aug 2012 07:54:22 -0600 Message-ID: <50226F8C.2020900@linux.vnet.ibm.com> Date: Wed, 08 Aug 2012 09:54:20 -0400 From: Corey Bryant MIME-Version: 1.0 References: <1344355108-14786-1-git-send-email-coreyb@linux.vnet.ibm.com> <1344355108-14786-7-git-send-email-coreyb@linux.vnet.ibm.com> <20120808130252.GA6532@stefanha-thinkpad.localdomain> In-Reply-To: <20120808130252.GA6532@stefanha-thinkpad.localdomain> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v7 6/6] block: Enable qemu_open/close to work with fd sets List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, aliguori@us.ibm.com, libvir-list@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, eblake@redhat.com On 08/08/2012 09:02 AM, Stefan Hajnoczi wrote: > On Tue, Aug 07, 2012 at 11:58:28AM -0400, Corey Bryant wrote: >> @@ -2566,6 +2567,92 @@ FdsetInfoList *qmp_query_fdsets(Error **errp) >> return fdset_list; >> } >> >> +int monitor_fdset_get_fd(int64_t fdset_id, int flags) >> +{ >> + mon_fdset_t *mon_fdset; >> + mon_fdset_fd_t *mon_fdset_fd; >> + int mon_fd_flags; >> + >> + QLIST_FOREACH(mon_fdset, &mon_fdsets, next) { >> + if (mon_fdset->id != fdset_id) { >> + continue; >> + } >> + QLIST_FOREACH(mon_fdset_fd, &mon_fdset->fds, next) { >> + if (mon_fdset_fd->removed) { >> + continue; >> + } > > This makes me wonder about immediately closing in remove-fd and drop the > removed field. This way, code using mon_fdset->fds does not need to > worry about removed=true fds. > > The reason we don't immediately close in remove-fd is so that the client doesn't have to keep track of what fd's are in use by QEMU. Let's say libvirt uses add-fd to add fd=4 (O_RDONLY) and fd=5 (O_RDWR) to fd set 2 and they both refer to /mnt/nfs/data.img. libvirt can then issue a command that uses the fd (e.g. drive_add file=/dev/fdsets/2). QEMU then opens and closes that file as it desires by dup'ing the fd in the fd set that has matching access mode (O_RDONLY or O_RDWR) and closing the dup'd fd. By not closing the fd immediately in remove-fd, we allow the client to issue a command like drive_open and immediately follow it with a remove-fd and not have to worry about determining when QEMU is done using the fd. -- Regards, Corey