qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Elena Ufimtseva <elena.ufimtseva@oracle.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: Fam Zheng <fam@euphon.net>,
	John G Johnson <john.g.johnson@oracle.com>,
	Swapnil Ingle <swapnil.ingle@nutanix.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	QEMU <qemu-devel@nongnu.org>, Gerd Hoffmann <kraxel@redhat.com>,
	Jagannathan Raman <jag.raman@oracle.com>,
	Juan Quintela <quintela@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>,
	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 v13 07/19] multi-process: add qio channel function to transmit data and fds
Date: Tue, 15 Dec 2020 12:42:41 -0800	[thread overview]
Message-ID: <20201215204241.GA17643@heatpipe> (raw)
In-Reply-To: <CAJ+F1CJLKJR5UirK106zKn5bM8rr1cDZyQwZ66QdMJLS-k_zBA@mail.gmail.com>

On Tue, Dec 15, 2020 at 02:49:22PM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Mon, Dec 14, 2020 at 9:15 AM Jagannathan Raman <jag.raman@oracle.com>
> wrote:
> 
> > From: Elena Ufimtseva <elena.ufimtseva@oracle.com>
> >
> > Adds QIO channel functions that transmit and receive iovs along with 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 | 50 +++++++++++++++++++++++++++++++++++++++++
> >  io/channel.c         | 63
> > +++++++++++++++++++++++++++++++++++++++++++++++++++-
> >  2 files changed, 112 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/io/channel.h b/include/io/channel.h
> > index 4d6fe45..c2d9836 100644
> > --- a/include/io/channel.h
> > +++ b/include/io/channel.h
> > @@ -774,4 +774,54 @@ void qio_channel_set_aio_fd_handler(QIOChannel *ioc,
> >                                      IOHandler *io_write,
> >                                      void *opaque);
> >
> > +/**
> > + * qio_channel_readv_full_all:
> > + * @ioc: the channel object
> > + * @iov: the array of memory regions to read data to
> > + * @niov: the length of the @iov array
> > + * @fds: an array of file handles to read
> > + * @nfds: number of file handles in @fds
> > + * @errp: pointer to a NULL-initialized error object
> > + *
> > + *
> > + * Behaves like qio_channel_readvv_full but will attempt
> > + * to read all data specified (file handles and memory regions).
> > + * The function will wait for all requested data
> > + * to be read, yielding from the current coroutine
> > + * if required.
> > + *
> > + * Returns: 0 if all bytes were read, or -1 on error
> > + */
> > +
> > +int qio_channel_readv_full_all(QIOChannel *ioc,
> > +                                const struct iovec *iov,
> > +                                size_t niov,
> > +                                int **fds, size_t *nfds,
> > +                                Error **errp);
> > +
> > +/**
> > + * 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..13b0e7a 100644
> > --- a/io/channel.c
> > +++ b/io/channel.c
> > @@ -152,15 +152,72 @@ int qio_channel_readv_all(QIOChannel *ioc,
> >      return ret;
> >  }
> >
> > +int qio_channel_readv_full_all(QIOChannel *ioc,
> > +                                const struct iovec *iov,
> > +                                size_t niov,
> > +                                int **fds, size_t *nfds,
> > +                                Error **errp)
> > +{
> > +    int ret = -1;
> > +    struct iovec *local_iov = g_new(struct iovec, niov);
> > +    struct iovec *local_iov_head = local_iov;
> > +    unsigned int nlocal_iov = niov;
> > +    int **local_fds = fds;
> > +    size_t *local_nfds = nfds;
> > +
> > +    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_readv_full(ioc, local_iov, nlocal_iov,
> > local_fds,
> > +                                     local_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) {
> > +            ret = len;
> > +            goto cleanup;
> > +        }
> > +
> > +        iov_discard_front(&local_iov, &nlocal_iov, len);
> > +
> > +        local_fds = NULL;
> > +        local_nfds = 0;
> > +    }
> > +
> > +    ret = 1;
> > + cleanup:
> > +    g_free(local_iov_head);
> > +    return ret;
> > +}
> > +
> >
> 
> I suggest to adapt the code so qio_channel_readv_all_eof() calls
> qio_channel_readv_full_all().
> 
> You may want to split this patch in 2 parts: the read and write parts.
> 
>

Thank you Marc-Andre, will do.

Elena
> >  int qio_channel_writev_all(QIOChannel *ioc,
> >                             const struct iovec *iov,
> >                             size_t niov,
> >                             Error **errp)
> >  {
> > +    return qio_channel_writev_full_all(ioc, iov, niov, NULL, 0, errp);
> > +}
> > +
> > +int qio_channel_writev_full_all(QIOChannel *ioc,
> > +                                const struct iovec *iov,
> > +                                size_t niov,
> > +                                int *fds, size_t nfds,
> > +                                Error **errp)
> > +{
> >      int ret = -1;
> >      struct iovec *local_iov = g_new(struct iovec, niov);
> >      struct iovec *local_iov_head = local_iov;
> >      unsigned int nlocal_iov = niov;
> > +    int *local_fds = fds;
> > +    size_t local_nfds = nfds;
> >
> >      nlocal_iov = iov_copy(local_iov, nlocal_iov,
> >                            iov, niov,
> > @@ -168,7 +225,8 @@ int qio_channel_writev_all(QIOChannel *ioc,
> >
> >      while (nlocal_iov > 0) {
> >          ssize_t len;
> > -        len = qio_channel_writev(ioc, local_iov, nlocal_iov, errp);
> > +        len = qio_channel_writev_full(ioc, local_iov, nlocal_iov,
> > local_fds,
> > +                                      local_nfds, errp);
> >          if (len == QIO_CHANNEL_ERR_BLOCK) {
> >              if (qemu_in_coroutine()) {
> >                  qio_channel_yield(ioc, G_IO_OUT);
> > @@ -182,6 +240,9 @@ int qio_channel_writev_all(QIOChannel *ioc,
> >          }
> >
> >          iov_discard_front(&local_iov, &nlocal_iov, len);
> > +
> > +        local_fds = NULL;
> > +        local_nfds = 0;
> >      }
> >
> >      ret = 0;
> > --
> > 1.8.3.1
> >
> >
> 
> -- 
> Marc-André Lureau


  reply	other threads:[~2020-12-15 20:44 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14  5:14 [PATCH v13 00/19] Initial support for multi-process Qemu Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 01/19] multi-process: add the concept description to docs/devel/qemu-multiprocess Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 02/19] multi-process: add configure and usage information Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 03/19] memory: alloc RAM from file at offset Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 04/19] multi-process: Add config option for multi-process QEMU Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 05/19] multi-process: setup PCI host bridge for remote device Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 06/19] multi-process: setup a machine object for remote device process Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 07/19] multi-process: add qio channel function to transmit data and fds Jagannathan Raman
2020-12-15 10:49   ` Marc-André Lureau
2020-12-15 20:42     ` Elena Ufimtseva [this message]
2020-12-15 21:22     ` Elena Ufimtseva
2020-12-16 10:02       ` Stefan Hajnoczi
2020-12-14  5:14 ` [PATCH v13 08/19] multi-process: define MPQemuMsg format and transmission functions Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 09/19] multi-process: Initialize message handler in remote device Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 10/19] multi-process: Associate fd of a PCIDevice with its object Jagannathan Raman
2020-12-14 21:23   ` Stefan Hajnoczi
2020-12-16 13:43   ` Marc-André Lureau
2020-12-16 17:06     ` Jag Raman
2020-12-16 17:34       ` Marc-André Lureau
2020-12-16 17:39         ` Jag Raman
2020-12-14  5:14 ` [PATCH v13 11/19] multi-process: setup memory manager for remote device Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 12/19] multi-process: introduce proxy object Jagannathan Raman
2020-12-16 13:45   ` Marc-André Lureau
2020-12-14  5:14 ` [PATCH v13 13/19] multi-process: add proxy communication functions Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 14/19] multi-process: Forward PCI config space acceses to the remote process Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 15/19] multi-process: PCI BAR read/write handling for proxy & remote endpoints Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 16/19] multi-process: Synchronize remote memory Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 17/19] multi-process: create IOHUB object to handle irq Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 18/19] multi-process: Retrieve PCI info from remote process Jagannathan Raman
2020-12-14  5:14 ` [PATCH v13 19/19] multi-process: perform device reset in the " Jagannathan Raman
2020-12-14 21:17 ` [PATCH v13 00/19] Initial support for multi-process Qemu Stefan Hajnoczi
2020-12-14 23:49 ` Jag Raman
2020-12-15 10:45 ` 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=20201215204241.GA17643@heatpipe \
    --to=elena.ufimtseva@oracle.com \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.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=marcandre.lureau@gmail.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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).