From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOrBT-0000oX-3F for qemu-devel@nongnu.org; Thu, 18 Oct 2012 10:34:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOrBQ-0002kM-NZ for qemu-devel@nongnu.org; Thu, 18 Oct 2012 10:34:51 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:54008) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOrBQ-0002kA-Jb for qemu-devel@nongnu.org; Thu, 18 Oct 2012 10:34:48 -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, 18 Oct 2012 10:34:47 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id B5C5638C8076 for ; Thu, 18 Oct 2012 10:34:44 -0400 (EDT) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q9IEYiV0277362 for ; Thu, 18 Oct 2012 10:34:44 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q9IEYi94023023 for ; Thu, 18 Oct 2012 10:34:44 -0400 Message-ID: <50801383.3070001@linux.vnet.ibm.com> Date: Thu, 18 Oct 2012 10:34:43 -0400 From: Corey Bryant MIME-Version: 1.0 References: <1350411046-2453-1-git-send-email-coreyb@linux.vnet.ibm.com> <507E3103.1020202@redhat.com> <507EBA60.9000000@redhat.com> <507EC84E.30106@redhat.com> <507EC8C2.4030807@redhat.com> In-Reply-To: <507EC8C2.4030807@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 4/4] qemu-config: Add new -add-fd command line option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: libvir-list@redhat.com, qemu-devel@nongnu.org On 10/17/2012 11:03 AM, Kevin Wolf wrote: > Am 17.10.2012 17:01, schrieb Eric Blake: >> On 10/17/2012 08:02 AM, Kevin Wolf wrote: >>> Am 17.10.2012 06:16, schrieb Eric Blake: >>>> I'm still seeing the corner case of: >>>> >>>> qemu-kvm -add-fd fd=3,set=1 -add-fd fd=4,set=2 4<&- >>>> >>>> where the dup(3) will populate fd 4 prior to the point where we get to >>>> process the -add-fd fd=4 command to notice that the user started >>>> qemu-kvm with fd 4 closed, and thus qemu will silently proceed to use >>>> the wrong fd. >>>> >>>> On the other hand, I'm not sure if that corner case is worth worrying >>>> about, or if we just chalk it up to user stupidity (aka libvirt >>>> programmer stupidity) if they did something like that (most likely, >>>> because the management app forgot to clear FD_CLOEXEC before exec()ing >>>> qemu-kvm). >>> >>> If you specify an FD number that isn't actually open when qemu is >>> stared, you can get any FD that qemu opens internally. I think the >>> correct answer to this problem is "then don't do that". >> >> Overnight, I realized we do have one potential safety valve: we are >> guaranteed that any fd inherited by the exec() of qemu-kvm has >> FD_CLOEXEC clear, and we also strive to have qemu open/dup all of its >> internal fds with FD_CLOEXEC set. Therefore, it may be worth a sanity >> check of fcntl(F_GETFD) to see if FD_CLOEXEC is set, and if so, the user >> must have failed to pass in the fd, and we are now looking at a qemu >> internal fd, and should therefore report failure. But I'm not sure if >> it's worth the extra code. > > Hm, this sounds actually easy enough. I'll leave the decision to Corey, > but I like the idea. Sure I can add this. -- Regards, Corey Bryant