All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@gmail.com>
To: Jagannathan Raman <jag.raman@oracle.com>
Cc: Elena Ufimtseva <elena.ufimtseva@oracle.com>,
	Fam Zheng <fam@euphon.net>,
	Swapnil Ingle <swapnil.ingle@nutanix.com>,
	John G Johnson <john.g.johnson@oracle.com>,
	QEMU <qemu-devel@nongnu.org>, Gerd Hoffmann <kraxel@redhat.com>,
	Juan Quintela <quintela@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Kanth Ghatraju <kanth.ghatraju@oracle.com>,
	Felipe Franciosi <felipe@nutanix.com>,
	Thomas Huth <thuth@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Thanos Makatos <thanos.makatos@nutanix.com>,
	Richard Henderson <rth@twiddle.net>,
	Kevin Wolf <kwolf@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>,
	Max Reitz <mreitz@redhat.com>,
	Ross Lagerwall <ross.lagerwall@citrix.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v12 07/19] multi-process: add qio channel function to transmit data and fds
Date: Fri, 4 Dec 2020 18:40:39 +0400	[thread overview]
Message-ID: <CAJ+F1CKk-RrQY=n2SVw4M699jzQYJjZWEatHJCZT7=RtboW=OQ@mail.gmail.com> (raw)
In-Reply-To: <7d135ab5224ad43d0a395f31be70e20a4bd52a11.1606853298.git.jag.raman@oracle.com>

[-- Attachment #1: Type: text/plain, Size: 3973 bytes --]

On Wed, Dec 2, 2020 at 12:23 AM Jagannathan Raman <jag.raman@oracle.com>
wrote:

> From: Elena Ufimtseva <elena.ufimtseva@oracle.com>
>
> Adds QIO channel functions that transmits the input iovs as well as the
> supplied fds.
>
> Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
> Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
> Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  include/io/channel.h | 24 ++++++++++++++++++++++++
>  io/channel.c         | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 69 insertions(+)
>
> diff --git a/include/io/channel.h b/include/io/channel.h
> index 4d6fe45..0aa44e1 100644
> --- a/include/io/channel.h
> +++ b/include/io/channel.h
> @@ -773,5 +773,29 @@ void qio_channel_set_aio_fd_handler(QIOChannel *ioc,
>                                      IOHandler *io_read,
>                                      IOHandler *io_write,
>                                      void *opaque);
> +/**
> + * qio_channel_writev_full_all:
> + * @ioc: the channel object
> + * @iov: the array of memory regions to write data from
> + * @niov: the length of the @iov array
> + * @fds: an array of file handles to send
> + * @nfds: number of file handles in @fds
> + * @errp: pointer to a NULL-initialized error object
> + *
> + *
> + * Behaves like qio_channel_writev_full but will attempt
> + * to send all data passed (file handles and memory regions).
> + * The function will wait for all requested data
> + * to be written, yielding from the current coroutine
> + * if required.
> + *
> + * Returns: 0 if all bytes were written, or -1 on error
> + */
> +
> +int qio_channel_writev_full_all(QIOChannel *ioc,
> +                           const struct iovec *iov,
> +                           size_t niov,
> +                           int *fds, size_t nfds,
> +                           Error **errp);
>
>  #endif /* QIO_CHANNEL_H */
> diff --git a/io/channel.c b/io/channel.c
> index 93d449d..255dd46 100644
> --- a/io/channel.c
> +++ b/io/channel.c
> @@ -190,6 +190,51 @@ int qio_channel_writev_all(QIOChannel *ioc,
>      return ret;
>  }
>
> +int qio_channel_writev_full_all(QIOChannel *ioc,
> +                                const struct iovec *iov,
> +                                size_t niov,
> +                                int *fds, size_t nfds,
> +                                Error **errp)
> +{
>

Please make qio_channel_writev_all() call qio_channel_writev_full_all() to
avoid logic duplication.


> +    int ret = -1;
> +    struct iovec *local_iov = g_new(struct iovec, niov);
> +    struct iovec *local_iov_head = local_iov;
> +    unsigned int nlocal_iov = niov;
> +
> +    nlocal_iov = iov_copy(local_iov, nlocal_iov,
> +                          iov, niov,
> +                          0, iov_size(iov, niov));
> +
> +    while (nlocal_iov > 0) {
> +        ssize_t len;
> +        len = qio_channel_writev_full(ioc, local_iov, nlocal_iov, fds,
> +                                      nfds, errp);
> +        if (len == QIO_CHANNEL_ERR_BLOCK) {
> +            if (qemu_in_coroutine()) {
> +                qio_channel_yield(ioc, G_IO_OUT);
> +            } else {
> +                qio_channel_wait(ioc, G_IO_OUT);
> +            }
> +            continue;
> +        }
> +        if (len < 0) {
> +            goto cleanup;
> +        }
> +
> +        iov_discard_front(&local_iov, &nlocal_iov, len);
> +
> +        if (len > 0) {
> +            fds = NULL;
> +            nfds = 0;
> +        }
> +    }
> +
> +    ret = 0;
> + cleanup:
> +    g_free(local_iov_head);
> +    return ret;
> +}
> +
>  ssize_t qio_channel_readv(QIOChannel *ioc,
>                            const struct iovec *iov,
>                            size_t niov,
> --
> 1.8.3.1
>
>

-- 
Marc-André Lureau

[-- Attachment #2: Type: text/html, Size: 5454 bytes --]

  reply	other threads:[~2020-12-04 14:42 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-01 20:22 [PATCH v12 00/19] Initial support for multi-process Qemu Jagannathan Raman
2020-12-01 20:22 ` [PATCH v12 01/19] multi-process: add the concept description to docs/devel/qemu-multiprocess Jagannathan Raman
2020-12-01 20:22 ` [PATCH v12 02/19] multi-process: add configure and usage information Jagannathan Raman
2020-12-04 14:10   ` Marc-André Lureau
2020-12-04 14:37   ` Daniel P. Berrangé
2020-12-09 16:20     ` Jag Raman
2020-12-01 20:22 ` [PATCH v12 03/19] memory: alloc RAM from file at offset Jagannathan Raman
2020-12-04 14:13   ` Marc-André Lureau
2020-12-04 14:18     ` Marc-André Lureau
2020-12-01 20:22 ` [PATCH v12 04/19] multi-process: Add config option for multi-process QEMU Jagannathan Raman
2020-12-01 20:22 ` [PATCH v12 05/19] multi-process: setup PCI host bridge for remote device Jagannathan Raman
2020-12-04 14:29   ` Marc-André Lureau
2020-12-04 14:32   ` Marc-André Lureau
2020-12-01 20:22 ` [PATCH v12 06/19] multi-process: setup a machine object for remote device process Jagannathan Raman
2020-12-04 14:35   ` Marc-André Lureau
2020-12-09 16:56     ` Jag Raman
2020-12-01 20:22 ` [PATCH v12 07/19] multi-process: add qio channel function to transmit data and fds Jagannathan Raman
2020-12-04 14:40   ` Marc-André Lureau [this message]
2020-12-01 20:22 ` [PATCH v12 08/19] multi-process: define MPQemuMsg format and transmission functions Jagannathan Raman
2020-12-07 13:18   ` Marc-André Lureau
2020-12-10  1:40     ` Elena Ufimtseva
2020-12-10  8:20       ` Marc-André Lureau
2020-12-10 12:53         ` Elena Ufimtseva
2020-12-01 20:22 ` [PATCH v12 09/19] multi-process: Initialize message handler in remote device Jagannathan Raman
2020-12-07 13:33   ` Marc-André Lureau
2020-12-01 20:22 ` [PATCH v12 10/19] multi-process: Associate fd of a PCIDevice with its object Jagannathan Raman
2020-12-07 14:03   ` Marc-André Lureau
2020-12-08 12:07     ` Marc-André Lureau
2020-12-01 20:22 ` [PATCH v12 11/19] multi-process: setup memory manager for remote device Jagannathan Raman
2020-12-08 11:54   ` Marc-André Lureau
2020-12-08 11:58   ` Marc-André Lureau
2020-12-01 20:22 ` [PATCH v12 12/19] multi-process: introduce proxy object Jagannathan Raman
2020-12-08 12:23   ` Marc-André Lureau
2020-12-01 20:22 ` [PATCH v12 13/19] multi-process: add proxy communication functions Jagannathan Raman
2020-12-08 12:39   ` Marc-André Lureau
2020-12-01 20:22 ` [PATCH v12 14/19] multi-process: Forward PCI config space acceses to the remote process Jagannathan Raman
2020-12-08 12:52   ` Marc-André Lureau
2020-12-01 20:22 ` [PATCH v12 15/19] multi-process: PCI BAR read/write handling for proxy & remote endpoints Jagannathan Raman
2020-12-01 20:22 ` [PATCH v12 16/19] multi-process: Synchronize remote memory Jagannathan Raman
2020-12-08 13:57   ` Marc-André Lureau
2020-12-09 16:18     ` Jag Raman
2020-12-09 21:28       ` Marc-André Lureau
2020-12-10 16:57         ` Jag Raman
2020-12-01 20:22 ` [PATCH v12 17/19] multi-process: create IOHUB object to handle irq Jagannathan Raman
2020-12-01 20:22 ` [PATCH v12 18/19] multi-process: Retrieve PCI info from remote process Jagannathan Raman
2020-12-01 20:22 ` [PATCH v12 19/19] multi-process: perform device reset in the " Jagannathan Raman
2020-12-03  9:14 ` [PATCH v12 00/19] Initial support for multi-process Qemu Stefan Hajnoczi
2020-12-03 19:26   ` Elena Ufimtseva
2020-12-03 20:40   ` Peter Maydell
2020-12-10 11:13     ` Stefan Hajnoczi
2020-12-10 11:24       ` Peter Maydell
2020-12-10 15:31         ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJ+F1CKk-RrQY=n2SVw4M699jzQYJjZWEatHJCZT7=RtboW=OQ@mail.gmail.com' \
    --to=marcandre.lureau@gmail.com \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=elena.ufimtseva@oracle.com \
    --cc=fam@euphon.net \
    --cc=felipe@nutanix.com \
    --cc=jag.raman@oracle.com \
    --cc=john.g.johnson@oracle.com \
    --cc=kanth.ghatraju@oracle.com \
    --cc=konrad.wilk@oracle.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=ross.lagerwall@citrix.com \
    --cc=rth@twiddle.net \
    --cc=stefanha@redhat.com \
    --cc=swapnil.ingle@nutanix.com \
    --cc=thanos.makatos@nutanix.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.