From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Jag 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-level <qemu-devel@nongnu.org>,
kraxel@redhat.com, quintela@redhat.com, mst@redhat.com,
armbru@redhat.com, kanth.ghatraju@oracle.com, felipe@nutanix.com,
thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com,
dgilbert@redhat.com, alex.williamson@redhat.com,
Stefan Hajnoczi <stefanha@redhat.com>,
pbonzini@redhat.com, kwolf@redhat.com, mreitz@redhat.com,
ross.lagerwall@citrix.com, marcandre.lureau@gmail.com,
thanos.makatos@nutanix.com
Subject: Re: [PATCH v19 08/20] io: add qio_channel_readv_full_all_eof & qio_channel_readv_full_all helpers
Date: Thu, 14 Jan 2021 18:00:35 +0000 [thread overview]
Message-ID: <20210114180035.GY1643043@redhat.com> (raw)
In-Reply-To: <CA0E47D0-F1F5-4825-ABB7-BE73AAD3E375@oracle.com>
On Thu, Jan 14, 2021 at 12:55:58PM -0500, Jag Raman wrote:
>
>
> > On Jan 14, 2021, at 11:27 AM, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> >
> > On Thu, Jan 14, 2021 at 10:40:03AM -0500, Jagannathan Raman wrote:
> >> +int qio_channel_readv_full_all(QIOChannel *ioc,
> >> + const struct iovec *iov,
> >> + size_t niov,
> >> + int **fds, size_t *nfds,
> >> + Error **errp)
> >> {
> >> - int ret = qio_channel_readv_all_eof(ioc, iov, niov, errp);
> >> + int ret = qio_channel_readv_full_all_eof(ioc, iov, niov, fds, nfds, errp);
> >>
> >> if (ret == 0) {
> >> - ret = -1;
> >> error_setg(errp,
> >> "Unexpected end-of-file before all bytes were read");
> >
> > qio_channel_readv_full_all_eof() can read file descriptors but no data
> > and return 0.
> >
> > Here that case is converted into an error and the file descriptors
> > aren't closed, freed, and fds/nfds isn't cleared.
>
> That’s a valid point. I’m wondering if the fix for this case should be in
> qio_channel_readv_full_all_eof(), instead of here.
>
> qio_channel_readv_full_all_eof() should probably return error (-1) if the
> amount of data read does not match iov_size(). If the caller is only expecting
> to read fds, and not any data, it would indicate that by setting iov to NULL
> and/or setting niov=0. If the caller is setting these parameters, it means it is
> expecting data.Does that sound good?
The API spec for the existing _eof() methods says:
* The function will wait for all requested data
* to be read, yielding from the current coroutine
* if required.
*
* If end-of-file occurs before any data is read,
* no error is reported; otherwise, if it occurs
* before all requested data has been read, an error
* will be reported.
IOW, return '0' is *only* valid if we've not read anything. I consider
file descriptors to be something.
IOW, qio_channel_readv_full_all_eof must only return 0, if it didn't
read any data and also didn't receive any file descriptors. So yeah,
we must return -1 in the scenario Stefan describes
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 :|
next prev parent reply other threads:[~2021-01-14 18:51 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-14 15:39 [PATCH v19 00/20] Initial support for multi-process Qemu Jagannathan Raman
2021-01-14 15:39 ` [PATCH v19 01/20] multi-process: add the concept description to docs/devel/qemu-multiprocess Jagannathan Raman
2021-01-14 15:39 ` [PATCH v19 02/20] multi-process: add configure and usage information Jagannathan Raman
2021-01-14 15:39 ` [PATCH v19 03/20] memory: alloc RAM from file at offset Jagannathan Raman
2021-01-14 15:39 ` [PATCH v19 04/20] multi-process: Add config option for multi-process QEMU Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 05/20] multi-process: setup PCI host bridge for remote device Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 06/20] multi-process: setup a machine object for remote device process Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 07/20] io: add qio_channel_writev_full_all helper Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 08/20] io: add qio_channel_readv_full_all_eof & qio_channel_readv_full_all helpers Jagannathan Raman
2021-01-14 16:27 ` Stefan Hajnoczi
2021-01-14 17:55 ` Jag Raman
2021-01-14 18:00 ` Daniel P. Berrangé [this message]
2021-01-14 18:24 ` Jag Raman
2021-01-15 9:20 ` Stefan Hajnoczi
2021-01-15 13:46 ` Jag Raman
2021-01-15 18:19 ` Jag Raman
2021-01-18 16:35 ` Stefan Hajnoczi
2021-01-14 15:40 ` [PATCH v19 09/20] multi-process: define MPQemuMsg format and transmission functions Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 10/20] multi-process: Initialize message handler in remote device Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 11/20] multi-process: Associate fd of a PCIDevice with its object Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 12/20] multi-process: setup memory manager for remote device Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 13/20] multi-process: introduce proxy object Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 14/20] multi-process: add proxy communication functions Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 15/20] multi-process: Forward PCI config space acceses to the remote process Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 16/20] multi-process: PCI BAR read/write handling for proxy & remote endpoints Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 17/20] multi-process: Synchronize remote memory Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 18/20] multi-process: create IOHUB object to handle irq Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 19/20] multi-process: Retrieve PCI info from remote process Jagannathan Raman
2021-01-14 15:40 ` [PATCH v19 20/20] multi-process: perform device reset in the " Jagannathan Raman
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=20210114180035.GY1643043@redhat.com \
--to=berrange@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=armbru@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=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).