qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Disk image shared and exclusive locks.


From: Avi Kivity
Subject: Re: [Qemu-devel] [PATCH] Disk image shared and exclusive locks.
Date: Sat, 05 Dec 2009 19:55:15 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091203 Fedora/3.0-3.13.rc2.fc12 Thunderbird/3.0

On 12/05/2009 07:47 PM, Anthony Liguori wrote:
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.

Oh, that's just an implementation bug. Obviously there's no need to open a file for exclusive access if it will only be accessed for read (when merging a snapshot we'd need to upgrade the lock to exclusive while that takes place). I thought you objected to the whole concept.


--
Do not meddle in the internals of kernels, for they are subtle and quick to 
panic.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]