Skip to contentSkip to conversation

fix broken migration

PATCH In review Glauber Costa 3 participants 11 messages Jul 24, 2009 – Jul 27, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix broken migration

While fixing migration with -S, commit 89befdd1a6b18215153b8976682d57b7d03d5782 broke the rest of us. Poor glommer, with a poor family, spare him his life from this monstruosity.

Since the unconditional vm_start, not autostart was the villain, I'm putting back autostart. Let me know if you prefer other solutions, it doesn't really matter, doesn't really matter to me.

Any way the wind blows...

---
 vl.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
vl.c +3 -1
index ce213c2..015f631 100644
@@ -6075,8 +6075,10 @@ int main(int argc, char **argv, char **envp)
     if (loadvm)
         do_loadvm(cur_mon, loadvm);
 
-    if (incoming)
+    if (incoming) {
+        autostart = 0;
         qemu_start_incoming_migration(incoming);
+    }
 
     if (autostart)
         vm_start();
Signature · 1 line
1.6.2.2
#1 lore raw
Quoted 2 lines · Glauber Costa

While fixing migration with -S, commit 89befdd1a6b18215153b8976682d57b7d03d5782 broke the rest of us.

With this patch a migrated virtual machine will never be restarted. If you want that, shouldn't you use -S? But if you really wanted a migrated virtual machine to never be restarted, didn't you have a problem before my patch as well?

Note that autostart (the variable) is never read except to choose whether to do that vm_start; so there can be no collateral effects from passing -S.

I don't understand what this patch is trying to achieve (and why).

Paolo

#2 lore raw
Quoted 9 lines · Paolo Bonzini
Quoted 2 lines · Glauber Costa

While fixing migration with -S, commit 89befdd1a6b18215153b8976682d57b7d03d5782 broke the rest of us.

With this patch a migrated virtual machine will never be restarted. If you want that, shouldn't you use -S? But if you really wanted a migrated virtual machine to never be restarted, didn't you have a problem before my patch as well?

Quoted 5 lines

Note that autostart (the variable) is never read except to choose whether to do that vm_start; so there can be no collateral effects from passing -S.

I don't understand what this patch is trying to achieve (and why).

If I pass --incoming to the VM, I don't expect the VM to start. I expect it to wait, because I'll be handling it a migration later. However, it does start, which is clearly wrong.

Of course, it does not start if we pass -S in conjunction with --incoming, but this is a totally crazy semantics. An option should not depend on another option to do the right thing.

As I said in the changelog, -S is still respected in migration because we're not automatically vm_start()'in anything after migration completes, and also work with a migrated machine that is already running. So what am I missing here?

#3 lore raw
Quoted 3 lines · Glauber Costa

If I pass --incoming to the VM, I don't expect the VM to start. I expect it to wait, because I'll be handling it a migration later. However, it does start, which is clearly wrong.

I see now, thanks. I was puzzled by your message, so to speak.

I suppose the best semantics would be to do like

   if (autostart && !incoming)
       vm_start ()

in vl.c and add

if (autostart)

       vm_start ()

in the migration-*.c files.

Paolo

#4 lore raw
Quoted 12 lines · Paolo Bonzini
Quoted 3 lines · Glauber Costa

If I pass --incoming to the VM, I don't expect the VM to start. I expect it to wait, because I'll be handling it a migration later. However, it does start, which is clearly wrong.

I see now, thanks. I was puzzled by your message, so to speak.

I suppose the best semantics would be to do like

   if (autostart && !incoming)
       vm_start ()
Quoted 6 lines

in vl.c and add

   if (autostart)
       vm_start ()

in the migration-*.c files.

I don't disagree. This is even more explicit about the meaning of each of the flags.

#5 lore raw

PATCH 1/1 fix migration to not require -S

Since migration returns right away, starting the VM right after calling qemu_start_incoming_migration is wrong even if -S is not passed.

Cc Glauber Costa <[email protected]>
Cc Anthony Liguori <[email protected]>

---
Oh my gosh. This is what I have in my tree and I did not squash it before sending out the patch to the list. I guess that this monstrosity :-) explains my reaction to Glauber's patch.

Anthony, I don't care if you apply my patch or his.

 vl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
vl.c +1 -1
index 845d185..d826968 100644
@@ -6198,7 +6198,7 @@ int main(int argc, char **argv, char **envp)
     if (incoming)
         qemu_start_incoming_migration(incoming);
 
-    if (autostart)
+    else if (autostart)
         vm_start();
 
 #ifndef _WIN32
Signature · 1 line
1.6.2.5
#6 lore raw

PATCH 1/1 fix migration to obey -S

In reply to Glauber Costa

Since migration returns right away, starting the VM right after calling qemu_start_incoming_migration is wrong even if -S is not passed. We have to do this after migration has completed.

Cc Glauber Costa <[email protected]>
Cc Anthony Liguori <[email protected]>

---
This implements the other semantics that glommer also agreed were nice to have.

 migration-exec.c |    2 ++
 migration-tcp.c  |    2 ++
 sysemu.h         |    1 +
 vl.c             |    4 ++--
 4 files changed, 7 insertions(+), 2 deletions(-)
migration-exec.c +2 -0
index e472979..6249b93 100644
@@ -118,6 +118,8 @@ static void exec_accept_incoming_migration(void *opaque)
     dprintf("successfully loaded vm state\n");
     /* we've successfully migrated, close the fd */
     qemu_set_fd_handler2(qemu_popen_fd(f), NULL, NULL, NULL, NULL);
+    if (autostart)
+        vm_start();
 
 err:
     qemu_fclose(f);
migration-tcp.c +2 -0
index 7a87a1e..d3feb85 100644
@@ -166,6 +166,8 @@ static void tcp_accept_incoming_migration(void *opaque)
     /* 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);
sysemu.h +1 -0
index fe24415..9ab346c 100644
@@ -102,6 +102,7 @@ typedef enum DisplayType
     DT_NOGRAPHIC,
 } DisplayType;
 
+extern int autostart;
 extern int bios_size;
 extern int cirrus_vga_enabled;
 extern int std_vga_enabled;
vl.c +2 -2
index 845d185..02a8cd4 100644
@@ -210,7 +210,7 @@ ram_addr_t ram_size;
 int nb_nics;
 NICInfo nd_table[MAX_NICS];
 int vm_running;
-static int autostart;
+int autostart;
 static int rtc_utc = 1;
 static int rtc_date_offset = -1; /* -1 means no change */
 int cirrus_vga_enabled = 1;
@@ -6198,7 +6198,7 @@ int main(int argc, char **argv, char **envp)
     if (incoming)
         qemu_start_incoming_migration(incoming);
 
-    if (autostart)
+    else if (autostart)
         vm_start();
 
 #ifndef _WIN32
#7 lore raw

[Qemu-devel] Re: [PATCH alternative] fix migration to obey -S

Quoted 35 lines · Paolo Bonzini

Since migration returns right away, starting the VM right after calling qemu_start_incoming_migration is wrong even if -S is not passed. We have to do this after migration has completed.

Cc Glauber Costa <[email protected]>
Cc Anthony Liguori <[email protected]>

---
This implements the other semantics that glommer also agreed were nice to have.

 migration-exec.c |    2 ++
 migration-tcp.c  |    2 ++
 sysemu.h         |    1 +
 vl.c             |    4 ++--
 4 files changed, 7 insertions(+), 2 deletions(-)
migration-exec.c +2 -0
index e472979..6249b93 100644
@@ -118,6 +118,8 @@ static void exec_accept_incoming_migration(void *opaque)
     dprintf("successfully loaded vm state\n");
     /* we've successfully migrated, close the fd */
     qemu_set_fd_handler2(qemu_popen_fd(f), NULL, NULL, NULL, NULL);
+    if (autostart)
+        vm_start();
 
 err:
     qemu_fclose(f);
migration-tcp.c +0 -0
index 7a87a1e..d3feb85 100644

migration-tcp.c static void tcp_accept_incoming_migration(void *opaque) · line 171

Quoted 6 lines
migration-tcp.c +2 -0
@@ -166,6 +166,8 @@ static void tcp_accept_incoming_migration(void *opaque)
     /* we've successfully migrated, close the server socket */
     qemu_set_fd_handler2(s, NULL, NULL, NULL, NULL);
     close(s);
+    if (autostart)
+        vm_start();
 

Hummm,, those are a little bit weird. I'd expect it to be a characteristic of the source machine, no the destination. IOW, if the machine was running prior to migration, it should be running after it, and if it was stopped prior to migration, it should be stopped after it.

Having dst flags to tamper this seems only confusing to me.

#8 lore raw

[Qemu-devel] Re: [PATCH alternative] fix migration to obey -S

Quoted 5 lines · Glauber Costa

Hummm,, those are a little bit weird. I'd expect it to be a characteristic of the source machine, no the destination. IOW, if the machine was running prior to migration, it should be running after it, and if it was stopped prior to migration, it should be stopped after it.

Whether a guest is running is not part of it's state-IOW, it's not visible to the guest whether it's running or not.

Signature · 3 lines
Regards,

Anthony Liguori
#9 lore raw

[Qemu-devel] Re: [PATCH alternative] fix migration to obey -S

Quoted 9 lines · Anthony Liguori
Quoted 5 lines · Glauber Costa

Hummm,, those are a little bit weird. I'd expect it to be a characteristic of the source machine, no the destination. IOW, if the machine was running prior to migration, it should be running after it, and if it was stopped prior to migration, it should be stopped after it.

Whether a guest is running is not part of it's state-IOW, it's not visible to the guest whether it's running or not.

Can't we then register a savevm function for that?
Otherwise, management gets quite complicated, if they really want to get the behaviour I described (which I believe to be the most reasonable one)

#10 lore raw

[Qemu-devel] Re: [PATCH alternative] fix migration to obey -S

Quoted 10 lines · Glauber Costa
Quoted 8 lines · Anthony Liguori
Quoted 6 lines · Glauber Costa

Hummm,, those are a little bit weird. I'd expect it to be a characteristic of the source machine, no the destination. IOW, if the machine was running prior to migration, it should be running after it, and if it was stopped prior to migration, it should be stopped after it.

Quoted 4 lines
Quoted 2 lines

Whether a guest is running is not part of it's state-IOW, it's not visible to the guest whether it's running or not.

Can't we then register a savevm function for that?

No, that's the point. Since it's not guest visible, it should not be saved as part of savevm.

It's up to the management tools to keep track of whether a VM is stopped or not. When creating the destination node, the user specify whether they want the VM to be stopped.

So qemu -incoming ... -S

Should translate to: do not automatically run the VM after migration.

qemu -incoming ...

Will always run the VM after migration regardless of whether the VM was migrated while stopped.

Signature · 3 lines
Regards,

Anthony Liguori