[libvirt] [PATCH 15/8] save: add more iohelper support for O_DIRECT

Eric Blake eblake at redhat.com
Tue Jul 19 17:58:47 UTC 2011

On 07/19/2011 11:50 AM, Daniel P. Berrange wrote:
> On Fri, Jul 15, 2011 at 08:48:18PM -0600, Eric Blake wrote:
>> Constraining the problem makes the solution easier to think about.
>> * src/util/iohelper.c (runIO): Make read support easy.
>> ---
>> Could be squashed into 6/8.
>>   src/util/iohelper.c |    9 ++++++++-
> ACK, if this really works for saving guests. We need to skip over the
> initial header + XML in save files, so I would have thought we needed
> to support a non-empty seekable file.

Yes, it really works.  QEMU state files need not be seekable (it is the 
same format as used for migration, which can be passed over non-seekable 
sockets).  Therefore, all we are doing is using iohelper to wrap a 
pipe() around the underlying file, at which point, all I/O is linear.

We do the wrapping _prior_ to the point that libvirt writes the header, 
and also prior to the point that libvirt then hands the fd over to qemu, 
for qemu to write the rest of the file.  Therefore, from iohelper's 
perspective, we don't care who did the writing, but the end result is 
that all i/o is aggregated and replayed into the O_DIRECT fd from start 
to finish.

Same thing on read - libvirt reads, rather than seeks, the header. 
Therefore, libvirt reads the header, then hands the fd over to qemu to 
read the rest of the file.

Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

More information about the libvir-list mailing list