Re: [PATCH v4 17/23] utils: Extend virCommandProcessIO to include the send buffers

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

 



On Thu, Jul 11, 2019 at 03:41:45PM -0400, Stefan Berger wrote:
> Extend virCommandProcessIO to include the send buffers in the poll
> loop.
> 
> Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxxxxx>
> ---
>  src/util/vircommand.c | 63 ++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 62 insertions(+), 1 deletion(-)
> 
> diff --git a/src/util/vircommand.c b/src/util/vircommand.c
> index b10bba5b32..e5ad1d64c4 100644
> --- a/src/util/vircommand.c
> +++ b/src/util/vircommand.c
> @@ -1817,6 +1817,62 @@ virCommandSetSendBuffer(virCommandPtr cmd,
>  }
>  
>  
> +static int
> +virCommandSendBuffersFillPollfd(virCommandPtr cmd,
> +                                struct pollfd *fds,
> +                                int startidx)
> +{
> +    size_t i, j;
> +
> +    for (i = 0, j = 0; i < virCommandGetNumSendBuffers(cmd); i++) {
> +        if (cmd->sendBuffers[i].fd >= 0) {
> +            fds[startidx + j].fd = cmd->sendBuffers[i].fd;
> +            fds[startidx + j].events = POLLOUT;
> +            fds[startidx + j].revents = 0;
> +            j++;
> +        }
> +    }
> +
> +    return j;
> +}
> +
> +
> +static int
> +virCommandSendBuffersHandlePoll(virCommandPtr cmd,
> +                                struct pollfd *fds)
> +{
> +    size_t i;
> +    int done;
> +
> +    for (i = 0; i < virCommandGetNumSendBuffers(cmd); i++) {
> +        if (fds->fd == cmd->sendBuffers[i].fd)
> +            break;
> +    }
> +    if (i == virCommandGetNumSendBuffers(cmd))
> +        return 0;
> +
> +    done = write(fds->fd,
> +                 cmd->sendBuffers[i].buffer + cmd->sendBuffers[i].offset,
> +                 MIN(cmd->sendBuffers[i].buflen - cmd->sendBuffers[i].offset,
> +                     MAX_PIPE_WRITE_BYTES));

The FD is non-blocking, so size limiting the data doesn't seem to serve
any useful purpose.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
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