From patchwork Tue Nov 24 13:35:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 7691361 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5CB43BF90C for ; Tue, 24 Nov 2015 13:53:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7CD36207E5 for ; Tue, 24 Nov 2015 13:53:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 93374207D7 for ; Tue, 24 Nov 2015 13:53:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754080AbbKXNxR (ORCPT ); Tue, 24 Nov 2015 08:53:17 -0500 Received: from mga01.intel.com ([192.55.52.88]:37612 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753150AbbKXNxO (ORCPT ); Tue, 24 Nov 2015 08:53:14 -0500 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 24 Nov 2015 05:53:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,338,1444719600"; d="scan'208";a="606321599" Received: from lantianyu-ws.sh.intel.com (HELO localhost) ([10.239.159.159]) by FMSMGA003.fm.intel.com with ESMTP; 24 Nov 2015 05:53:10 -0800 From: Lan Tianyu To: aik@ozlabs.ru, alex.williamson@redhat.com, amit.shah@redhat.com, anthony@codemonkey.ws, ard.biesheuvel@linaro.org, blauwirbel@gmail.com, cornelia.huck@de.ibm.com, eddie.dong@intel.com, nrupal.jani@intel.com, agraf@suse.de, kvm@vger.kernel.org, pbonzini@redhat.com, qemu-devel@nongnu.org, emil.s.tantilov@intel.com, gerlitz.or@gmail.com, donald.c.skidmore@intel.com, mark.d.rustad@intel.com, mst@redhat.com, kraxel@redhat.com, lcapitulino@redhat.com, quintela@redhat.com Cc: Lan Tianyu Subject: [RFC PATCH V2 08/10] Qemu: Add save_before_stop callback to run just before stopping VCPU during migration Date: Tue, 24 Nov 2015 21:35:25 +0800 Message-Id: <1448372127-28115-9-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1448372127-28115-1-git-send-email-tianyu.lan@intel.com> References: <1448372127-28115-1-git-send-email-tianyu.lan@intel.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch is to add a callback which is called just before stopping VCPU. It's for VF migration to trigger mailbox irq as later as possible to decrease service downtime. Signed-off-by: Lan Tianyu --- include/migration/vmstate.h | 3 +++ include/sysemu/sysemu.h | 1 + migration/migration.c | 3 ++- migration/savevm.c | 13 +++++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index dc681a6..093faf1 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -58,6 +58,9 @@ typedef struct SaveVMHandlers { /* This runs after restoring CPU related state */ void (*post_load_state)(void *opaque); + + /* This runs before stopping VCPU */ + void (*save_before_stop)(QEMUFile *f, void *opaque); LoadStateHandler *load_state; } SaveVMHandlers; diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index df80951..3d0d72c 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -84,6 +84,7 @@ void qemu_announce_self(void); bool qemu_savevm_state_blocked(Error **errp); void qemu_savevm_state_begin(QEMUFile *f, const MigrationParams *params); +void qemu_savevm_save_before_stop(QEMUFile *f); void qemu_savevm_state_header(QEMUFile *f); int qemu_savevm_state_iterate(QEMUFile *f); void qemu_savevm_state_complete(QEMUFile *f); diff --git a/migration/migration.c b/migration/migration.c index c6ac08a..fccadea 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -759,7 +759,6 @@ int64_t migrate_xbzrle_cache_size(void) } /* migration thread support */ - static void *migration_thread(void *opaque) { MigrationState *s = opaque; @@ -788,6 +787,8 @@ static void *migration_thread(void *opaque) } else { int ret; + qemu_savevm_save_before_stop(s->file); + qemu_mutex_lock_iothread(); start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); diff --git a/migration/savevm.c b/migration/savevm.c index 48b6223..c2e4802 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -715,6 +715,19 @@ void qemu_savevm_post_load(void) } } +void qemu_savevm_save_before_stop(QEMUFile *f) +{ + SaveStateEntry *se; + + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (!se->ops || !se->ops->save_before_stop) { + continue; + } + + se->ops->save_before_stop(f, se->opaque); + } +} + void qemu_savevm_state_header(QEMUFile *f) {