Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main-src > by-pkgid > aadbe78a25743146bb784eee19f007c5 > files > 76

kvm-83-164.el5_5.9.src.rpm

From 47b5595b36a5683593766bb5a5a08e66462e54af Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost@redhat.com>
Date: Thu, 17 Sep 2009 14:06:03 -0300
Subject: [PATCH 34/38] kvm: BZ503367: obey -S on migration

RH-Author: Paolo Bonzini <pbonzini@redhat.com>
Message-id: <1250693970-10271-1-git-send-email-pbonzini@redhat.com>
Patchwork-id: 3280
O-Subject: [PATCH RHEL5.5] kvm: BZ503367: obey -S on migration
Bugzilla: 503367
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dor Laor <dlaor@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>

Bugzilla: 503367

Brew build: http://brewweb.devel.redhat.com/brew/taskinfo/?taskID=1934529

Upstream: Combination of upstream commits 89befdd and d399f67 (but
    code is somewhat different).

On incoming migration, -S is not honored by qemu.  If a domain is migrated
while paused, thus, it will start running on the remote machine; this
is wrong.

After this patch, a migrated VM (including start/stop) will be started
or not depending on whether -S is passed.  libvirt always uses -S and
issues a manual "cont" if the machine was running when it was saved.

There are still two issues pending:

1) on the libvirt side, if the domain is suspended during migration,
the domain will start running on the remote side.  This is
scheduled for RHEL6 as part of bug 517724.

2) I sometimes got a "soft lockup - CPU stuck for 10s" if I resume
the migrated virtual machine 10 seconds or more after the migration
is complete.  This is more scary than it is important, but it would
be nice to fix it.

As can be guessed from (2), tested by me. :-)

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
	It is still possible to mitigate the issue with suspend-during-
	migration, and I'll post RFC patches to the libvirt list soon.

 migration-exec.c |    4 ++--
 migration-tcp.c  |    3 ++-
 sysemu.h         |    1 +
 vl.c             |   17 ++++++-----------
 4 files changed, 11 insertions(+), 14 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu/migration-exec.c |    4 ++--
 qemu/migration-tcp.c  |    3 ++-
 qemu/sysemu.h         |    1 +
 qemu/vl.c             |   17 ++++++-----------
 4 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/qemu/migration-exec.c b/qemu/migration-exec.c
index 6b66344..6f8470b 100644
--- a/qemu/migration-exec.c
+++ b/qemu/migration-exec.c
@@ -133,7 +133,6 @@ int exec_start_incoming_migration(const char *command)
         return -errno;
     }
     strncpy(vm_stop_reason, "incomming migration", STOP_REASON_LEN);
-    vm_stop(0); /* just in case */
     ret = qemu_loadvm_state(f);
     if (ret < 0) {
         fprintf(stderr, "load of migration failed\n");
@@ -142,7 +141,8 @@ int exec_start_incoming_migration(const char *command)
     qemu_announce_self();
     dprintf("successfully loaded vm state\n");
     term_printf_async(MIGRATION_ASYNC_EVENT, "migration: migration process finished\n");
-    vm_start();
+    if (autostart)
+        vm_start();
     qemu_fclose(f);
     return 0;
 
diff --git a/qemu/migration-tcp.c b/qemu/migration-tcp.c
index 485c4e8..df765d0 100644
--- a/qemu/migration-tcp.c
+++ b/qemu/migration-tcp.c
@@ -486,7 +486,8 @@ static void tcp_incoming_load_vm(void)
 	    fprintf(stderr, "reopening of drives failed\n");
 	    goto error;
     }
-    vm_start();
+    if (autostart)
+        vm_start();
 
 error:
     tcp_incoming_cleanup();
diff --git a/qemu/sysemu.h b/qemu/sysemu.h
index 06ca917..ea84039 100644
--- a/qemu/sysemu.h
+++ b/qemu/sysemu.h
@@ -91,6 +91,7 @@ int tap_win32_init(VLANState *vlan, const char *model,
 /* SLIRP */
 void do_info_slirp(void);
 
+extern int autostart;
 extern int bios_size;
 extern int cirrus_vga_enabled;
 extern int vmsvga_enabled;
diff --git a/qemu/vl.c b/qemu/vl.c
index 2c24889..0c52166 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -242,6 +242,7 @@ int no_shutdown = 0;
 int cursor_hide = 1;
 int graphic_rotate = 0;
 int daemonize = 0;
+int autostart = 0;
 const char *incoming;
 const char *option_rom[MAX_OPTION_ROMS];
 int nb_option_roms;
@@ -5109,7 +5110,6 @@ int main(int argc, char **argv, char **envp)
     int fds[2];
     int tb_size;
     const char *pid_file = NULL;
-    int autostart;
     const char *incoming = NULL;
 
     qemu_cache_utils_init(envp);
@@ -6375,18 +6375,13 @@ int main(int argc, char **argv, char **envp)
     if (loadvm)
         do_loadvm(loadvm);
 
-    if (incoming) {
-        autostart = 0; /* fixme how to deal with -daemonize */
+    if (incoming)
         qemu_start_incoming_migration(incoming);
-    }
 
-    {
-        /* XXX: simplify init */
-        read_passwords();
-        if (autostart) {
-            vm_start();
-        }
-    }
+    /* XXX: simplify init */
+    read_passwords();
+    if (!incoming && autostart)
+        vm_start();
 
     if (daemonize) {
 	uint8_t status = 0;
-- 
1.6.3.rc4.29.g8146