From patchwork Mon Aug 8 21:03:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 657001 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 3s7VnS2hRtz9t0H for ; Tue, 9 Aug 2016 07:25:32 +1000 (AEST) Received: from localhost ([::1]:59876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWs38-0007Qb-1v for incoming@patchwork.ozlabs.org; Mon, 08 Aug 2016 17:25:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWrk4-0003vs-QA for qemu-devel@nongnu.org; Mon, 08 Aug 2016 17:05:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWrk0-0005tQ-Ia for qemu-devel@nongnu.org; Mon, 08 Aug 2016 17:05:47 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:26743 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWrk0-0005tI-Cc for qemu-devel@nongnu.org; Mon, 08 Aug 2016 17:05:44 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u78KxnIS105555 for ; Mon, 8 Aug 2016 17:05:44 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 24nbs0rmjs-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 08 Aug 2016 17:05:43 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 8 Aug 2016 15:05:43 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 8 Aug 2016 15:05:41 -0600 X-IBM-Helo: d03dlp01.boulder.ibm.com X-IBM-MailFrom: mdroth@linux.vnet.ibm.com Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id B381B1FF0054; Mon, 8 Aug 2016 15:05:19 -0600 (MDT) Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u78L5c1Q18612728; Mon, 8 Aug 2016 21:05:38 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36CCA28046; Mon, 8 Aug 2016 17:05:35 -0400 (EDT) Received: from localhost (unknown [9.80.86.168]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id D1F6A2803D; Mon, 8 Aug 2016 17:05:34 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 8 Aug 2016 16:03:52 -0500 X-Mailer: git-send-email 1.9.1 In-Reply-To: <1470690267-31454-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1470690267-31454-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16080821-0016-0000-0000-0000045F917C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005568; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000178; SDB=6.00741898; UDB=6.00349151; IPR=6.00514456; BA=6.00004651; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012252; XFM=3.00000011; UTC=2016-08-08 21:05:42 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16080821-0017-0000-0000-000031D64BB6 Message-Id: <1470690267-31454-22-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-08-08_15:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1608080226 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 21/56] 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-stable@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 (cherry picked from commit 24f3902b088cd4f2dbebfd90527b5d81d6a050e9) Signed-off-by: Michael Roth --- 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 0563b4c..6cecc35 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 16ba443..8346649 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1169,7 +1169,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; }