From: Michal Privoznik Date: Fri, 20 May 2016 14:44:22 +0000 (+0200) Subject: remote_driver: Implement VIR_STREAM_RECV_STOP_AT_HOLE X-Git-Tag: v3.4.0-rc1~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31024b3d05d6a37202e3c6f6608333c27aeaccb8;p=thirdparty%2Flibvirt.git remote_driver: Implement VIR_STREAM_RECV_STOP_AT_HOLE This is fairly trivial now that we have everything in place. Signed-off-by: Michal Privoznik --- diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index dc59034c3b..d27e96ffc2 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 c22b6661e5..7b28d63db0 100644 --- a/src/rpc/virnetclientstream.c +++ b/src/rpc/virnetclientstream.c @@ -468,7 +468,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); @@ -532,6 +532,13 @@ int virNetClientStreamRecvPacket(virNetClientStreamPtr st, /* Pretend holeLength 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) { + /* No error reporting here. Caller knows what they are doing. */ + rv = -3; + goto cleanup; + } + if (len > st->holeLength) len = st->holeLength;