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