qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Liang Li <liang.z.li@intel.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, quintela@redhat.com,
	Liang Li <liang.z.li@intel.com>,
	qemu-stable@nongnu.org, yong.y.wang@intel.com,
	yang.z.zhang@intel.com, stefanha@redhat.com,
	amit.shah@redhat.com
Subject: [Qemu-devel] [v2 1/4] migration: do cleanup operation after completion
Date: Thu, 13 Aug 2015 13:46:33 +0800	[thread overview]
Message-ID: <1439444796-22862-2-git-send-email-liang.z.li@intel.com> (raw)
In-Reply-To: <1439444796-22862-1-git-send-email-liang.z.li@intel.com>

Because of the patch 3ea3b7fa9af067982f34b of kvm, now the migration_end()
is a time consuming operation, which takes about dozens of milliseconds, and
will prolong VM downtime. Such an operation should be done after migration
completion.

For a VM with 8G RAM, this patch can reduce the VM downtime about 32 ms during
live migration.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
 migration/block.c     |  1 -
 migration/migration.c | 14 +++++++-------
 migration/ram.c       |  1 -
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/migration/block.c b/migration/block.c
index ed865ed..85496fd 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -750,7 +750,6 @@ static int block_save_complete(QEMUFile *f, void *opaque)
 
     qemu_put_be64(f, BLK_MIG_FLAG_EOS);
 
-    blk_mig_cleanup();
     return 0;
 }
 
diff --git a/migration/migration.c b/migration/migration.c
index 662e77e..4ddb9ad 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -560,12 +560,9 @@ static void migrate_fd_cleanup(void *opaque)
 
     assert(s->state != MIGRATION_STATUS_ACTIVE);
 
-    if (s->state != MIGRATION_STATUS_COMPLETED) {
-        qemu_savevm_state_cancel();
-        if (s->state == MIGRATION_STATUS_CANCELLING) {
-            migrate_set_state(s, MIGRATION_STATUS_CANCELLING,
-                              MIGRATION_STATUS_CANCELLED);
-        }
+    if (s->state == MIGRATION_STATUS_CANCELLING) {
+        migrate_set_state(s, MIGRATION_STATUS_CANCELLING,
+                          MIGRATION_STATUS_CANCELLED);
     }
 
     notifier_list_notify(&migration_state_notifiers, s);
@@ -923,6 +920,7 @@ static void *migration_thread(void *opaque)
     int64_t initial_bytes = 0;
     int64_t max_size = 0;
     int64_t start_time = initial_time;
+    int64_t end_time;
     bool old_vm_running = false;
 
     rcu_register_thread();
@@ -1007,9 +1005,11 @@ static void *migration_thread(void *opaque)
         }
     }
 
+    end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
+
     qemu_mutex_lock_iothread();
+    qemu_savevm_state_cancel();
     if (s->state == MIGRATION_STATUS_COMPLETED) {
-        int64_t end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
         uint64_t transferred_bytes = qemu_ftell(s->file);
         s->total_time = end_time - s->total_time;
         s->downtime = end_time - start_time;
diff --git a/migration/ram.c b/migration/ram.c
index 7f007e6..6249f6e 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1269,7 +1269,6 @@ static int ram_save_complete(QEMUFile *f, void *opaque)
 
     rcu_read_unlock();
 
-    migration_end();
     qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
 
     return 0;
-- 
1.9.1

  reply	other threads:[~2015-08-13  5:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13  5:46 [Qemu-devel] [v2 0/4] Fix long vm downtime during live migration Liang Li
2015-08-13  5:46 ` Liang Li [this message]
2015-08-13  5:46 ` [Qemu-devel] [v2 2/4] migration: rename qemu_savevm_state_cancel Liang Li
2015-08-13  5:46 ` [Qemu-devel] [v2 3/4] migration: rename cancel to cleanup in SaveVMHandles Liang Li
2015-08-13  5:46 ` [Qemu-devel] [v2 4/4] migration: code clean up Liang Li
2015-08-13  6:30 ` [Qemu-devel] [v2 0/4] Fix long vm downtime during live migration Paolo Bonzini
2015-10-09  8:56   ` Li, Liang Z
2015-10-21  9:00     ` Li, Liang Z
2015-10-26  6:09       ` Amit Shah
2015-10-26  8:27         ` Li, Liang Z

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1439444796-22862-2-git-send-email-liang.z.li@intel.com \
    --to=liang.z.li@intel.com \
    --cc=amit.shah@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=yang.z.zhang@intel.com \
    --cc=yong.y.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).