From patchwork Thu Oct 6 02:54:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 9363623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F2277600C8 for ; Thu, 6 Oct 2016 02:57:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E474028DAF for ; Thu, 6 Oct 2016 02:57:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D966428DB2; Thu, 6 Oct 2016 02:57:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7F9DC28DAF for ; Thu, 6 Oct 2016 02:57:04 +0000 (UTC) Received: from localhost ([::1]:52617 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bryrn-0006Tf-Pc for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Oct 2016 22:57:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43806) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bryrL-0006Qf-MZ for qemu-devel@nongnu.org; Wed, 05 Oct 2016 22:56:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bryrJ-0000LY-ME for qemu-devel@nongnu.org; Wed, 05 Oct 2016 22:56:35 -0400 Received: from [59.151.112.132] (port=19055 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bryrJ-0000Ka-9j for qemu-devel@nongnu.org; Wed, 05 Oct 2016 22:56:33 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="11673066" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 06 Oct 2016 10:56:31 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 795D3466F727; Thu, 6 Oct 2016 10:56:29 +0800 (CST) Received: from G08FNSTD140138.localdomain (10.167.226.45) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.279.2; Thu, 6 Oct 2016 10:56:28 +0800 From: Li Zhijian To: , , Date: Thu, 6 Oct 2016 10:54:20 +0800 Message-ID: <1475722460-22185-2-git-send-email-lizhijian@cn.fujitsu.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1475722460-22185-1-git-send-email-lizhijian@cn.fujitsu.com> References: <1475722460-22185-1-git-send-email-lizhijian@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.45] X-yoursite-MailScanner-ID: 795D3466F727.AF351 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: lizhijian@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Subject: [Qemu-devel] [PATCH 2/2] migration: introduce section type QEMU_VM_SECTION_HEADER X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Zhijian Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Introduce a new section type to help destination to detect unknown/inconsistent devices early that let source side stop migration and keep alive. Prevoisly, if we have a different device list between source and distination ( e.g: souce with -device virtio-blk,drive=foo and distination with -device virtio-scsi-pci,id=scsi0), after migration, the source goto status "paused (postmigrate)" and distination will exit since detect inconsistent device. Signed-off-by: Li Zhijian --- include/migration/migration.h | 1 + migration/savevm.c | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index d4acc72..03cc2c4 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -35,6 +35,7 @@ #define QEMU_VM_VMDESCRIPTION 0x06 #define QEMU_VM_CONFIGURATION 0x07 #define QEMU_VM_COMMAND 0x08 +#define QEMU_VM_SECTION_HEADER 0x09 #define QEMU_VM_SECTION_FOOTER 0x7e struct MigrationParams { diff --git a/migration/savevm.c b/migration/savevm.c index c36a675..dae24c6 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -677,7 +677,8 @@ void savevm_skip_section_footers(void) } /* - * Write the header for device section (QEMU_VM_SECTION START/END/PART/FULL) + * Write the header for device section + * (QEMU_VM_SECTION START/END/PART/FULL/HEADER) */ static void save_section_header(QEMUFile *f, SaveStateEntry *se, uint8_t section_type) @@ -686,7 +687,8 @@ static void save_section_header(QEMUFile *f, SaveStateEntry *se, qemu_put_be32(f, se->section_id); if (section_type == QEMU_VM_SECTION_FULL || - section_type == QEMU_VM_SECTION_START) { + section_type == QEMU_VM_SECTION_START || + section_type == QEMU_VM_SECTION_HEADER) { /* ID string */ size_t len = strlen(se->idstr); qemu_put_byte(f, len); @@ -887,6 +889,10 @@ void qemu_savevm_state_begin(QEMUFile *f, trace_savevm_state_begin(); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + /* new section type since 2.8, we send devices header to destination + * at the migration beginning + */ + save_section_header(f, se, QEMU_VM_SECTION_HEADER); if (!se->ops || !se->ops->set_params) { continue; } @@ -1846,11 +1852,20 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) { uint8_t section_type; int ret; + uint32_t vid, sid; + SaveStateEntry *se; while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) { trace_qemu_loadvm_state_section(section_type); switch (section_type) { + /* new section type since 2.8 */ + case QEMU_VM_SECTION_HEADER: + ret = qemu_loadvm_section_header(f, mis, &se, &vid, &sid); + if (ret < 0) { + return ret; + } + break; case QEMU_VM_SECTION_START: case QEMU_VM_SECTION_FULL: ret = qemu_loadvm_section_start_full(f, mis);