4382ef6
From a0591dc91ad795ffb47476b37730e46977a6be36 Mon Sep 17 00:00:00 2001
4382ef6
From: Juan Quintela <quintela@redhat.com>
4382ef6
Date: Tue, 9 Mar 2010 23:58:50 +0100
4382ef6
Subject: [PATCH] migration: Clear fd also in error cases
4382ef6
4382ef6
Not clearing the fd and closing the file makes qemu spin using 100%CPU
4382ef6
after incoming migration error.
4382ef6
4382ef6
See for instance bug:
4382ef6
https://bugzilla.redhat.com/show_bug.cgi?id=518032
4382ef6
4382ef6
Signed-off-by: Juan Quintela <quintela@trasno.org>
4382ef6
---
4382ef6
 migration-exec.c |    3 +--
4382ef6
 migration-fd.c   |    3 +--
4382ef6
 migration-tcp.c  |    5 ++---
4382ef6
 migration-unix.c |    5 ++---
4382ef6
 4 files changed, 6 insertions(+), 10 deletions(-)
4382ef6
4382ef6
diff --git a/migration-exec.c b/migration-exec.c
4382ef6
index 87f645b..e57a55d 100644
4382ef6
--- a/migration-exec.c
4382ef6
+++ b/migration-exec.c
4382ef6
@@ -120,12 +120,11 @@ static void exec_accept_incoming_migration(void *opaque)
4382ef6
     }
4382ef6
     qemu_announce_self();
4382ef6
     dprintf("successfully loaded vm state\n");
4382ef6
-    /* we've successfully migrated, close the fd */
4382ef6
-    qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
4382ef6
     if (autostart)
4382ef6
         vm_start();
4382ef6
4382ef6
 err:
4382ef6
+    qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
4382ef6
     qemu_fclose(f);
4382ef6
 }
4382ef6
4382ef6
diff --git a/migration-fd.c b/migration-fd.c
4382ef6
index ef7edbc..7325d13 100644
4382ef6
--- a/migration-fd.c
4382ef6
+++ b/migration-fd.c
4382ef6
@@ -113,12 +113,11 @@ static void fd_accept_incoming_migration(void *opaque)
4382ef6
     }
4382ef6
     qemu_announce_self();
4382ef6
     dprintf("successfully loaded vm state\n");
4382ef6
-    /* we've successfully migrated, close the fd */
4382ef6
-    qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
4382ef6
     if (autostart)
4382ef6
         vm_start();
4382ef6
4382ef6
 err:
4382ef6
+    qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
4382ef6
     qemu_fclose(f);
4382ef6
 }
4382ef6
4382ef6
diff --git a/migration-tcp.c b/migration-tcp.c
4382ef6
index 2cfa8cb..c328e73 100644
4382ef6
--- a/migration-tcp.c
4382ef6
+++ b/migration-tcp.c
4382ef6
@@ -170,15 +170,14 @@ static void tcp_accept_incoming_migration(void *opaque)
4382ef6
     qemu_announce_self();
4382ef6
     dprintf("successfully loaded vm state\n");
4382ef6
4382ef6
-    /* we've successfully migrated, close the server socket */
4382ef6
-    qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
4382ef6
-    close(s);
4382ef6
     if (autostart)
4382ef6
         vm_start();
4382ef6
4382ef6
 out_fopen:
4382ef6
     qemu_fclose(f);
4382ef6
 out:
4382ef6
+    qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
4382ef6
+    close(s);
4382ef6
     close(c);
4382ef6
 }
4382ef6
4382ef6
diff --git a/migration-unix.c b/migration-unix.c
4382ef6
index a141dbb..9685c4b 100644
4382ef6
--- a/migration-unix.c
4382ef6
+++ b/migration-unix.c
4382ef6
@@ -176,13 +176,12 @@ static void unix_accept_incoming_migration(void *opaque)
4382ef6
     qemu_announce_self();
4382ef6
     dprintf("successfully loaded vm state\n");
4382ef6
4382ef6
-    /* we've successfully migrated, close the server socket */
4382ef6
-    qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
4382ef6
-    close(s);
4382ef6
4382ef6
 out_fopen:
4382ef6
     qemu_fclose(f);
4382ef6
 out:
4382ef6
+    qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
4382ef6
+    close(s);
4382ef6
     close(c);
4382ef6
 }
4382ef6
4382ef6
-- 
4382ef6
1.6.6.1
4382ef6