From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgyyX-0004zO-0p for qemu-devel@nongnu.org; Tue, 19 Jun 2012 10:00:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SgyyQ-0007qP-KB for qemu-devel@nongnu.org; Tue, 19 Jun 2012 10:00:08 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]:45839) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgyyQ-0007mt-DX for qemu-devel@nongnu.org; Tue, 19 Jun 2012 10:00:02 -0400 Received: from /spool/local by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 19 Jun 2012 07:59:57 -0600 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 4982719D805C for ; Tue, 19 Jun 2012 13:59:44 +0000 (WET) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5JDxbWg085714 for ; Tue, 19 Jun 2012 07:59:38 -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 q5JDxVTY008251 for ; Tue, 19 Jun 2012 07:59:31 -0600 Message-ID: <4FE085C1.8000905@linux.vnet.ibm.com> Date: Tue, 19 Jun 2012 09:59:29 -0400 From: Corey Bryant MIME-Version: 1.0 References: <1339689305-27031-1-git-send-email-coreyb@linux.vnet.ibm.com> <1339689305-27031-4-git-send-email-coreyb@linux.vnet.ibm.com> <4FDB51E8.8060406@redhat.com> <4FDB7C1B.8020802@linux.vnet.ibm.com> <4FDB82F9.8020708@redhat.com> <4FDB8AAC.3030002@linux.vnet.ibm.com> <4FDB9477.9060709@redhat.com> <4FDEE290.2040302@redhat.com> In-Reply-To: <4FDEE290.2040302@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 3/5] osdep: Enable qemu_open to dup pre-opened fd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com, libvir-list@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com, Eric Blake On 06/18/2012 04:10 AM, Kevin Wolf wrote: > Am 15.06.2012 22:00, schrieb Eric Blake: >> On 06/15/2012 01:19 PM, Corey Bryant wrote: >> >>>>> There are some flags that I don't think we'll be able to change. For >>>>> example: O_RDONLY, O_WRONLY, O_RDWR. I assume libvirt would open all >>>>> files O_RDWR. >>>> >>>> I think we need to check all of them and fail qemu_open() if they don't >>>> match. Those that qemu can change, should be just changed, of course. >>>> >>> >>> Ok. I remember a scenario where QEMU opens a file read-only (perhaps to >>> check headers and determine the file format) before re-opening it >>> read-write. Perhaps this is only when format= isn't specified with >>> -drive. I'm thinking we may need to change flags to read-write where >>> they used to be read-only, in some circumstances. >> >> In those situations, libvirt would pass fd with O_RDWR, and qemu_open() >> would be fine requesting O_RDONLY the first time (subset is okay), and >> O_RDWR the second time. Where you have to error out is where libvirt >> passes O_RDONLY but qemu wants O_RDWR, and so forth. > > Let's try it with requiring an exact match first. If you pass the > format, I think the probing is completely avoided indeed, and having > read-only images really opened O_RDONLY protects against stupid mistakes. > > Or if we really need to open the file for probing, maybe we could add a > flag that relaxes the check and that isn't used in the real bdrv_open(). > > Kevin > I haven't heard any objection to this so I'll be checking for exact match, and implementing a flag to relax the check only if it's necessary. -- Regards, Corey