Skip to contentSkip to conversation

Migration fixes

PATCH Applied Juan Quintela 2 participants 6 messages Mar 9, 2010 – Mar 17, 2010

lore
Share & tools
lore
#0 lore raw

cover Migration fixes

This series:
- fix 100% cpu use when incoming migration fails
- makes unix migration to obey autostart, like the others

Please, apply

Juan Quintela (2):
migration: Clear fd also in error cases
migration: unix migration should obey autostart are the other ones

 migration-exec.c |    4 ++--
 migration-fd.c   |    4 ++--
 migration-tcp.c  |    5 ++---
 migration-unix.c |    7 ++++---
 4 files changed, 10 insertions(+), 10 deletions(-)
#1 lore raw

PATCH 1/2 migration: Clear fd also in error cases

Not clearing the fd and closing the file makes qemu spin using 100%CPU after incoming migration error.

See for instance bug:
https://bugzilla.redhat.com/show_bug.cgi?id=518032

---
 migration-exec.c |    4 ++--
 migration-fd.c   |    4 ++--
 migration-tcp.c  |    5 ++---
 migration-unix.c |    5 ++---
 4 files changed, 8 insertions(+), 10 deletions(-)
migration-exec.c +2 -2
index 3edc026..6ff8449 100644
@@ -120,12 +120,12 @@ static void exec_accept_incoming_migration(void *opaque)
     }
     qemu_announce_self();
     DPRINTF("successfully loaded vm state\n");
-    /* we've successfully migrated, close the fd */
-    qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
+
     if (autostart)
         vm_start();
 
 err:
+    qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
     qemu_fclose(f);
 }
 
migration-fd.c +2 -2
index 0cc74ad..9cf52ce 100644
@@ -113,12 +113,12 @@ static void fd_accept_incoming_migration(void *opaque)
     }
     qemu_announce_self();
     DPRINTF("successfully loaded vm state\n");
-    /* we've successfully migrated, close the fd */
-    qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
+
     if (autostart)
         vm_start();
 
 err:
+    qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
     qemu_fclose(f);
 }
 
migration-tcp.c +2 -3
index e7f307c..95ce722 100644
@@ -170,15 +170,14 @@ static void tcp_accept_incoming_migration(void *opaque)
     qemu_announce_self();
     DPRINTF("successfully loaded vm state\n");
 
-    /* we've successfully migrated, close the server socket */
-    qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
-    close(s);
     if (autostart)
         vm_start();
 
 out_fopen:
     qemu_fclose(f);
 out:
+    qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
+    close(s);
     close(c);
 }
 
migration-unix.c +2 -3
index b7aab38..ce59a2a 100644
@@ -176,13 +176,12 @@ static void unix_accept_incoming_migration(void *opaque)
     qemu_announce_self();
     DPRINTF("successfully loaded vm state\n");
 
-    /* we've successfully migrated, close the server socket */
-    qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
-    close(s);
 
 out_fopen:
     qemu_fclose(f);
 out:
+    qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
+    close(s);
     close(c);
 }
 
Signature · 1 line
1.6.6.1
#3 lore raw

PATCH 2/2 migration: unix migration should obey autostart are the other ones

In reply to Juan Quintela

This was the only incoming migration without autostart check

---
 migration-unix.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
migration-unix.c +2 -0
index ce59a2a..49de1b9 100644
@@ -176,6 +176,8 @@ static void unix_accept_incoming_migration(void *opaque)
     qemu_announce_self();
     DPRINTF("successfully loaded vm state\n");
 
+    if (autostart)
+        vm_start();
 
 out_fopen:
     qemu_fclose(f);
Signature · 1 line
1.6.6.1
#4 lore raw

Re: [Qemu-devel] [PATCH 2/2] migration: unix migration should obey autostart are the other ones

Quoted 12 lines · Juan Quintela

This was the only incoming migration without autostart check

---
  migration-unix.c |    2 ++
  1 files changed, 2 insertions(+), 0 deletions(-)
migration-unix.c +0 -0
index ce59a2a..49de1b9 100644

migration-unix.c static void unix_accept_incoming_migration(void *opaque) · line 181

Quoted 6 lines
migration-unix.c +2 -0
@@ -176,6 +176,8 @@ static void unix_accept_incoming_migration(void *opaque)
      qemu_announce_self();
      DPRINTF("successfully loaded vm state\n");
 
+    if (autostart)
+        vm_start();
 

Maybe a better thing to do is make accept_incoming_migration return an error code and do the vm_start in common code.

Regards,

Anthony Liguori

Quoted 3 lines
migration-unix.c +0 -0
  out_fopen:
      qemu_fclose(f);
#5 lore raw

[Qemu-devel] Re: [PATCH 2/2] migration: unix migration should obey autostart are the other ones

Quoted 16 lines · Anthony Liguori
Quoted 15 lines · Juan Quintela

This was the only incoming migration without autostart check

---
  migration-unix.c |    2 ++
  1 files changed, 2 insertions(+), 0 deletions(-)
migration-unix.c +0 -0
index ce59a2a..49de1b9 100644
@@ -176,6 +176,8 @@ static void unix_accept_incoming_migration(void *opaque)
      qemu_announce_self();
      DPRINTF("successfully loaded vm state\n");
 
Quoted 6 lines

migration-unix.c static void unix_accept_incoming_migration(void *opaque) · line 181

Quoted 3 lines
migration-unix.c +2 -0
+    if (autostart)
+        vm_start();
 

Maybe a better thing to do is make accept_incoming_migration return an error code and do the vm_start in common code.

It is uglier than that (got the ones from migration-fd but idea is the same, removed uinteresting bits)

static void fd_accept_incoming_migration(void *opaque)

{
    ret = qemu_loadvm_state(f);
    ....
    if (autostart)
        vm_start();
    ....
}

int fd_start_incoming_migration(const char *infd)

{
    ....
    qemu_set_fd_handler2(fd, NULL, fd_accept_incoming_migration, NULL,
			 (void *)(unsigned long)f);

    return 0;
}

function call chain is:

main() ->
qemu_start_incoming_migration() ->
fd_start_migration() ->

here they got an fd, and call fd_accept_incoming_migration asyncronously on that fd. We can't call vm_start() until migration finish. And we have gone async a long time ago.

As a related note, you can see that exec_accept_incoming_migration() is identical to fd_start_incoming_migration(). I was going to share the code for all migrations until I found that unix & tcp migration do the accept also asynchronously, breaking the common function.

My plan was to make the accept in {unix,tcp}_start_incoming_migration() and then have a shared qemu_accept_incoming_migration() for all four kinds of migration.

Notice that it don't make sense to make the accept async, because qemu is not going to do _anything_ until incoming migration is finished, anyways. Just didn't want to merge the bugfix with the other change.

Later, Juan.

Quoted 7 lines

Regards,

Anthony Liguori

Quoted 3 lines
migration-unix.c +0 -0
  out_fopen:
      qemu_fclose(f);
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] migration: Clear fd also in error cases

In reply to Juan Quintela
Quoted 8 lines · Juan Quintela

Not clearing the fd and closing the file makes qemu spin using 100%CPU after incoming migration error.

See for instance bug:
https://bugzilla.redhat.com/show_bug.cgi?id=518032

Applied all. Thanks.

Regards,

Anthony Liguori

Quoted 88 lines
---
  migration-exec.c |    4 ++--
  migration-fd.c   |    4 ++--
  migration-tcp.c  |    5 ++---
  migration-unix.c |    5 ++---
  4 files changed, 8 insertions(+), 10 deletions(-)
migration-exec.c +2 -2
index 3edc026..6ff8449 100644
@@ -120,12 +120,12 @@ static void exec_accept_incoming_migration(void *opaque)
      }
      qemu_announce_self();
      DPRINTF("successfully loaded vm state\n");
-    /* we've successfully migrated, close the fd */
-    qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
+
      if (autostart)
          vm_start();
 
  err:
+    qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
      qemu_fclose(f);
  }
 
migration-fd.c +2 -2
index 0cc74ad..9cf52ce 100644
@@ -113,12 +113,12 @@ static void fd_accept_incoming_migration(void *opaque)
      }
      qemu_announce_self();
      DPRINTF("successfully loaded vm state\n");
-    /* we've successfully migrated, close the fd */
-    qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
+
      if (autostart)
          vm_start();
 
  err:
+    qemu_set_fd_handler2(qemu_stdio_fd(f), NULL, NULL, NULL, NULL);
      qemu_fclose(f);
  }
 
migration-tcp.c +2 -3
index e7f307c..95ce722 100644
@@ -170,15 +170,14 @@ static void tcp_accept_incoming_migration(void *opaque)
      qemu_announce_self();
      DPRINTF("successfully loaded vm state\n");
 
-    /* we've successfully migrated, close the server socket */
-    qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
-    close(s);
      if (autostart)
          vm_start();
 
  out_fopen:
      qemu_fclose(f);
  out:
+    qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
+    close(s);
      close(c);
  }
 
migration-unix.c +2 -3
index b7aab38..ce59a2a 100644
@@ -176,13 +176,12 @@ static void unix_accept_incoming_migration(void *opaque)
      qemu_announce_self();
      DPRINTF("successfully loaded vm state\n");
 
-    /* we've successfully migrated, close the server socket */
-    qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
-    close(s);
 
  out_fopen:
      qemu_fclose(f);
  out:
+    qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
+    close(s);
      close(c);
  }