From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1LF0-0002DR-Ak for qemu-devel@nongnu.org; Mon, 31 Oct 2016 18:39:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1LEz-0007WV-Ax for qemu-devel@nongnu.org; Mon, 31 Oct 2016 18:39:42 -0400 Date: Mon, 31 Oct 2016 22:39:33 +0000 From: "Richard W.M. Jones" Message-ID: <20161031223933.GS11243@redhat.com> References: <1477928314-11184-1-git-send-email-famz@redhat.com> <1477928314-11184-14-git-send-email-famz@redhat.com> <43438fac-7c1c-443f-28fc-f49fd33fdfe0@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43438fac-7c1c-443f-28fc-f49fd33fdfe0@redhat.com> Subject: Re: [Qemu-devel] [PATCH 13/14] raw-posix: Implement image locking List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Fam Zheng , qemu-devel@nongnu.org, Kevin Wolf , qemu-block@nongnu.org, Max Reitz On Mon, Oct 31, 2016 at 05:01:44PM -0500, Eric Blake wrote: > On 10/31/2016 10:38 AM, Fam Zheng wrote: > > This implements open flag sensible image locking for local file > > and host device protocol. > > > > virtlockd in libvirt locks the first byte, so we start looking at the > > file bytes from 1. > > What happens if we try to use a raw file with less than 3 bytes? There's > not much to be locked in that case (especially if we round down to > sector sizes - the file is effectively empty) - but it's probably a > corner case you have to be aware of. It would be nice if qemu could handle zero-length or even < 512 byte drives, but we (libguestfs) gave up that battle a long time ago after encountering several bugs in this area. These days when you try to add an empty file[1] through the libguestfs API, the implementation replaces it with a 4096 byte raw-format file of zeroes. More here: https://github.com/libguestfs/libguestfs/blob/master/src/drives.c#L395 Rich. [1] It has the name "/dev/null" for historical reasons, but is not that actual device for the reasons given above. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW