From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwxqL-000271-E0 for qemu-devel@nongnu.org; Thu, 02 Aug 2012 12:01:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SwxqF-0000zc-CC for qemu-devel@nongnu.org; Thu, 02 Aug 2012 12:01:45 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:37127) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwxqF-0000zU-82 for qemu-devel@nongnu.org; Thu, 02 Aug 2012 12:01:39 -0400 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 2 Aug 2012 12:01:35 -0400 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 80C3D38C9AE9 for ; Thu, 2 Aug 2012 11:08:53 -0400 (EDT) Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q72F8fSt21561384 for ; Thu, 2 Aug 2012 11:08:41 -0400 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q72F8SIE028377 for ; Thu, 2 Aug 2012 09:08:29 -0600 Message-ID: <501A97E8.9000705@linux.vnet.ibm.com> Date: Thu, 02 Aug 2012 11:08:24 -0400 From: Corey Bryant MIME-Version: 1.0 References: <1343048885-1701-1-git-send-email-coreyb@linux.vnet.ibm.com> <1343048885-1701-7-git-send-email-coreyb@linux.vnet.ibm.com> <50104C44.1050206@redhat.com> <5010C031.9040602@linux.vnet.ibm.com> In-Reply-To: <5010C031.9040602@linux.vnet.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 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: Eric Blake Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com, libvir-list@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com On 07/25/2012 11:57 PM, Corey Bryant wrote: > > > On 07/25/2012 03:43 PM, Eric Blake wrote: >> On 07/23/2012 07:08 AM, Corey Bryant wrote: >>> When qemu_open is passed a filename of the "/dev/fdset/nnn" >>> format (where nnn is the fdset ID), an fd with matching access >>> mode flags will be searched for within the specified monitor >>> fd set. If the fd is found, a dup of the fd will be returned >>> from qemu_open. >>> >>> Each fd set has a reference count. The purpose of the reference >>> count is to determine if an fd set contains file descriptors that >>> have open dup() references that have not yet been closed. It is >>> incremented on qemu_open and decremented on qemu_close. It is >>> not until the refcount is zero that file desriptors in an fd set >>> can be closed. If an fd set has dup() references open, then we >>> must keep the other fds in the fd set open in case a reopen >>> of the file occurs that requires an fd with a different access >>> mode. >>> >> >>> +++ b/monitor.c >>> @@ -2551,6 +2551,91 @@ static void monitor_fdsets_set_in_use(Monitor >>> *mon, bool in_use) >>> } >>> } >>> >>> +void monitor_fdset_increment_refcount(Monitor *mon, int64_t fdset_id) >>> +{ >>> + mon_fdset_t *mon_fdset; >>> + >>> + if (!mon) { >>> + return; >>> + } >> >> Am I reading this code right by stating that 'if there is no monitor, we >> don't increment the refcount'? How does a monitor reattach affect >> things? Or am I missing something fundamental about the cases when >> 'mon==NULL' will exist? >> > > Yes you're reading this correctly. > > I'm pretty sure that mon will only be NULL if QEMU is started without a > monitor. > > If QEMU has a monitor, and libvirt disconnects it's connection to the > qemu monitor, then I believe mon will remain non-NULL. I've verified this to be true and everything is working as expected. If libvirt's connection to the monitor fd is closed, mon will remain non-NULL and the refcount will still be incremented/decremented on qemu_open()/qemu_close(). When libvirt reconnects, any fdsets that haven't been cleaned up will still be available. query-fdsets can be used to determine what's available. -- Regards, Corey