From nobody Fri May 3 06:41:56 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505454350262683.2129539135738; Thu, 14 Sep 2017 22:45:50 -0700 (PDT) Received: from localhost ([::1]:51414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsjRk-0001u5-7r for importer@patchew.org; Fri, 15 Sep 2017 01:45:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsjQI-0000ZR-3q for qemu-devel@nongnu.org; Fri, 15 Sep 2017 01:44:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsjQG-0007NE-2d for qemu-devel@nongnu.org; Fri, 15 Sep 2017 01:44:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51110) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsjQF-0007N6-Sr; Fri, 15 Sep 2017 01:44:16 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E70A9C0587F5; Fri, 15 Sep 2017 05:44:14 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-95.pek2.redhat.com [10.72.12.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id B56D769555; Fri, 15 Sep 2017 05:44:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E70A9C0587F5 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=famz@redhat.com From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 15 Sep 2017 13:44:02 +0800 Message-Id: <20170915054404.19914-2-famz@redhat.com> In-Reply-To: <20170915054404.19914-1-famz@redhat.com> References: <20170915054404.19914-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 15 Sep 2017 05:44:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/3] migration: Allow ram_save_cleanup to be called with empty state 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: qemu-stable@nongnu.org, "Dr. David Alan Gilbert" , peterx@redhat.com, Juan Quintela 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" So that we can do cleanup unconditionally at the end of main(). Signed-off-by: Fam Zheng Reviewed-by: Peter Xu --- migration/ram.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index e18b3e2d4f..37e6a71241 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1365,6 +1365,9 @@ static void ram_save_cleanup(void *opaque) RAMState **rsp =3D opaque; RAMBlock *block; =20 + if (!rsp || !*rsp) { + return; + } /* caller have hold iothread lock or is in a bh, so there is * no writing race against this migration_bitmap */ --=20 2.13.5 From nobody Fri May 3 06:41:56 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505454433552803.0936171585039; Thu, 14 Sep 2017 22:47:13 -0700 (PDT) Received: from localhost ([::1]:51420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsjT6-0003gY-V9 for importer@patchew.org; Fri, 15 Sep 2017 01:47:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsjQJ-0000Zn-V7 for qemu-devel@nongnu.org; Fri, 15 Sep 2017 01:44:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsjQJ-0007O9-24 for qemu-devel@nongnu.org; Fri, 15 Sep 2017 01:44:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44644) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsjQI-0007Nx-RU; Fri, 15 Sep 2017 01:44:18 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D707287649; Fri, 15 Sep 2017 05:44:17 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-95.pek2.redhat.com [10.72.12.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E64069555; Fri, 15 Sep 2017 05:44:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D707287649 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=famz@redhat.com From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 15 Sep 2017 13:44:03 +0800 Message-Id: <20170915054404.19914-3-famz@redhat.com> In-Reply-To: <20170915054404.19914-1-famz@redhat.com> References: <20170915054404.19914-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 15 Sep 2017 05:44:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/3] migration: Cancel migration at exit 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: qemu-stable@nongnu.org, "Dr. David Alan Gilbert" , peterx@redhat.com, Juan Quintela 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" bdrv_close_all() would abort() due to op blockers added by BMDS, clean up migration states when main loop quits to avoid that. Signed-off-by: Fam Zheng --- include/migration/misc.h | 1 + migration/migration.c | 7 ++++++- vl.c | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index c079b7771b..b9a26b0898 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -54,5 +54,6 @@ bool migration_has_failed(MigrationState *); /* ...and after the device transmission */ bool migration_in_postcopy_after_devices(MigrationState *); void migration_global_dump(Monitor *mon); +void migrate_cancel(void); =20 #endif diff --git a/migration/migration.c b/migration/migration.c index 959e8ec88e..2c844945c7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1274,11 +1274,16 @@ void qmp_migrate(const char *uri, bool has_blk, boo= l blk, } } =20 -void qmp_migrate_cancel(Error **errp) +void migrate_cancel(void) { migrate_fd_cancel(migrate_get_current()); } =20 +void qmp_migrate_cancel(Error **errp) +{ + migrate_cancel(); +} + void qmp_migrate_set_cache_size(int64_t value, Error **errp) { MigrationState *s =3D migrate_get_current(); diff --git a/vl.c b/vl.c index fb1f05b937..abbe61f40b 100644 --- a/vl.c +++ b/vl.c @@ -87,6 +87,7 @@ int main(int argc, char **argv) #include "sysemu/blockdev.h" #include "hw/block/block.h" #include "migration/misc.h" +#include "migration/savevm.h" #include "migration/snapshot.h" #include "migration/global_state.h" #include "sysemu/tpm.h" @@ -4799,6 +4800,8 @@ int main(int argc, char **argv, char **envp) iothread_stop_all(); =20 pause_all_vcpus(); + migrate_cancel(); + qemu_savevm_state_cleanup(); bdrv_close_all(); res_free(); =20 --=20 2.13.5 From nobody Fri May 3 06:41:56 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505454505775622.4144382268063; Thu, 14 Sep 2017 22:48:25 -0700 (PDT) Received: from localhost ([::1]:51427 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsjUH-0004uU-4H for importer@patchew.org; Fri, 15 Sep 2017 01:48:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50433) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsjQN-0000cl-1B for qemu-devel@nongnu.org; Fri, 15 Sep 2017 01:44:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsjQL-0007PI-Py for qemu-devel@nongnu.org; Fri, 15 Sep 2017 01:44:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55318) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dsjQL-0007P0-Hr; Fri, 15 Sep 2017 01:44:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8BD4C356D7; Fri, 15 Sep 2017 05:44:20 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-95.pek2.redhat.com [10.72.12.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79A84785ED; Fri, 15 Sep 2017 05:44:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8BD4C356D7 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=famz@redhat.com From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 15 Sep 2017 13:44:04 +0800 Message-Id: <20170915054404.19914-4-famz@redhat.com> In-Reply-To: <20170915054404.19914-1-famz@redhat.com> References: <20170915054404.19914-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 15 Sep 2017 05:44:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/3] iotests: Add "quit during block migration" case 195 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: qemu-stable@nongnu.org, "Dr. David Alan Gilbert" , peterx@redhat.com, Juan Quintela 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" Signed-off-by: Fam Zheng --- tests/qemu-iotests/195 | 97 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/195.out | 19 +++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 117 insertions(+) create mode 100755 tests/qemu-iotests/195 create mode 100644 tests/qemu-iotests/195.out diff --git a/tests/qemu-iotests/195 b/tests/qemu-iotests/195 new file mode 100755 index 0000000000..f732b56854 --- /dev/null +++ b/tests/qemu-iotests/195 @@ -0,0 +1,97 @@ +#!/bin/bash +# +# Test quit during block migration (migrate -b) doesn't crash +# +# Copyright 2017 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=3Dfamz@redhat.com + +seq=3D`basename $0` +echo "QA output created by $seq" + +here=3D`pwd` +status=3D1 # failure is the default! + +MIG_SOCKET=3D"${TEST_DIR}/migrate" + +_cleanup() +{ + rm -f "${MIG_SOCKET}" + rm -f "${TEST_IMG}.dest" + _cleanup_test_img + _cleanup_qemu +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +_supported_fmt qcow2 raw qed dmg quorum +_supported_proto file +_supported_os Linux + +size=3D64M +_make_test_img $size +TEST_IMG=3D"${TEST_IMG}.dest" _make_test_img $size + +echo +echo =3D=3D=3D Starting VMs =3D=3D=3D +echo + +qemu_comm_method=3D"qmp" + +_launch_qemu \ + -drive file=3D"${TEST_IMG}",cache=3D$CACHEMODE,driver=3D$IMGFMT,id=3Dd= isk +src=3D$QEMU_HANDLE +_send_qemu_cmd $src "{ 'execute': 'qmp_capabilities' }" 'return' + +_launch_qemu \ + -drive file=3D"${TEST_IMG}.dest",cache=3D$CACHEMODE,driver=3D$IMGFMT,i= d=3Ddisk \ + -incoming "unix:${MIG_SOCKET}" +dest=3D$QEMU_HANDLE +_send_qemu_cmd $dest "{ 'execute': 'qmp_capabilities' }" 'return' + +echo +echo =3D=3D=3D Do block migration to destination =3D=3D=3D +echo + +reply=3D"$(_send_qemu_cmd $src \ + "{ 'execute': 'migrate', + 'arguments': { 'uri': 'unix:${MIG_SOCKET}', 'blk': true } }" \ + 'return\|error')" +echo "$reply" +if echo "$reply" | grep "compiled without old-style" > /dev/null; then + _notrun "migrate -b support not compiled in" +fi + +echo +echo =3D=3D=3D Shut down and check image =3D=3D=3D +echo + +_send_qemu_cmd $src '{"execute":"quit"}' 'return' +_cleanup_qemu + +_check_test_img +TEST_IMG=3D"${TEST_IMG}.dest" _check_test_img + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/195.out b/tests/qemu-iotests/195.out new file mode 100644 index 0000000000..36b2fc5e83 --- /dev/null +++ b/tests/qemu-iotests/195.out @@ -0,0 +1,19 @@ +QA output created by 195 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +Formatting 'TEST_DIR/t.IMGFMT.dest', fmt=3DIMGFMT size=3D67108864 + +=3D=3D=3D Starting VMs =3D=3D=3D + +{"return": {}} +{"return": {}} + +=3D=3D=3D Do block migration to destination =3D=3D=3D + +{"return": {}} + +=3D=3D=3D Shut down and check image =3D=3D=3D + +{"return": {}} +No errors were found on the image. +No errors were found on the image. +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 94e764865a..e7e8fcc722 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -189,3 +189,4 @@ 190 rw auto quick 192 rw auto quick 194 rw auto migration quick +195 rw auto migration quick --=20 2.13.5