While the previous commit implemented a helper for sending a
STREAM_SKIP packet for daemon, this is a client's counterpart.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/libvirt_remote.syms | 1 +
src/rpc/virnetclientstream.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
src/rpc/virnetclientstream.h | 4 ++++
3 files changed, 57 insertions(+)
diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index 18d3f2d..e823588 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -54,6 +54,7 @@ virNetClientStreamQueuePacket;
virNetClientStreamRaiseError;
virNetClientStreamRecvPacket;
virNetClientStreamSendPacket;
+virNetClientStreamSendSkip;
virNetClientStreamSetError;
diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index 06d91d1..bfd76d7 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -431,6 +431,58 @@ int virNetClientStreamRecvPacket(virNetClientStreamPtr st,
}
+int
+virNetClientStreamSendSkip(virNetClientStreamPtr st,
+ virNetClientPtr client,
+ unsigned long long offset)
+{
+ virNetMessagePtr msg = NULL;
+ virNetStreamSkip data;
+ int ret = -1;
+
+ VIR_DEBUG("st=%p offset=%llu", st, offset);
+
+ if (!st->seekable) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("Skipping is not supported with this stream"));
+ return -1;
+ }
+
+ memset(&data, 0, sizeof(data));
+ data.offset = offset;
+
+ 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_SKIP;
+ msg->header.serial = st->serial;
+ msg->header.proc = st->proc;
+
+ virObjectUnlock(st);
+
+ if (virNetMessageEncodeHeader(msg) < 0)
+ goto cleanup;
+
+ if (virNetMessageEncodePayload(msg,
+ (xdrproc_t) xdr_virNetStreamSkip,
+ &data) < 0)
+ goto cleanup;
+
+ if (virNetClientSendNoReply(client, msg) < 0)
+ goto cleanup;
+
+ ret = 0;
+ cleanup:
+ virNetMessageFree(msg);
+ return ret;
+}
+
+
int virNetClientStreamEventAddCallback(virNetClientStreamPtr st,
int events,
virNetClientStreamEventCallback cb,
diff --git a/src/rpc/virnetclientstream.h b/src/rpc/virnetclientstream.h
index 0a5aafd..58fbc89 100644
--- a/src/rpc/virnetclientstream.h
+++ b/src/rpc/virnetclientstream.h
@@ -61,6 +61,10 @@ int virNetClientStreamRecvPacket(virNetClientStreamPtr st,
size_t nbytes,
bool nonblock);
+int virNetClientStreamSendSkip(virNetClientStreamPtr st,
+ virNetClientPtr client,
+ unsigned long long offset);
+
int virNetClientStreamEventAddCallback(virNetClientStreamPtr st,
int events,
virNetClientStreamEventCallback cb,
--
2.8.1