[libvirt] [PATCH 06/27] Introduce virStreamInData and virStreamRegisterInData

Eric Blake eblake at redhat.com
Thu May 5 15:11:32 UTC 2016


On 04/28/2016 04:04 AM, Michal Privoznik wrote:
> These functions will be called to determine whether underlying

s/whether/whether the/

> file that stream is transferring is currently in a data or hole.

s/stream/the stream/

> 
> While virStreamRegisterInData is exposed, virStreamInData does
> not need to be made a public API as it will be called just
> internally.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---

> +int
> +virStreamRegisterInData(virStreamPtr stream,
> +                        virStreamInDataFunc inDataCb,
> +                        void *opaque)
> +{
> +    VIR_DEBUG("stream=%p, inDataCb=%p opaque=%p", stream, inDataCb, opaque);
> +
> +    virResetLastError();
> +
> +    virCheckStreamReturn(stream, -1);
> +    virCheckNonNullArgReturn(inDataCb, -1);
> +
> +    if (stream->inDataCb) {
> +        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> +                       _("A inData callback is already registered"));

s/A inData/An inData/ (or maybe s/A //)


> +/**
> + * virStreamInData:
> + * @stream: stream
> + * @data: are we in data or hole
> + * @offset: offset to next section
> + *
> + * This function will check underlying stream (typically a file)

s/check/check the/

> + * whether the current position the stream is in lies in a data
> + * section or in a hole.

Reads a bit awkwardly; maybe:

This function checks the underlying stream (typically a file) to learn
whether the current stream position lies within a data section or a hold.

> Upon return @data is set to a nonzero
> + * value if former is the case, or to zero if @stream is in a
> + * hole. Moreover, @offset it updated to tell caller how much

s/it/is/
s/much/many/

> + * bytes can be read from @stream until current section changes
> + * (from data to a hole or vice versa).
> + *
> + * As a special case, there's an implicit hole at EOF. In this
> + * situation this function should set @data = false, @offset = 0
> + * and return 0.
> + *
> + * Returns 0 on success,
> + *        -1 otherwise
> + */
> +int
> +virStreamInData(virStreamPtr stream,
> +                int *data,
> +                unsigned long long *offset)

I still wonder if 'length' is a better name than 'offset', but this one
doesn't feel quite as awkward as the ones earlier in the series.

> +++ b/src/libvirt_public.syms
> @@ -736,6 +736,7 @@ LIBVIRT_1.3.5 {
>      global:
>          virStreamSkip;
>          virStreamRegisterSkip;
> +        virStreamRegisterInData;

Worth sorting?

Interface looks usable so far.

-- 
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/062ec74d/attachment-0001.sig>


More information about the libvir-list mailing list