Re: [PATCH 04/27] Introduce virStreamSkip

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

 



On 05.05.2016 16:37, Eric Blake wrote:
> On 04/28/2016 04:04 AM, Michal Privoznik wrote:
>> This API can be used to tell the other side of the stream to skip
>> some bytes in the stream. This can be used to create a sparse
>> file on the receiving side of a stream.
>>
>> It takes just one argument @offset, which says how big the hole
>> is. Since our streams are not rewindable like regular files, we
>> don't need @whence argument like seek(2) has.
>>
>> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
>> ---
>>  include/libvirt/libvirt-stream.h |  3 +++
>>  src/driver-stream.h              |  5 +++++
>>  src/libvirt-stream.c             | 40 ++++++++++++++++++++++++++++++++++++++++
>>  src/libvirt_public.syms          |  5 +++++
>>  4 files changed, 53 insertions(+)
>>
> 
>> +++ b/src/libvirt-stream.c
>> @@ -286,6 +286,46 @@ virStreamRecv(virStreamPtr stream,
>>  
>>  
>>  /**
>> + * virStreamSkip:
>> + * @stream: pointer to the stream object
>> + * @offset: number of bytes to skip
>> + *
>> + * Skip @offset bytes in the stream. This is useful when there's
>> + * no actual data in the stream, just a hole. If that's the case,
>> + * this API can be used to skip the hole properly instead of
>> + * transmitting zeroes to the other side.
>> + *
>> + * Returns 0 on success,
>> + *        -1 error
>> + */
>> +int
>> +virStreamSkip(virStreamPtr stream,
>> +              unsigned long long offset)
> 
> 'offset' is a bit misleading - you're not skipping _to_ the given
> offset, so much as _over_ length bytes.  I'd name it 'length'.
> 
> Otherwise looks okay.
> 

Ah, good point. Whilst implementing this I've balanced between Seek and
Skip back and forth.  That's why I call streem seekable even if it's
really just skip what is implemented here.

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]