[libvirt] [PATCH 04/27] Introduce virStreamSkip
Eric Blake
eblake at redhat.com
Thu May 5 14:37:54 UTC 2016
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 at redhat.com>
> ---
> 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.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160505/5cbe39b2/attachment-0001.sig>
More information about the libvir-list
mailing list