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

Re: [libvirt] [libvirt-perl][PATCH 3/7] Introduce Stream::recvHole() and Stream::sendHole()



On Tue, May 23, 2017 at 05:05:37PM +0200, Michal Privoznik wrote:
> Signed-off-by: Michal Privoznik <mprivozn redhat com>
> ---
>  Changes                |  1 +
>  Virt.xs                | 28 ++++++++++++++++++++++++++++
>  lib/Sys/Virt/Stream.pm | 17 +++++++++++++++++
>  3 files changed, 46 insertions(+)
> 
> diff --git a/Changes b/Changes
> index b4a493c..c92c271 100644
> --- a/Changes
> +++ b/Changes
> @@ -6,6 +6,7 @@ Revision history for perl module Sys::Virt
>   - Fix send_all() callback helper
>   - Introduce flags to Stream::recv() and
>     register RECV_STOP_AT_HOLE constant
> + - Introduce Stream::recvHole() and Stream::sendHole()
>  
>  3.3.0 2017-05-08
>  
> diff --git a/Virt.xs b/Virt.xs
> index 498e711..d112708 100644
> --- a/Virt.xs
> +++ b/Virt.xs
> @@ -7900,6 +7900,34 @@ recv(st, data, nbytes, flags=0)
>        RETVAL
>  
>  
> +SV *
> +recvHole(st, flags=0)
> +      virStreamPtr st;
> +      unsigned int flags;
> +  PREINIT:
> +      long long length;
> +    CODE:
> +      if (virStreamRecvHole(st, &length, flags) < 0)
> +          _croak_error();
> +
> +      RETVAL = virt_newSVll(length);
> +  OUTPUT:
> +      RETVAL
> +
> +
> +void
> +sendHole(st, lengthSV, flags=0)
> +      virStreamPtr st;
> +      SV *lengthSV;
> +      unsigned int flags;
> + PREINIT:
> +      long long length;
> +  PPCODE:
> +      length = virt_SvIVll(lengthSV);
> +      if (virStreamSendHole(st, length, flags) < 0)
> +          _croak_error();
> +
> +
>  void
>  send_all(stref, handler)
>        SV *stref;
> diff --git a/lib/Sys/Virt/Stream.pm b/lib/Sys/Virt/Stream.pm
> index 069895e..5984fb6 100644
> --- a/lib/Sys/Virt/Stream.pm
> +++ b/lib/Sys/Virt/Stream.pm
> @@ -93,6 +93,23 @@ Send upto C<$nbytes> worth of data, copying from C<$data>.
>  Returns the number of bytes sent, or -2 if I/O would block,
>  or -1 on error.
>  
> +=item $rv = $st->recvHole($flags=0)
> +
> +Determine the amount of the empty space (in bytes) to be created
> +in a stream's target file when uploading or downloading sparsely
> +populated files. This is the counterpart to C<sendHole>. The
> +optional C<$flags> parameter is currently unused and defaults to
> +zero if omitted.
> +
> +=item $st->sendHole($length, $flags=0)
> +
> +Rather than transmitting empty file space, this method directs
> +the stream target to create C<$length> bytes of empty space.
> +This method would be used when uploading or downloading sparsely
> +populated files to avoid the needless copy of empty file space.
> +The optional C<$flags> parameter is currently unused and defaults
> +to zero if omitted.

These methods should use '_' rather than camelCase in naming.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


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