All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark McLoughlin <markmc@redhat.com>
To: Uri Lublin <uril@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] migrate_fd_close: delete associated io-handler before closing the fd
Date: Mon, 08 Jun 2009 16:49:42 +0100	[thread overview]
Message-ID: <1244476182.3632.40.camel@blaa> (raw)
In-Reply-To: <1244460481-13575-1-git-send-email-uril@redhat.com>

On Mon, 2009-06-08 at 14:28 +0300, Uri Lublin wrote:
> It may happen that the io-handler is still registered. That causes
> select() to return with EBADF, not calling handlers for other fds.
> 
> The io-handler would be registered when (on the source) the whole state
> was written but not yet flushed. For example when using QEMUFileBuffered,
> (tcp-migration) there may be data left in a buffer waiting to be transferred.
> In such a case buffered_close() calls buffered_flush() which calls
> migrate_fd_put_buffer, which may, upon EAGAIN, register migrate_fd_put_notify
> as a handler.
> 
> Signed-off-by: Uri Lublin <uril@redhat.com>
> ---
>  migration.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/migration.c b/migration.c
> index 401383c..57f2a52 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -301,5 +301,7 @@ void migrate_fd_wait_for_unfreeze(void *opaque)
>  int migrate_fd_close(void *opaque)
>  {
>      FdMigrationState *s = opaque;
> +
> +    qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);

Looks good, but perhaps a comment explaining how the I/O handler could
possibly be registered here would be useful - at first glance, it seemed
to me that the I/O handler should always be de-registered in
migrate_fd_cleanup() before getting here.

The key to understanding the problem is that qemu_fclose() on a buffered
file can cause I/O to be flushed.

Reviewed-by: Mark McLoughlin <markmc@redhat.com>

Cheers,
Mark.

  reply	other threads:[~2009-06-08 15:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-08 11:28 [Qemu-devel] [PATCH] migrate_fd_close: delete associated io-handler before closing the fd Uri Lublin
2009-06-08 15:49 ` Mark McLoughlin [this message]
2009-06-08 15:56   ` Uri Lublin
2009-06-08 16:38     ` Mark McLoughlin
2009-06-08 17:02       ` 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=1244476182.3632.40.camel@blaa \
    --to=markmc@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 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.