Re: [PATCH v2 12/38] Introduce virStreamHoleSize

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

 




On 04/20/2017 06:01 AM, Michal Privoznik wrote:
> This function is basically a counterpart for virStreamSkip. If
> one side of a stream called virStreamSkip() the other should call

s/should/would need to/

> virStreamHoleSize() to get the size of the hole.
> 
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  include/libvirt/libvirt-stream.h |  3 +++
>  src/driver-stream.h              |  5 +++++
>  src/libvirt-stream.c             | 42 ++++++++++++++++++++++++++++++++++++++++
>  src/libvirt_public.syms          |  1 +
>  4 files changed, 51 insertions(+)
> 

Again the naming doesn't necessarily conform to our newer standard, but
that's something I'd expect we've already discussed in patch 11...
Likewise should a @flags argument be added?

> diff --git a/include/libvirt/libvirt-stream.h b/include/libvirt/libvirt-stream.h
> index 4e0a599..2ebda74 100644
> --- a/include/libvirt/libvirt-stream.h
> +++ b/include/libvirt/libvirt-stream.h
> @@ -53,6 +53,9 @@ int virStreamRecvFlags(virStreamPtr st,
>  int virStreamSkip(virStreamPtr st,
>                    unsigned long long length);
>  
> +int virStreamHoleSize(virStreamPtr,
> +                      unsigned long long *length);
> +
>  
>  /**
>   * virStreamSourceFunc:
> diff --git a/src/driver-stream.h b/src/driver-stream.h
> index 20ea13f..e196b6d 100644
> --- a/src/driver-stream.h
> +++ b/src/driver-stream.h
> @@ -46,6 +46,10 @@ typedef int
>                      unsigned long long length);
>  
>  typedef int
> +(*virDrvStreamHoleSize)(virStreamPtr st,
> +                        unsigned long long *length);
> +
> +typedef int
>  (*virDrvStreamEventAddCallback)(virStreamPtr stream,
>                                  int events,
>                                  virStreamEventCallback cb,
> @@ -73,6 +77,7 @@ struct _virStreamDriver {
>      virDrvStreamRecv streamRecv;
>      virDrvStreamRecvFlags streamRecvFlags;
>      virDrvStreamSkip streamSkip;
> +    virDrvStreamHoleSize streamHoleSize;
>      virDrvStreamEventAddCallback streamEventAddCallback;
>      virDrvStreamEventUpdateCallback streamEventUpdateCallback;
>      virDrvStreamEventRemoveCallback streamEventRemoveCallback;
> diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c
> index 55f3ef5..3ac9e0d 100644
> --- a/src/libvirt-stream.c
> +++ b/src/libvirt-stream.c
> @@ -403,6 +403,48 @@ virStreamSkip(virStreamPtr stream,
>  
>  
>  /**
> + * virStreamHoleSize:
> + * @stream: pointer to the stream object
> + * @length: number of bytes to skip
> + *
> + * This function is a counterpart to virStreamSkip(). That is, if
> + * one side of a stream has called virStreamSkip() the other side
> + * of the stream should call virStreamHoleSize() to retrieve the
> + * size of hole. If there's currently no hole in the stream, -1
> + * is returned.

Hmmm.. this last sentence belongs in the "Returns" space.

Consider

This API is used to determine the @length in bytes of the empty space to
be created in a @stream's target file when uploading or downloading
sparsely populated files. This is the counterpart to virStream....().

> + *
> + * Returns 0 on success,
> + *        -1 on error

s/on error/on error or when there's currently no hole in the stream


Again, similar to last patch - ACK after the API naming discussion...

John

> + */
> +int
> +virStreamHoleSize(virStreamPtr stream,
> +                  unsigned long long *length)
> +{
> +    VIR_DEBUG("stream=%p, length=%p", stream, length);
> +
> +    virResetLastError();
> +
> +    virCheckStreamReturn(stream, -1);
> +    virCheckNonNullArgReturn(length, -1);
> +
> +    if (stream->driver &&
> +        stream->driver->streamHoleSize) {
> +        int ret;
> +        ret = (stream->driver->streamHoleSize)(stream, length);
> +        if (ret < 0)
> +            goto error;
> +        return ret;
> +    }
> +
> +    virReportUnsupportedError();
> +
> + error:
> +    virDispatchError(stream->conn);
> +    return -1;
> +}
> +
> +
> +/**
>   * virStreamSendAll:
>   * @stream: pointer to the stream object
>   * @handler: source callback for reading data from application
> diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
> index acadda8..0e34eee 100644
> --- a/src/libvirt_public.syms
> +++ b/src/libvirt_public.syms
> @@ -761,6 +761,7 @@ LIBVIRT_3.1.0 {
>  
>  LIBVIRT_3.3.0 {
>      global:
> +        virStreamHoleSize;
>          virStreamRecvFlags;
>          virStreamSkip;
>  } LIBVIRT_3.1.0;
> 

--
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]
  Powered by Linux