From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgX3J-0008Ok-Br for qemu-devel@nongnu.org; Mon, 18 Jun 2012 04:11:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SgX3E-0007Or-KE for qemu-devel@nongnu.org; Mon, 18 Jun 2012 04:11:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgX3E-0007OX-D3 for qemu-devel@nongnu.org; Mon, 18 Jun 2012 04:11:08 -0400 Message-ID: <4FDEE290.2040302@redhat.com> Date: Mon, 18 Jun 2012 10:10:56 +0200 From: Kevin Wolf 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> In-Reply-To: <4FDB9477.9060709@redhat.com> Content-Type: text/plain; charset=UTF-8 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: Eric Blake Cc: aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com, libvir-list@redhat.com, Corey Bryant , qemu-devel@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com 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