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

[libvirt] [PATCH v2 23/32] remote_driver: Implement VIR_STREAM_RECV_STOP_AT_HOLE



Signed-off-by: Michal Privoznik <mprivozn redhat com>
---
 src/remote/remote_driver.c   |  2 +-
 src/rpc/virnetclientstream.c | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 5507713..72f8f21 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5096,7 +5096,7 @@ remoteStreamRecvFlags(virStreamPtr st,
     virNetClientStreamPtr privst = st->privateData;
     int rv;
 
-    virCheckFlags(0, -1);
+    virCheckFlags(VIR_STREAM_RECV_STOP_AT_HOLE, -1);
 
     if (virNetClientStreamRaiseError(privst))
         return -1;
diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index f63072e..e8ef3a3 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -436,7 +436,7 @@ int virNetClientStreamRecvPacket(virNetClientStreamPtr st,
     VIR_DEBUG("st=%p client=%p data=%p nbytes=%zu nonblock=%d flags=%x",
               st, client, data, nbytes, nonblock, flags);
 
-    virCheckFlags(0, -1);
+    virCheckFlags(VIR_STREAM_RECV_STOP_AT_HOLE, -1);
 
     virObjectLock(st);
 
@@ -499,6 +499,15 @@ int virNetClientStreamRecvPacket(virNetClientStreamPtr st,
         /* Pretend skipLength zeroes was read from stream. */
         size_t len = want;
 
+        /* Yes, pretend unless we are asked not to. */
+        if (flags & VIR_STREAM_RECV_STOP_AT_HOLE) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Stream is in a hole"));
+            rv = -3;
+            goto cleanup;
+        }
+
+
         if (len > st->skipLength)
             len = st->skipLength;
 
-- 
2.8.3


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