From nobody Thu Apr 25 00:49:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523898861021769.7225932311505; Mon, 16 Apr 2018 10:14:21 -0700 (PDT) Received: from localhost ([::1]:58889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87hl-000313-4N for importer@patchew.org; Mon, 16 Apr 2018 13:14:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f87dK-0007wN-LR for qemu-devel@nongnu.org; Mon, 16 Apr 2018 13:09:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f87dI-00039q-92 for qemu-devel@nongnu.org; Mon, 16 Apr 2018 13:09:38 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36560 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f87dI-00038j-3n for qemu-devel@nongnu.org; Mon, 16 Apr 2018 13:09:36 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03F67406F8B0 for ; Mon, 16 Apr 2018 17:09:35 +0000 (UTC) Received: from dgilbert-t530.redhat.com (unknown [10.36.116.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id 305C22026DFD; Mon, 16 Apr 2018 17:09:31 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, kwolf@redhat.com, quintela@redhat.com, jdenemar@redhat.com Date: Mon, 16 Apr 2018 18:09:30 +0100 Message-Id: <20180416170930.35504-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 16 Apr 2018 17:09:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 16 Apr 2018 17:09:35 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dgilbert@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 for 2.13] migration: Don't activate block devices if using -S 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Activating the block devices causes the locks to be taken on the backing file. If we're running with -S and the destination libvirt hasn't started the destination with 'cont', it's expecting the locks are still untaken. Don't activate the block devices if we're not going to autostart the VM; 'cont' already will do that anyway. This change is tied to the new migration capability 'late-block-activate' that defaults to off, keeping the old behaviour by default. bz: https://bugzilla.redhat.com/show_bug.cgi?id=3D1560854 Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- migration/migration.c | 34 +++++++++++++++++++++++++++------- qapi/migration.json | 6 +++++- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 52a5092add..a05c6c893b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -197,6 +197,16 @@ static void migrate_generate_event(int new_state) } } =20 +static bool migrate_late_block_activate(void) +{ + MigrationState *s; + + s =3D migrate_get_current(); + + return s->enabled_capabilities[ + MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE]; +} + /* * Called on -incoming with a defer: uri. * The migration can be started later after any parameters have been @@ -306,13 +316,23 @@ static void process_incoming_migration_bh(void *opaqu= e) Error *local_err =3D NULL; MigrationIncomingState *mis =3D opaque; =20 - /* Make sure all file formats flush their mutable metadata. - * If we get an error here, just don't restart the VM yet. */ - bdrv_invalidate_cache_all(&local_err); - if (local_err) { - error_report_err(local_err); - local_err =3D NULL; - autostart =3D false; + /* If capability late_block_activate is set: + * Only fire up the block code now if we're going to restart the + * VM, else 'cont' will do it. + * This causes file locking to happen; so we don't want it to happen + * unless we really are starting the VM. + */ + if (!migrate_late_block_activate() || + (autostart && (!global_state_received() || + global_state_get_runstate() =3D=3D RUN_STATE_RUNNING))) { + /* Make sure all file formats flush their mutable metadata. + * If we get an error here, just don't restart the VM yet. */ + bdrv_invalidate_cache_all(&local_err); + if (local_err) { + error_report_err(local_err); + local_err =3D NULL; + autostart =3D false; + } } =20 /* diff --git a/qapi/migration.json b/qapi/migration.json index 9d0bf82cf4..757302762d 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -357,13 +357,17 @@ # @dirty-bitmaps: If enabled, QEMU will migrate named dirty bitmaps. # (since 2.12) # +# @late-block-activate: If enabled, the destination will not activate block +# devices (and thus take locks) immediately at the end of migrat= ion. +# (since 2.13) +# # Since: 1.2 ## { 'enum': 'MigrationCapability', 'data': ['xbzrle', 'rdma-pin-all', 'auto-converge', 'zero-blocks', 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram', 'block', 'return-path', 'pause-before-switchover', 'x-multifd', - 'dirty-bitmaps' ] } + 'dirty-bitmaps', 'late-block-activate' ] } =20 ## # @MigrationCapabilityStatus: --=20 2.17.0