Re: [PATCH v2 23/38] virnetclientstream: Introduce virNetClientStreamSendSkip

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

 




On 04/20/2017 06:01 AM, Michal Privoznik wrote:
> 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@xxxxxxxxxx>
> ---
>  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 29dceab..6093613 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 42619bf..1e30080 100644
> --- a/src/rpc/virnetclientstream.c
> +++ b/src/rpc/virnetclientstream.c
> @@ -429,6 +429,58 @@ int virNetClientStreamRecvPacket(virNetClientStreamPtr st,
>  }
>  
>  
> +int
> +virNetClientStreamSendSkip(virNetClientStreamPtr st,
> +                           virNetClientPtr client,
> +                           unsigned long long length)

would probably need the @flags too for @data inclusion
> +{
> +    virNetMessagePtr msg = NULL;
> +    virNetStreamSkip data;
> +    int ret = -1;
> +
> +    VIR_DEBUG("st=%p length=%llu", st, length);
> +
> +    if (!st->skippable) {

As pointed out earlier - allowSkip


John
> +        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,
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux