Re: [libvirt] [PATCH v3 06/31] Introduce virStreamRecvHole

2017-05-16 Thread John Ferlan


On 05/16/2017 10:03 AM, Michal Privoznik wrote:
> This function is basically a counterpart for virStreamSendHole().
> If one side of a stream called virStreamSendHole() the other
> should call virStreamRecvHole() to get the size of the hole.
> 
> Signed-off-by: Michal Privoznik 
> ---
>  include/libvirt/libvirt-stream.h |  4 
>  src/driver-stream.h  |  6 ++
>  src/libvirt-stream.c | 44 
> 
>  src/libvirt_public.syms  |  1 +
>  4 files changed, 55 insertions(+)
> 

Reviewed-by: John Ferlan 

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v3 06/31] Introduce virStreamRecvHole

2017-05-16 Thread Michal Privoznik
This function is basically a counterpart for virStreamSendHole().
If one side of a stream called virStreamSendHole() the other
should call virStreamRecvHole() to get the size of the hole.

Signed-off-by: Michal Privoznik 
---
 include/libvirt/libvirt-stream.h |  4 
 src/driver-stream.h  |  6 ++
 src/libvirt-stream.c | 44 
 src/libvirt_public.syms  |  1 +
 4 files changed, 55 insertions(+)

diff --git a/include/libvirt/libvirt-stream.h b/include/libvirt/libvirt-stream.h
index 14c9af142..feaa8ad64 100644
--- a/include/libvirt/libvirt-stream.h
+++ b/include/libvirt/libvirt-stream.h
@@ -54,6 +54,10 @@ int virStreamSendHole(virStreamPtr st,
   long long length,
   unsigned int flags);
 
+int virStreamRecvHole(virStreamPtr,
+  long long *length,
+  unsigned int flags);
+
 
 /**
  * virStreamSourceFunc:
diff --git a/src/driver-stream.h b/src/driver-stream.h
index 0a5201431..0fb56ebd2 100644
--- a/src/driver-stream.h
+++ b/src/driver-stream.h
@@ -46,6 +46,11 @@ typedef int
 long long length,
 unsigned int flags);
 
+typedef int
+(*virDrvStreamRecvHole)(virStreamPtr st,
+long long *length,
+unsigned int flags);
+
 typedef int
 (*virDrvStreamEventAddCallback)(virStreamPtr stream,
 int events,
@@ -74,6 +79,7 @@ struct _virStreamDriver {
 virDrvStreamRecv streamRecv;
 virDrvStreamRecvFlags streamRecvFlags;
 virDrvStreamSendHole streamSendHole;
+virDrvStreamRecvHole streamRecvHole;
 virDrvStreamEventAddCallback streamEventAddCallback;
 virDrvStreamEventUpdateCallback streamEventUpdateCallback;
 virDrvStreamEventRemoveCallback streamEventRemoveCallback;
diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c
index a09896dcd..dc0dc9ea3 100644
--- a/src/libvirt-stream.c
+++ b/src/libvirt-stream.c
@@ -405,6 +405,50 @@ virStreamSendHole(virStreamPtr stream,
 }
 
 
+/**
+ * virStreamRecvHole:
+ * @stream: pointer to the stream object
+ * @length: number of bytes to skip
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * 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 virStreamSendHole().
+ *
+ * Returns 0 on success,
+ *-1 on error or when there's currently no hole in the stream
+ */
+int
+virStreamRecvHole(virStreamPtr stream,
+  long long *length,
+  unsigned int flags)
+{
+VIR_DEBUG("stream=%p, length=%p flags=%x",
+  stream, length, flags);
+
+virResetLastError();
+
+virCheckStreamReturn(stream, -1);
+virCheckNonNullArgReturn(length, -1);
+
+if (stream->driver &&
+stream->driver->streamRecvHole) {
+int ret;
+ret = (stream->driver->streamRecvHole)(stream, length, flags);
+if (ret < 0)
+goto error;
+return ret;
+}
+
+virReportUnsupportedError();
+
+ error:
+virDispatchError(stream->conn);
+return -1;
+}
+
+
 /**
  * virStreamSendAll:
  * @stream: pointer to the stream object
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 3be7cc6a0..b73cc8af1 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -762,6 +762,7 @@ LIBVIRT_3.1.0 {
 LIBVIRT_3.4.0 {
 global:
 virStreamRecvFlags;
+virStreamRecvHole;
 virStreamSendHole;
 } LIBVIRT_3.1.0;
 
-- 
2.13.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list