From: "Michael S. Tsirkin" <mst@redhat.com>
To: Uri Lublin <uril@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] exec-migration: handle EINTR in popen_get_buffer()
Date: Tue, 9 Jun 2009 15:20:57 +0300 [thread overview]
Message-ID: <20090609122057.GF3476@redhat.com> (raw)
In-Reply-To: <20090608175452.GA4995@redhat.com>
On Mon, Jun 08, 2009 at 08:54:52PM +0300, Michael S. Tsirkin wrote:
> On Mon, Jun 08, 2009 at 07:27:21PM +0300, Uri Lublin wrote:
> > Sometimes, upon interrupt, fread returns with no data, and
> > the (incoming exec) migration fails.
> >
> > Fix by retrying on such a case.
> >
> > Signed-off-by: Uri Lublin <uril@redhat.com>
> > ---
> > savevm.c | 9 ++++++++-
> > 1 files changed, 8 insertions(+), 1 deletions(-)
> >
> > diff --git a/savevm.c b/savevm.c
> > index 248aea3..df2486d 100644
> > --- a/savevm.c
> > +++ b/savevm.c
> > @@ -215,7 +215,14 @@ static int popen_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, int s
> > static int popen_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size)
> > {
> > QEMUFilePopen *s = opaque;
> > - return fread(buf, 1, size, s->popen_file);
> > + FILE *fp = s->popen_file;
> > + int bytes;
> > +
> > + do {
> > + clearerr(fp);
>
> Would it make sense to only clearerr on EINTR - if we intend to retry?
>
> > + bytes = fread(buf, 1, size, fp);
> > + } while ((bytes == 0) && ferror(fp) && (errno == EINTR));
>
>
> This does nothing about partial reads (bytes != 0)
> I think it's intentional because the user actually retries
> partial reads. Right?
>
> > + return bytes;
> > }
> >
> > static int popen_close(void *opaque)
>
> Looking at qemu_fill_buffer, it seems that it is enough to set
> bytes to -EAGAIN. User will then retry. Correct?
Looking at the code some more, at least qemu_get_byte really seems to
expect a reliable read underneath, so it won't work. Generally the fact
that qemu_get_byte returns 0 on error seems broken to me maybe we could
fix that and then have a single loop retrying reads. But that's for
another patch.
Acked-by: Michael S. Tsirkin <mst@redhat.com>
--
MST
next prev parent reply other threads:[~2009-06-09 12:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-08 16:27 [Qemu-devel] [PATCH] exec-migration: handle EINTR in popen_get_buffer() Uri Lublin
2009-06-08 16:55 ` Blue Swirl
2009-06-09 10:49 ` Uri Lublin
2009-06-09 14:51 ` Blue Swirl
2009-06-08 17:54 ` Michael S. Tsirkin
2009-06-09 12:20 ` Michael S. Tsirkin [this message]
2009-06-09 12:32 ` Uri Lublin
-- strict thread matches above, loose matches on Subject: below --
2009-06-02 16:49 Uri Lublin
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=20090609122057.GF3476@redhat.com \
--to=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=uril@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).