From c331f56b93b8635928c8c86a5fbf4ea01a452ad6 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Sun, 10 Apr 2016 15:48:27 +0200 Subject: [PATCH] remote_driver: Implement virStreamSendHole Now that we have RPC wrappers over VIR_NET_STREAM_HOLE we can start wiring them up. This commit wires up situation when a client wants to send a hole to daemon. To keep stream offsets synchronous, upon successful call on the daemon skip the same hole in local part of the stream. Signed-off-by: Michal Privoznik --- src/remote/remote_driver.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index aebdd47c9f..ff5be6ebb9 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -5683,6 +5683,37 @@ remoteStreamRecv(virStreamPtr st, return remoteStreamRecvFlags(st, data, nbytes, 0); } + +static int +remoteStreamSendHole(virStreamPtr st, + long long length, + unsigned int flags) +{ + VIR_DEBUG("st=%p length=%lld flags=%x", + st, length, flags); + struct private_data *priv = st->conn->privateData; + virNetClientStreamPtr privst = st->privateData; + int rv; + + if (virNetClientStreamRaiseError(privst)) + return -1; + + remoteDriverLock(priv); + priv->localUses++; + remoteDriverUnlock(priv); + + rv = virNetClientStreamSendHole(privst, + priv->client, + length, + flags); + + remoteDriverLock(priv); + priv->localUses--; + remoteDriverUnlock(priv); + return rv; +} + + struct remoteStreamCallbackData { virStreamPtr st; virStreamEventCallback cb; @@ -5857,6 +5888,7 @@ static virStreamDriver remoteStreamDrv = { .streamRecv = remoteStreamRecv, .streamRecvFlags = remoteStreamRecvFlags, .streamSend = remoteStreamSend, + .streamSendHole = remoteStreamSendHole, .streamFinish = remoteStreamFinish, .streamAbort = remoteStreamAbort, .streamEventAddCallback = remoteStreamEventAddCallback,