From nobody Thu May 2 22:18:37 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@gnu.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@gnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506961971475341.85130159208416; Mon, 2 Oct 2017 09:32:51 -0700 (PDT) Received: from localhost ([::1]:53322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz3e4-0004p1-Fn for importer@patchew.org; Mon, 02 Oct 2017 12:32:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz3dC-0004Vl-8t for qemu-devel@nongnu.org; Mon, 02 Oct 2017 12:31:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dz3d9-0006dZ-1d for qemu-devel@nongnu.org; Mon, 02 Oct 2017 12:31:46 -0400 Received: from smtp.citrix.com ([66.165.176.89]:47968) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1dz3d8-0006aB-Ri for qemu-devel@nongnu.org; Mon, 02 Oct 2017 12:31:42 -0400 X-IronPort-AV: E=Sophos;i="5.42,470,1500940800"; d="scan'208";a="442189833" From: Anthony PERARD To: Date: Mon, 2 Oct 2017 17:30:58 +0100 Message-ID: <20171002163058.15651-1-anthony.perard@citrix.com> X-Mailer: git-send-email 2.14.2 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.89 Subject: [Qemu-devel] [PATCH] migration, xen: Fix block image lock issue on live migration X-BeenThere: qemu-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Juan Quintela , Ian Jackson , "Dr. David Alan Gilbert" , Anthony PERARD , xen-devel@lists.xenproject.org Errors-To: qemu-devel-bounces+importer=patchew.org@gnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When doing a live migration of a Xen guest with libxl, the images for block devices are locked by the original QEMU process, and this prevent the QEMU at the destination to take the lock and the migration fail. From QEMU point of view, once the RAM of a domain is migrated, there is two QMP commands, "stop" then "xen-save-devices-state", at which point a new QEMU is spawned at the destination. Release locks in "xen-save-devices-state" so the destination can takes them. Signed-off-by: Anthony PERARD --- CCing libxl maintainers: CC: Ian Jackson CC: Wei Liu --- migration/savevm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index 4a88228614..69d904c179 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2263,6 +2263,20 @@ void qmp_xen_save_devices_state(const char *filename= , Error **errp) qemu_fclose(f); if (ret < 0) { error_setg(errp, QERR_IO_ERROR); + } else { + /* libxl calls the QMP command "stop" before calling + * "xen-save-devices-state" and in case of migration failure, libxl + * would call "cont". + * So call bdrv_inactivate_all (release locks) here to let the oth= er + * side of the migration take controle of the images. + */ + if (!saved_vm_running) { + ret =3D bdrv_inactivate_all(); + if (ret) { + error_setg(errp, "%s: bdrv_inactivate_all() failed (%d)", + __func__, ret); + } + } } =20 the_end: --=20 Anthony PERARD