From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NGyj1-0004zO-45 for qemu-devel@nongnu.org; Sat, 05 Dec 2009 12:47:19 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NGyiw-0004vy-ET for qemu-devel@nongnu.org; Sat, 05 Dec 2009 12:47:18 -0500 Received: from [199.232.76.173] (port=50668 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGyiw-0004vd-4y for qemu-devel@nongnu.org; Sat, 05 Dec 2009 12:47:14 -0500 Received: from mail-yw0-f183.google.com ([209.85.211.183]:61422) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NGyiw-0000xU-51 for qemu-devel@nongnu.org; Sat, 05 Dec 2009 12:47:14 -0500 Received: by ywh13 with SMTP id 13so3559345ywh.29 for ; Sat, 05 Dec 2009 09:47:13 -0800 (PST) Message-ID: <4B1A9C9F.5040705@codemonkey.ws> Date: Sat, 05 Dec 2009 11:47:11 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Disk image shared and exclusive locks. References: <20091204165301.GA4167@amd.home.annexia.org> <4B1943A0.7030509@codemonkey.ws> <20091204215517.GA5938@amd.home.annexia.org> <4B198D5B.5080803@codemonkey.ws> <4B1A98D9.7010408@redhat.com> In-Reply-To: <4B1A98D9.7010408@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: "Richard W.M. Jones" , qemu-devel@nongnu.org Avi Kivity wrote: > On 12/05/2009 12:29 AM, Anthony Liguori wrote: >> >> Well disk sharing isn't actually bad as long as it's raw or a >> physical device. >> >> For qcow2, it's very complicated by backing files because we really >> need to express the concept of a read-write lock. >> >> That is, as long as the guests are opening the file read only, you >> should allow many readers. However, you should prevent anyone from >> opening with write permission. Likewise, writes should prevent >> future reads. >> > > Well shared/exclusive or read/write locks support exactly that. > > For non-raw storage we should take the locks unconditionally, since > there is no useful way to share such images opened for write access. > I think I made my point poorly. Consider the following: qemu-img create -f raw base.img 10G qemu-img create -f qcow2 -b base.img cow1.img qemu-img create -f qcow2 -b base.img cow2.img qemu -drive file=cow1.img,lock=exclusive qemu -drive file=cow2.img,lock=exclusive With the current patch, the second command will fail and it's impossible to invoke correctly. That's because flags are passed down to backing devices directly. You really need to be much smarter here in how you handle locking. Exposing exclusive/shared is probably the wrong interface. I think the better thing to do would be to expose a boolean and then automatically choose the proper lock type. This make require some deeper surgery to get right as we currently don't handle cdrom's intelligently (we try to open with write permission first). Regards, Anthony Liguori