From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMMmL-0000Q5-RV for qemu-devel@nongnu.org; Thu, 11 Oct 2012 13:42:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMMmF-0003yP-Hl for qemu-devel@nongnu.org; Thu, 11 Oct 2012 13:42:37 -0400 Received: from e4.ny.us.ibm.com ([32.97.182.144]:32932) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMMmF-0003y9-EA for qemu-devel@nongnu.org; Thu, 11 Oct 2012 13:42:31 -0400 Received: from /spool/local by e4.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 11 Oct 2012 13:42:30 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q9BHaurM152756 for ; Thu, 11 Oct 2012 13:36:56 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q9BHaudX026692 for ; Thu, 11 Oct 2012 13:36:56 -0400 Message-ID: <507703B7.1040801@linux.vnet.ibm.com> Date: Thu, 11 Oct 2012 13:36:55 -0400 From: Corey Bryant MIME-Version: 1.0 References: <1349878805-16352-1-git-send-email-coreyb@linux.vnet.ibm.com> <1349878805-16352-4-git-send-email-coreyb@linux.vnet.ibm.com> <5075F727.1060608@redhat.com> <5076DB6C.7040003@linux.vnet.ibm.com> <5076EBE2.6090909@redhat.com> In-Reply-To: <5076EBE2.6090909@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 3/3] qemu-config: Add new -add-fd command line option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, libvir-list@redhat.com, qemu-devel@nongnu.org On 10/11/2012 11:55 AM, Eric Blake wrote: > On 10/11/2012 08:45 AM, Corey Bryant wrote: > >>> Another missing validation check is for duplicate use. With the monitor >>> command, you ALWAYS have a unique fd (thanks to SCM_RIGHTS). But with >>> the command line, I can type 'qemu -add-fd fd=4,set=1 -add-fd >>> fd=4,set=2'. Oops - I've now corrupted your set layout, unless you >>> validate that every fd requested in -add-fd does not already reside in >>> any existing set. >>> >> >> I don't see this validation check for duplicate use of fd's being >> necessary. Like you say below, in the QMP add-fd case we can add the >> same fd multiple times. So we should be able to add the same fd >> multiple times via the command line. The only difference between QMP >> and command line in this case is that the QMP fd is a dup and therefore >> a different number and the command line fd will be the same fd. I'd >> prefer to leave this alone unless there's a compelling reason to block >> adding of the same fd. > > There is a compelling reason to prevent duplicates among your sets: > qemu_close(). > > Suppose I add fd 4 into set 1 and 2, and then discard set 2 via monitor > commands. Then, when qemu_close() drops the last reference to set 2, it > steps through and calls close() on all fds in that set, including fd 4. > Oops - now set 1 is invalid, because it is tracking a closed fd. And > worse, if qemu then does something else to open a new fd, it will get fd > 4 again, and now set 1 will be tracking the WRONG fd. > Ah yes, that is compelling. So we do need something here. I'll reply to your other email regarding the approach to take. -- Regards, Corey Bryant