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

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

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 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.
+
 =item $st->recv_all($handler)
 
 Receive all data available from the stream, invoking
-- 
2.13.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