[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v2 15/32] virnetclientstream: Introduce virNetClientStreamSendSkip



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 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 b97b9b1..16fde79 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 fb83693..d7d2b0e 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 length)
+{
+    virNetMessagePtr msg = NULL;
+    virNetStreamSkip data;
+    int ret = -1;
+
+    VIR_DEBUG("st=%p length=%llu", st, length);
+
+    if (!st->skippable) {
+        virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                       _("Skipping is not supported with this stream"));
+        return -1;
+    }
+
+    memset(&data, 0, sizeof(data));
+    data.length = length;
+
+    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..a648b7c 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 length);
+
 int virNetClientStreamEventAddCallback(virNetClientStreamPtr st,
                                        int events,
                                        virNetClientStreamEventCallback cb,
-- 
2.8.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]