virnetclientstream: Introduce virNetClientStreamSendHole

While the previous commit implemented a helper for sending a
STREAM_HOLE packet for daemon, this is a client's counterpart.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2016-04-11 17:23:17 +02:00
parent fa19af0a13
commit 87f2a5c65d
3 changed files with 60 additions and 0 deletions

View File

@ -53,6 +53,7 @@ virNetClientStreamNew;
virNetClientStreamQueuePacket; virNetClientStreamQueuePacket;
virNetClientStreamRaiseError; virNetClientStreamRaiseError;
virNetClientStreamRecvPacket; virNetClientStreamRecvPacket;
virNetClientStreamSendHole;
virNetClientStreamSendPacket; virNetClientStreamSendPacket;
virNetClientStreamSetError; virNetClientStreamSetError;

View File

@ -430,6 +430,60 @@ int virNetClientStreamRecvPacket(virNetClientStreamPtr st,
} }
int
virNetClientStreamSendHole(virNetClientStreamPtr st,
virNetClientPtr client,
long long length,
unsigned int flags)
{
virNetMessagePtr msg = NULL;
virNetStreamHole data;
int ret = -1;
VIR_DEBUG("st=%p length=%llu", st, length);
if (!st->allowSkip) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Skipping is not supported with this stream"));
return -1;
}
memset(&data, 0, sizeof(data));
data.length = length;
data.flags = flags;
if (!(msg = virNetMessageNew(false)))
return -1;
virObjectLock(st);
msg->header.prog = virNetClientProgramGetProgram(st->prog);
msg->header.vers = virNetClientProgramGetVersion(st->prog);
msg->header.status = VIR_NET_CONTINUE;
msg->header.type = VIR_NET_STREAM_HOLE;
msg->header.serial = st->serial;
msg->header.proc = st->proc;
virObjectUnlock(st);
if (virNetMessageEncodeHeader(msg) < 0)
goto cleanup;
if (virNetMessageEncodePayload(msg,
(xdrproc_t) xdr_virNetStreamHole,
&data) < 0)
goto cleanup;
if (virNetClientSendNoReply(client, msg) < 0)
goto cleanup;
ret = 0;
cleanup:
virNetMessageFree(msg);
return ret;
}
int virNetClientStreamEventAddCallback(virNetClientStreamPtr st, int virNetClientStreamEventAddCallback(virNetClientStreamPtr st,
int events, int events,
virNetClientStreamEventCallback cb, virNetClientStreamEventCallback cb,

View File

@ -61,6 +61,11 @@ int virNetClientStreamRecvPacket(virNetClientStreamPtr st,
size_t nbytes, size_t nbytes,
bool nonblock); bool nonblock);
int virNetClientStreamSendHole(virNetClientStreamPtr st,
virNetClientPtr client,
long long length,
unsigned int flags);
int virNetClientStreamEventAddCallback(virNetClientStreamPtr st, int virNetClientStreamEventAddCallback(virNetClientStreamPtr st,
int events, int events,
virNetClientStreamEventCallback cb, virNetClientStreamEventCallback cb,