mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-29 17:33:09 +00:00
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:
parent
fa19af0a13
commit
87f2a5c65d
@ -53,6 +53,7 @@ virNetClientStreamNew;
|
|||||||
virNetClientStreamQueuePacket;
|
virNetClientStreamQueuePacket;
|
||||||
virNetClientStreamRaiseError;
|
virNetClientStreamRaiseError;
|
||||||
virNetClientStreamRecvPacket;
|
virNetClientStreamRecvPacket;
|
||||||
|
virNetClientStreamSendHole;
|
||||||
virNetClientStreamSendPacket;
|
virNetClientStreamSendPacket;
|
||||||
virNetClientStreamSetError;
|
virNetClientStreamSetError;
|
||||||
|
|
||||||
|
@ -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,
|
||||||
|
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user