Re: [PATCH 06/27] Introduce virStreamInData and virStreamRegisterInData

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

 



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@xxxxxxxxxx>
> ---

> +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

Attachment: signature.asc
Description: OpenPGP digital signature

--
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]