From: Anthony Liguori <anthony@codemonkey.ws>
To: "Zhanghaoyu (A)" <haoyu.zhang@huawei.com>,
qemu-devel <qemu-devel@nongnu.org>,
Eric Blake <eblake@redhat.com>
Cc: Luonengjun <luonengjun@huawei.com>,
"Wangrui (K)" <moon.wangrui@huawei.com>,
"Huangweidong (C)" <weidong.huang@huawei.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Zengjunliang <zengjunliang@huawei.com>
Subject: Re: [Qemu-devel] [PATCH] migration: add timeout option for tcp migration send/receive socket
Date: Tue, 02 Jul 2013 09:53:58 -0500 [thread overview]
Message-ID: <8761wtqagp.fsf@codemonkey.ws> (raw)
In-Reply-To: <D3E216785288A145B7BC975F83A2ED103FEE66F7@szxeml556-mbx.china.huawei.com>
"Zhanghaoyu (A)" <haoyu.zhang@huawei.com> writes:
> When network disconnection occurs during live migration, the migration thread will be stuck in the function sendmsg(), as the migration socket is in ~O_NONBLOCK mode now.
>
> Signed-off-by: Zeng Junliang <zengjunliang@huawei.com>
Unconditionally setting an arbitrary timeout is a bad idea.
Should we send a signal on cancel to break the migration thread out of
sendmsg?
Regards,
Anthony Liguori
> ---
> include/migration/migration.h | 4 ++++
> migration-tcp.c | 23 ++++++++++++++++++++++-
> 2 files changed, 26 insertions(+), 1 deletions(-)
>
> diff --git a/include/migration/migration.h b/include/migration/migration.h
> index f0640e0..1a56248 100644
> --- a/include/migration/migration.h
> +++ b/include/migration/migration.h
> @@ -23,6 +23,8 @@
> #include "qapi-types.h"
> #include "exec/cpu-common.h"
>
> +#define QEMU_MIGRATE_SOCKET_OP_TIMEOUT 60
> +
> struct MigrationParams {
> bool blk;
> bool shared;
> @@ -109,6 +111,8 @@ uint64_t xbzrle_mig_pages_transferred(void);
> uint64_t xbzrle_mig_pages_overflow(void);
> uint64_t xbzrle_mig_pages_cache_miss(void);
>
> +int tcp_migration_set_socket_timeout(int fd, int optname, int timeout_in_sec);
> +
> /**
> * @migrate_add_blocker - prevent migration from proceeding
> *
> diff --git a/migration-tcp.c b/migration-tcp.c
> index b20ee58..860238b 100644
> --- a/migration-tcp.c
> +++ b/migration-tcp.c
> @@ -29,11 +29,28 @@
> do { } while (0)
> #endif
>
> +int tcp_migration_set_socket_timeout(int fd, int optname, int timeout_in_sec)
> +{
> + struct timeval timeout;
> + int ret = 0;
> +
> + if (fd < 0 || timeout_in_sec < 0 ||
> + (optname != SO_RCVTIMEO && optname != SO_SNDTIMEO))
> + return -1;
> +
> + timeout.tv_sec = timeout_in_sec;
> + timeout.tv_usec = 0;
> +
> + ret = qemu_setsockopt(fd, SOL_SOCKET, optname, &timeout, sizeof(timeout));
> +
> + return ret;
> +}
> +
> static void tcp_wait_for_connect(int fd, void *opaque)
> {
> MigrationState *s = opaque;
>
> - if (fd < 0) {
> + if (tcp_migration_set_socket_timeout(fd, SO_SNDTIMEO, QEMU_MIGRATE_SOCKET_OP_TIMEOUT) < 0) {
> DPRINTF("migrate connect error\n");
> s->file = NULL;
> migrate_fd_error(s);
> @@ -76,6 +93,10 @@ static void tcp_accept_incoming_migration(void *opaque)
> goto out;
> }
>
> + if (tcp_migration_set_socket_timeout(c, SO_RCVTIMEO, QEMU_MIGRATE_SOCKET_OP_TIMEOUT) < 0) {
> + fprintf(stderr, "set tcp migration socket receive timeout error\n");
> + goto out;
> + }
> process_incoming_migration(f);
> return;
>
> --
> 1.7.3.1.msysgit.0
prev parent reply other threads:[~2013-07-02 14:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-30 5:12 [Qemu-devel] [PATCH] migration: add timeout option for tcp migration send/receive socket Zhanghaoyu (A)
2013-07-02 14:53 ` Anthony Liguori [this message]
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=8761wtqagp.fsf@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=eblake@redhat.com \
--cc=haoyu.zhang@huawei.com \
--cc=luonengjun@huawei.com \
--cc=moon.wangrui@huawei.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=weidong.huang@huawei.com \
--cc=zengjunliang@huawei.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).