]> git.ipfire.org Git - thirdparty/libvirt.git/commit
storage: avoid short reads while chasing backing chain
authorEric Blake <eblake@redhat.com>
Tue, 5 Nov 2013 17:30:56 +0000 (10:30 -0700)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 18 Feb 2014 15:53:08 +0000 (15:53 +0000)
commit79110a1d0398bb094754648d6c75d6d6d7c93964
treee9808fdb1d2b3e5a4109b483c948f771fa99c1eb
parent6c5e4442875f442a758c81caeeb97dd851ce9353
storage: avoid short reads while chasing backing chain

Our backing file chain code was not very robust to an ill-timed
EINTR, which could lead to a short read causing us to randomly
treat metadata differently than usual.  But the existing
virFileReadLimFD forces an error if we don't read the entire
file, even though we only care about the header of the file.
So add a new virFile function that does what we want.

* src/util/virfile.h (virFileReadHeaderFD): New prototype.
* src/util/virfile.c (virFileReadHeaderFD): New function.
* src/libvirt_private.syms (virfile.h): Export it.
* src/util/virstoragefile.c (virStorageFileGetMetadataInternal)
(virStorageFileProbeFormatFromFD): Use it.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 5327fad4f292e4f3f84884ffe158c492bf00519c)

Conflicts:
src/util/virstoragefile.c: OOM error reporting & buffer signedness
src/libvirt_private.syms
src/util/virfile.c
src/util/virfile.h
src/util/virstoragefile.c