From patchwork Tue Mar 17 08:53:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Liang Z" X-Patchwork-Id: 450899 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DFC9714007F for ; Tue, 17 Mar 2015 20:03:36 +1100 (AEDT) Received: from localhost ([::1]:53422 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXnPQ-0004sR-H2 for incoming@patchwork.ozlabs.org; Tue, 17 Mar 2015 05:03:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXnP8-0004aa-I7 for qemu-devel@nongnu.org; Tue, 17 Mar 2015 05:03:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXnOz-0004qt-Jz for qemu-devel@nongnu.org; Tue, 17 Mar 2015 05:03:12 -0400 Received: from mga11.intel.com ([192.55.52.93]:63322) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXnOz-0004qJ-EX for qemu-devel@nongnu.org; Tue, 17 Mar 2015 05:03:05 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 17 Mar 2015 02:02:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,415,1422950400"; d="scan'208";a="541978581" Received: from lil.sh.intel.com (HELO localhost) ([10.239.159.70]) by orsmga003.jf.intel.com with ESMTP; 17 Mar 2015 02:01:43 -0700 From: Liang Li To: qemu-devel@nongnu.org Date: Tue, 17 Mar 2015 16:53:58 +0800 Message-Id: <1426582438-9698-1-git-send-email-liang.z.li@intel.com> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Cc: amit.shah@redhat.com, yang.z.zhang@intel.com, Liang Li , quintela@redhat.com Subject: [Qemu-devel] [PATCH] migration: flush the bdrv before stopping VM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org If there are file write operations in the guest when doing live migration, the VM downtime will be much longer than the max_downtime, this is caused by bdrv_flush_all(), this function is a time consuming operation if there a lot of data have to be flushed to disk. By adding bdrv_flush_all() before VM stop, we can reduce the time consumed by bdrv_flush_all() in vm_stop_force_state, this means the VM down time can be reduced. The test shows this optimization can help to reduce the VM downtime from more than 20 seconds to about 100 milliseconds. Signed-off-by: Liang Li --- migration/migration.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index 2c805f1..fc4735c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -655,6 +655,10 @@ static void *migration_thread(void *opaque) qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); old_vm_running = runstate_is_running(); + /* do flush here is aimed to shorten the VM downtime, + * bdrv_flush_all is a time consuming operation + * when the guest has done some file writing */ + bdrv_flush_all(); ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); if (ret >= 0) { qemu_file_set_rate_limit(s->file, INT64_MAX);