Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/remote/remote_driver.c | 2 +-
src/rpc/virnetclientstream.c | 10 +++++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 376e9ba..fd76811 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5652,7 +5652,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 ff35137..c668d64 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -434,7 +434,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);
@@ -497,6 +497,14 @@ 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.10.2