From patchwork Mon May 23 17:19:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 9132195 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 5E9CE607D6 for ; Mon, 23 May 2016 17:27:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 532DC2823A for ; Mon, 23 May 2016 17:27:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 482B928246; Mon, 23 May 2016 17:27:02 +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 C8C7128240 for ; Mon, 23 May 2016 17:27:01 +0000 (UTC) Received: from localhost ([::1]:49518 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4td6-0004Fr-6p for patchwork-qemu-devel@patchwork.kernel.org; Mon, 23 May 2016 13:27:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4tWc-0007Ra-QI for qemu-devel@nongnu.org; Mon, 23 May 2016 13:20:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4tWW-0005UO-95 for qemu-devel@nongnu.org; Mon, 23 May 2016 13:20:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55049) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4tWW-0005UG-0q for qemu-devel@nongnu.org; Mon, 23 May 2016 13:20:12 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9728E85366; Mon, 23 May 2016 17:20:11 +0000 (UTC) Received: from localhost (ovpn-116-17.sin2.redhat.com [10.67.116.17]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4NHK9ei004821; Mon, 23 May 2016 13:20:10 -0400 From: Amit Shah To: gkurz@linux.vnet.ibm.com, Markus Armbruster , jjherne@linux.vnet.ibm.com, Peter Maydell Date: Mon, 23 May 2016 22:49:46 +0530 Message-Id: <24f3902b088cd4f2dbebfd90527b5d81d6a050e9.1464023816.git.amit.shah@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 23 May 2016 17:20:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/5] savevm: fail if migration blockers are present 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: Amit Shah , qemu list , "Dr. David Alan Gilbert" , Juan Quintela Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Greg Kurz QEMU has currently two ways to prevent migration to occur: - migration blocker when it depends on runtime state - VMStateDescription.unmigratable when migration is not supported at all This patch gathers all the logic into a single function to be called from both the savevm and the migrate paths. This fixes a bug with 9p, at least, where savevm would succeed and the following would happen in the guest after loadvm: $ ls /host ls: cannot access /host: Protocol error With this patch: (qemu) savevm foo Migration is disabled when VirtFS export path '/' is mounted in the guest using mount_tag 'host' Signed-off-by: Greg Kurz Reviewed-by: Paolo Bonzini Message-Id: <146239057139.11271.9011797645454781543.stgit@bahia.huguette.org> [Update subject according to Paolo's suggestion - Amit] Signed-off-by: Amit Shah --- include/migration/migration.h | 1 + migration/migration.c | 21 +++++++++++++++------ migration/savevm.c | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index ac2c12c..9e36a97 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -210,6 +210,7 @@ int migrate_fd_close(MigrationState *s); void add_migration_state_change_notifier(Notifier *notify); void remove_migration_state_change_notifier(Notifier *notify); MigrationState *migrate_init(const MigrationParams *params); +bool migration_is_blocked(Error **errp); bool migration_in_setup(MigrationState *); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); diff --git a/migration/migration.c b/migration/migration.c index 12dbf5b..721d010 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -992,6 +992,20 @@ void qmp_migrate_incoming(const char *uri, Error **errp) once = false; } +bool migration_is_blocked(Error **errp) +{ + if (qemu_savevm_state_blocked(errp)) { + return true; + } + + if (migration_blockers) { + *errp = error_copy(migration_blockers->data); + return true; + } + + return false; +} + void qmp_migrate(const char *uri, bool has_blk, bool blk, bool has_inc, bool inc, bool has_detach, bool detach, Error **errp) @@ -1014,12 +1028,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, return; } - if (qemu_savevm_state_blocked(errp)) { - return; - } - - if (migration_blockers) { - *errp = error_copy(migration_blockers->data); + if (migration_is_blocked(errp)) { return; } diff --git a/migration/savevm.c b/migration/savevm.c index 8546fdf..f8450fd 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1170,7 +1170,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) MigrationState *ms = migrate_init(¶ms); ms->to_dst_file = f; - if (qemu_savevm_state_blocked(errp)) { + if (migration_is_blocked(errp)) { return -EINVAL; }