qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] migration/fd: abort migration if receive POLLHUP event
@ 2018-04-21  7:22 Wang Xin
  2018-04-24 17:16 ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 7+ messages in thread
From: Wang Xin @ 2018-04-21  7:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, quintela, arei.gonglei, Wang Xin

If the fd socket peer closed shortly, ppoll may receive a POLLHUP
event before the expected POLLIN event, and qemu will do nothing
but goes into an infinite loop of the POLLHUP event.

So, abort the migration if we receive a POLLHUP event.

Signed-off-by: Wang Xin <wangxinxin.wang@huawei.com>

diff --git a/migration/fd.c b/migration/fd.c
index cd06182..5932c87 100644
--- a/migration/fd.c
+++ b/migration/fd.c
@@ -15,6 +15,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/error-report.h"
 #include "channel.h"
 #include "fd.h"
 #include "monitor/monitor.h"
@@ -46,6 +47,11 @@ static gboolean fd_accept_incoming_migration(QIOChannel *ioc,
                                              GIOCondition condition,
                                              gpointer opaque)
 {
+    if (condition & G_IO_HUP) {
+        error_report("The migration peer closed, job abort");
+        exit(EXIT_FAILURE);
+    }
+
     migration_channel_process_incoming(ioc);
     object_unref(OBJECT(ioc));
     return G_SOURCE_REMOVE;
@@ -67,7 +73,7 @@ void fd_start_incoming_migration(const char *infd, Error **errp)
 
     qio_channel_set_name(QIO_CHANNEL(ioc), "migration-fd-incoming");
     qio_channel_add_watch(ioc,
-                          G_IO_IN,
+                          G_IO_IN | G_IO_HUP,
                           fd_accept_incoming_migration,
                           NULL,
                           NULL);
-- 
2.8.1.windows.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-04-25  8:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-21  7:22 [Qemu-devel] [PATCH] migration/fd: abort migration if receive POLLHUP event Wang Xin
2018-04-24 17:16 ` Dr. David Alan Gilbert
2018-04-24 18:24   ` Daniel P. Berrangé
2018-04-25  3:14     ` Peter Xu
2018-04-25  3:31       ` Peter Xu
2018-04-25  7:29         ` wangxin (U)
2018-04-25  8:03           ` Daniel P. Berrangé

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).