From: Chris Lalancette <[EMAIL PROTECTED]>

If the remote side wasn't set up properly (i.e. the memory size didn't match),
the migration would fail, but the source host didn't actually react properly,
so the migration would still be "in-progress".  This patch fixes up the error
checking to properly quit when the remote side isn't prepared for whatever
reason.

Signed-off-by: Chris Lalancette <[EMAIL PROTECTED]>
Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>

diff --git a/qemu/migration.c b/qemu/migration.c
index 17ad77c..df0acf9 100644
--- a/qemu/migration.c
+++ b/qemu/migration.c
@@ -425,18 +425,26 @@ static int start_migration(MigrationState *s)
 #endif
        
     r = MIG_STAT_WRITE_FAILED;
-    if (write_whole_buffer(s->fd, &running, sizeof(running)))
+    if (write_whole_buffer(s->fd, &running, sizeof(running))) {
+        perror("vm_running write failed");
         goto out;
-    if (write_whole_buffer(s->fd, &value, sizeof(value)))
+    }
+    if (write_whole_buffer(s->fd, &value, sizeof(value))) {
+        perror("phys_ram_size write failed");
         goto out;
+    }
 
 #ifdef USE_KVM
     if (kvm_allowed) {
         value = cpu_to_be32(n);
-        if (write_whole_buffer(s->fd, &value, sizeof(value)))
+        if (write_whole_buffer(s->fd, &value, sizeof(value))) {
+            perror("phys_ram_size_bitmap size write failed");
             goto out;
-        if (write_whole_buffer(s->fd, phys_ram_page_exist_bitmap, n))
+       }
+        if (write_whole_buffer(s->fd, phys_ram_page_exist_bitmap, n)) {
+            perror("phys_ram_page_exist_bitmap write failed");
             goto out;
+       }
     }
 #endif
     fcntl(s->fd, F_SETFL, O_NONBLOCK);
@@ -456,7 +464,8 @@ static int start_migration(MigrationState *s)
 
     if (cpu_physical_memory_set_dirty_tracking(1)) {
         *s->has_error = MIG_STAT_KVM_SET_DIRTY_TRACKING_FAILED;
-        return -1;
+        r = MIG_STAT_KVM_SET_DIRTY_TRACKING_FAILED;
+        goto out;
     }
 
     s->addr = 0;
@@ -470,6 +479,8 @@ static int start_migration(MigrationState *s)
     qemu_mod_timer(s->timer, qemu_get_clock(rt_clock));
     qemu_set_fd_handler2(s->fd, NULL, NULL, migrate_write, s);
 
+    r = 0;
+
  out:
 #ifdef USE_KVM
     if (phys_ram_page_exist_bitmap)
@@ -498,8 +509,9 @@ static MigrationState *migration_init_fd(int detach, int fd)
 
     current_migration = s;
     
-    if (start_migration(s) == -1) {
+    if (start_migration(s)) {
        term_printf("Could not start migration\n");
+       migrate_finish(s);
        return NULL;
     }
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-commits mailing list
kvm-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-commits

Reply via email to