From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Prasad Pandit <ppandit@redhat.com>
Cc: qemu-devel@nongnu.org, Juraj Marcin <jmarcin@redhat.com>,
Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>
Subject: Re: [PATCH 1/2] migration: simplify error reporting after channel read
Date: Mon, 4 Aug 2025 11:22:50 +0100 [thread overview]
Message-ID: <aJCJ-tqqimnrDDgZ@redhat.com> (raw)
In-Reply-To: <CAE8KmOxzskHzPsfUCZP56qmFHC7Rgi8x0HacUuZgzUv4UNiYyQ@mail.gmail.com>
On Mon, Aug 04, 2025 at 03:48:59PM +0530, Prasad Pandit wrote:
> On Sat, 2 Aug 2025 at 00:06, Daniel P. Berrangé <berrange@redhat.com> wrote:
> > The code handling the return value of qio_channel_read proceses
> > len == 0 (EOF) separately from len < 1 (error), but in both
> > cases ends up calling qemu_file_set_error_obj() with -EIO as the
> > errno. This logic can be merged into one codepath to simplify it.
> >
> > } else {
> > qio_channel_wait(f->ioc, G_IO_IN);
> > }
> > - } else if (len < 0) {
> > - len = -EIO;
> > }
> > } while (len == QIO_CHANNEL_ERR_BLOCK);
> >
> > if (len > 0) {
> > f->buf_size += len;
> > - } else if (len == 0) {
> > - qemu_file_set_error_obj(f, -EIO, local_error);
> > } else {
> > - qemu_file_set_error_obj(f, len, local_error);
> > + qemu_file_set_error_obj(f, -EIO, local_error);
> > }
>
> * But should _file_set_error_obj(... -EIO) be called for len == 0
> (EOF) case? ie. function is trying to read from a file, at some point
> it is bound to reach EOF. '-EIO' indicates an I/O error, reaching EOF
> could not be an error. Maybe we could just return zero(0) ? (just
> checking)
The migration protocol knows whether it is expecting more data or not.
If we want more data, then a call to qemu_fill_buffer must successfully
read at least 1 byte.
If we don't want more data, then we would not have triggered any call
to qemu_fill_buffer.
Thus, a call to qemu_fill_buffer which gets EOF is an error scenario.
With 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:[~2025-08-04 10:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-01 17:02 [PATCH for-10.1 0/2] migration: actually make gnutls workaround functional Daniel P. Berrangé
2025-08-01 17:02 ` [PATCH 1/2] migration: simplify error reporting after channel read Daniel P. Berrangé
2025-08-04 10:18 ` Prasad Pandit
2025-08-04 10:22 ` Daniel P. Berrangé [this message]
2025-08-04 11:03 ` Prasad Pandit
2025-08-06 0:41 ` Peter Xu
2025-08-01 17:02 ` [PATCH 2/2] migration: fix workaround for gnutls thread safety Daniel P. Berrangé
2025-08-04 10:29 ` Prasad Pandit
2025-08-04 18:13 ` Fabiano Rosas
2025-08-04 17:53 ` [PATCH for-10.1 0/2] migration: actually make gnutls workaround functional Juraj Marcin
2025-08-04 19:27 ` Fabiano Rosas
2025-08-05 10:09 ` Daniel P. Berrangé
2025-08-05 13:44 ` Fabiano Rosas
2025-08-05 14:18 ` Daniel P. Berrangé
2025-08-05 15:28 ` Fabiano Rosas
2025-08-05 14:52 ` Juraj Marcin
2025-08-06 14:54 ` Peter Xu
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=aJCJ-tqqimnrDDgZ@redhat.com \
--to=berrange@redhat.com \
--cc=farosas@suse.de \
--cc=jmarcin@redhat.com \
--cc=peterx@redhat.com \
--cc=ppandit@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).