From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O5F35-0005TM-7o for qemu-devel@nongnu.org; Fri, 23 Apr 2010 05:19:47 -0400 Received: from [140.186.70.92] (port=42529 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O5F33-0005Ss-F0 for qemu-devel@nongnu.org; Fri, 23 Apr 2010 05:19:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O5F31-0008PK-RB for qemu-devel@nongnu.org; Fri, 23 Apr 2010 05:19:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15443) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O5DoL-0003AL-K0 for qemu-devel@nongnu.org; Fri, 23 Apr 2010 04:00:31 -0400 Date: Fri, 23 Apr 2010 09:00:25 +0100 From: "Richard W.M. Jones" Subject: Re: [Qemu-devel] One more thing about block device locking Message-ID: <20100423080025.GA1639@amd.home.annexia.org> References: <4BD12B10.1060304@msgid.tls.msk.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4BD12B10.1060304@msgid.tls.msk.ru> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev Cc: qemu-devel On Fri, Apr 23, 2010 at 09:07:28AM +0400, Michael Tokarev wrote: > So we'll have to either > trial and error, or open "normally", check > if it's a block device and re-open with that > flag set. Perhaps I'm missing something, but why can't you stat(2) the name first to see if it's a block device (ie. S_ISBLK(st_mode)) then add the O_EXCL flag or not as appropriate? Anyway, the problem with this is it's not helpful (in fact: actively bad) for libguestfs. We want to allow people to open existing devices read-only, even if one qemu process has them open for writing. Consider, for example, virt-df or virt-cat which allow you to read information out from live VMs. This is why we should have exclusive|shared modes for locking (or if you prefer write|read -- it's the same thing with a different name AFAICT). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v