Re: [PATCH RFC 08/48] Introduce virStreamHoleSize

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

 



On Wed, Jun 22, 2016 at 04:43:25PM +0200, Michal Privoznik wrote:
> This function is basically a counterpart for virStreamSkip. If
> one side of a stream called virStreamSkip() the other should call
> 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(+)
> 
> 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.
> + *
> + * Returns 0 on success,
> + *        -1 on error
> + */
> +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 5b536eb..0439434 100644
> --- a/src/libvirt_public.syms
> +++ b/src/libvirt_public.syms
> @@ -738,6 +738,7 @@ LIBVIRT_2.0.0 {
>          virDomainGetGuestVcpus;
>          virDomainSetGuestVcpus;
>          virConnectStoragePoolEventRegisterAny;
> +        virStreamHoleSize;
>          virStreamRecvFlags;
>          virStreamSkip;
>  } LIBVIRT_1.3.3;

Use 2.1.0 now

ACK

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

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