From nobody Fri Oct 24 21:59:45 2025 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 151862292957829.753210219843027; Wed, 14 Feb 2018 07:42:09 -0800 (PST) Received: from localhost ([::1]:33290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzCC-0001VI-Lh for importer@patchew.org; Wed, 14 Feb 2018 10:42:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzA3-0008Ia-Fg for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elzA0-00075a-8L for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:55 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40564 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 1elz9z-00074X-VL for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C0114040857; Wed, 14 Feb 2018 15:39:46 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-251.ams2.redhat.com [10.36.116.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id A79C2B3517; Wed, 14 Feb 2018 15:39:45 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com, groug@kaod.org, ross.lagerwall@citrix.com Date: Wed, 14 Feb 2018 15:39:29 +0000 Message-Id: <20180214153938.5410-2-dgilbert@redhat.com> In-Reply-To: <20180214153938.5410-1-dgilbert@redhat.com> References: <20180214153938.5410-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 14 Feb 2018 15:39:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 14 Feb 2018 15:39:46 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL 01/10] migration/xen: Check return value of qemu_fclose 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: Ross Lagerwall QEMUFile uses buffered IO so when writing small amounts (such as the Xen device state file), the actual write call and any errors that may occur only happen as part of qemu_fclose(). Therefore, report IO errors when saving the device state under Xen by checking the return value of qemu_fclose(). Signed-off-by: Ross Lagerwall Message-Id: <20180206163039.23661-1-ross.lagerwall@citrix.com> Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Dr. David Alan Gilbert --- migration/savevm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 3f611c02e8..68b652ff76 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2284,8 +2284,7 @@ void qmp_xen_save_devices_state(const char *filename,= bool has_live, bool live, f =3D qemu_fopen_channel_output(QIO_CHANNEL(ioc)); object_unref(OBJECT(ioc)); ret =3D qemu_save_device_state(f); - qemu_fclose(f); - if (ret < 0) { + if (ret < 0 || qemu_fclose(f) < 0) { error_setg(errp, QERR_IO_ERROR); } else { /* libxl calls the QMP command "stop" before calling --=20 2.14.3 From nobody Fri Oct 24 21:59:45 2025 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 1518623119708830.1453848790854; Wed, 14 Feb 2018 07:45:19 -0800 (PST) Received: from localhost ([::1]:33309 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzFG-0005R0-Hj for importer@patchew.org; Wed, 14 Feb 2018 10:45:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzA3-0008IV-BC for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elzA0-00075l-96 for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:55 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37566 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 1elz9z-00074Z-VP for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A8DB2EAE91; Wed, 14 Feb 2018 15:39:47 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-251.ams2.redhat.com [10.36.116.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3DA1F41A2; Wed, 14 Feb 2018 15:39:46 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com, groug@kaod.org, ross.lagerwall@citrix.com Date: Wed, 14 Feb 2018 15:39:30 +0000 Message-Id: <20180214153938.5410-3-dgilbert@redhat.com> In-Reply-To: <20180214153938.5410-1-dgilbert@redhat.com> References: <20180214153938.5410-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 14 Feb 2018 15:39:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 14 Feb 2018 15:39:47 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL 02/10] migration: improve documentation of postcopy-ram 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: Greg Kurz This capability must have the same value on both source and destination, otherwise migration fails (commit 875fcd013ab6 "migration: incoming postcopy advise sanity checks"). Let's write it down in various places where postcopy-ram is documented. Signed-off-by: Greg Kurz Message-Id: <151801810352.29167.4832480228518630626.stgit@bahia.lan> Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Eric Blake Reviewed-by: Dr. David Alan Gilbert --- docs/devel/migration.rst | 4 ++-- hmp-commands.hx | 3 ++- qapi/migration.json | 10 ++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst index bf97080dac..9d1b7657f0 100644 --- a/docs/devel/migration.rst +++ b/docs/devel/migration.rst @@ -387,8 +387,8 @@ doesn't finish in a given time the switch is made to po= stcopy. Enabling postcopy ----------------- =20 -To enable postcopy, issue this command on the monitor prior to the -start of migration: +To enable postcopy, issue this command on the monitor (both source and +destination) prior to the start of migration: =20 ``migrate_set_capability postcopy-ram on`` =20 diff --git a/hmp-commands.hx b/hmp-commands.hx index 15620c94d3..d26eb4119b 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1041,7 +1041,8 @@ ETEXI .params =3D "", .help =3D "Followup to a migration command to switch the mig= ration" " to postcopy mode. The postcopy-ram capability must= " - "be set before the original migration command.", + "be set on both source and destination before the " + "original migration command .", .cmd =3D hmp_migrate_start_postcopy, }, =20 diff --git a/qapi/migration.json b/qapi/migration.json index 4cd3d13158..7f465a1902 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -327,8 +327,10 @@ # to speed up convergence of RAM migration. (since 1.6) # # @postcopy-ram: Start executing on the migration target before all of RAM= has -# been migrated, pulling the remaining pages along as needed. NOT= E: If -# the migration fails during postcopy the VM will fail. (since 2= .6) +# been migrated, pulling the remaining pages along as needed. The +# capacity must have the same setting on both source and target +# or migration will not even start. NOTE: If the migration fails = during +# postcopy the VM will fail. (since 2.6) # # @x-colo: If enabled, migration will never end, and the state of the VM o= n the # primary side will be migrated continuously to the VM on secondary @@ -742,8 +744,8 @@ # @migrate-start-postcopy: # # Followup to a migration command to switch the migration to postcopy mode. -# The postcopy-ram capability must be set before the original migration -# command. +# The postcopy-ram capability must be set on both source and destination +# before the original migration command. # # Since: 2.5 # --=20 2.14.3 From nobody Fri Oct 24 21:59:45 2025 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 1518623329017866.4702289327008; Wed, 14 Feb 2018 07:48:49 -0800 (PST) Received: from localhost ([::1]:33604 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzIe-0008Cm-49 for importer@patchew.org; Wed, 14 Feb 2018 10:48:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzA3-0008IX-Dp for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:40:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elzA0-00075v-96 for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:55 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58424 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 1elz9z-00074a-VM for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5AE340FB650; Wed, 14 Feb 2018 15:39:48 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-251.ams2.redhat.com [10.36.116.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0C5CB351A; Wed, 14 Feb 2018 15:39:47 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com, groug@kaod.org, ross.lagerwall@citrix.com Date: Wed, 14 Feb 2018 15:39:31 +0000 Message-Id: <20180214153938.5410-4-dgilbert@redhat.com> In-Reply-To: <20180214153938.5410-1-dgilbert@redhat.com> References: <20180214153938.5410-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 14 Feb 2018 15:39:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 14 Feb 2018 15:39:48 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL 03/10] tests/migration: Add source to PC boot block 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" The boot block used in the migration test is currently only shipped as a hex (with the source in the git commit message of ea0c6d62), change this to actually include the source. A script is added to rebuild the header but the expectation is that the generated hex is shipped as well as the .s, so that there's no requirement to have just the right assembler etc. Signed-off-by: Dr. David Alan Gilbert Message-Id: <20180213100606.5379-1-dgilbert@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Dr. David Alan Gilbert Removed blank line at end of script --- tests/migration-test.c | 52 ++---------------- tests/migration/rebuild-x86-bootblock.sh | 33 ++++++++++++ tests/migration/x86-a-b-bootblock.h | 51 ++++++++++++++++++ tests/migration/x86-a-b-bootblock.s | 92 ++++++++++++++++++++++++++++= ++++ 4 files changed, 180 insertions(+), 48 deletions(-) create mode 100755 tests/migration/rebuild-x86-bootblock.sh create mode 100644 tests/migration/x86-a-b-bootblock.h create mode 100644 tests/migration/x86-a-b-bootblock.s diff --git a/tests/migration-test.c b/tests/migration-test.c index d0abad40f5..97fdb1988e 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -1,7 +1,7 @@ /* * QTest testcase for migration * - * Copyright (c) 2016 Red Hat, Inc. and/or its affiliates + * Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates * based on the vhost-user-test.c that is: * Copyright (c) 2014 Virtual Open Systems Sarl. * @@ -78,59 +78,15 @@ static bool ufd_version_check(void) static const char *tmpfs; =20 /* A simple PC boot sector that modifies memory (1-100MB) quickly - * outputing a 'B' every so often if it's still running. + * outputting a 'B' every so often if it's still running. */ -unsigned char bootsect[] =3D { - 0xfa, 0x0f, 0x01, 0x16, 0x74, 0x7c, 0x66, 0xb8, 0x01, 0x00, 0x00, 0x00, - 0x0f, 0x22, 0xc0, 0x66, 0xea, 0x20, 0x7c, 0x00, 0x00, 0x08, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x92, 0x0c, 0x02, - 0xe6, 0x92, 0xb8, 0x10, 0x00, 0x00, 0x00, 0x8e, 0xd8, 0x66, 0xb8, 0x41, - 0x00, 0x66, 0xba, 0xf8, 0x03, 0xee, 0xb3, 0x00, 0xb8, 0x00, 0x00, 0x10, - 0x00, 0xfe, 0x00, 0x05, 0x00, 0x10, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x40, - 0x06, 0x7c, 0xf2, 0xfe, 0xc3, 0x75, 0xe9, 0x66, 0xb8, 0x42, 0x00, 0x66, - 0xba, 0xf8, 0x03, 0xee, 0xeb, 0xde, 0x66, 0x90, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00, 0x27, 0x00, 0x5c, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa -}; +#include "tests/migration/x86-a-b-bootblock.h" =20 static void init_bootfile_x86(const char *bootpath) { FILE *bootfile =3D fopen(bootpath, "wb"); =20 - g_assert_cmpint(fwrite(bootsect, 512, 1, bootfile), =3D=3D, 1); + g_assert_cmpint(fwrite(x86_bootsect, 512, 1, bootfile), =3D=3D, 1); fclose(bootfile); } =20 diff --git a/tests/migration/rebuild-x86-bootblock.sh b/tests/migration/reb= uild-x86-bootblock.sh new file mode 100755 index 0000000000..86cec5d284 --- /dev/null +++ b/tests/migration/rebuild-x86-bootblock.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# Author: dgilbert@redhat.com + +ASMFILE=3D$PWD/tests/migration/x86-a-b-bootblock.s +HEADER=3D$PWD/tests/migration/x86-a-b-bootblock.h + +if [ ! -e "$ASMFILE" ] +then + echo "Couldn't find $ASMFILE" >&2 + exit 1 +fi + +ASM_WORK_DIR=3D$(mktemp -d --tmpdir X86BB.XXXXXX) +cd "$ASM_WORK_DIR" && +as --32 -march=3Di486 "$ASMFILE" -o x86.o && +objcopy -O binary x86.o x86.boot && +dd if=3Dx86.boot of=3Dx86.bootsect bs=3D256 count=3D2 skip=3D124 && +xxd -i x86.bootsect | +sed -e 's/.*int.*//' > x86.hex && +cat - x86.hex < "$HEADER" +/* This file is automatically generated from + * tests/migration/x86-a-b-bootblock.s, edit that and then run + * tests/migration/rebuild-x86-bootblock.sh to update, + * and then remember to send both in your patch submission. + */ +HERE + +rm x86.hex x86.bootsect x86.boot x86.o +cd .. && rmdir "$ASM_WORK_DIR" diff --git a/tests/migration/x86-a-b-bootblock.h b/tests/migration/x86-a-b-= bootblock.h new file mode 100644 index 0000000000..78a151fe2a --- /dev/null +++ b/tests/migration/x86-a-b-bootblock.h @@ -0,0 +1,51 @@ +/* This file is automatically generated from + * tests/migration/x86-a-b-bootblock.s, edit that and then run + * tests/migration/rebuild-x86-bootblock.sh to update, + * and then remember to send both in your patch submission. + */ +unsigned char x86_bootsect[] =3D { + 0xfa, 0x0f, 0x01, 0x16, 0x74, 0x7c, 0x66, 0xb8, 0x01, 0x00, 0x00, 0x00, + 0x0f, 0x22, 0xc0, 0x66, 0xea, 0x20, 0x7c, 0x00, 0x00, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x92, 0x0c, 0x02, + 0xe6, 0x92, 0xb8, 0x10, 0x00, 0x00, 0x00, 0x8e, 0xd8, 0x66, 0xb8, 0x41, + 0x00, 0x66, 0xba, 0xf8, 0x03, 0xee, 0xb3, 0x00, 0xb8, 0x00, 0x00, 0x10, + 0x00, 0xfe, 0x00, 0x05, 0x00, 0x10, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x40, + 0x06, 0x7c, 0xf2, 0xfe, 0xc3, 0x75, 0xe9, 0x66, 0xb8, 0x42, 0x00, 0x66, + 0xba, 0xf8, 0x03, 0xee, 0xeb, 0xde, 0x66, 0x90, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00, 0x27, 0x00, 0x5c, 0x7c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa +}; + diff --git a/tests/migration/x86-a-b-bootblock.s b/tests/migration/x86-a-b-= bootblock.s new file mode 100644 index 0000000000..b1642641a7 --- /dev/null +++ b/tests/migration/x86-a-b-bootblock.s @@ -0,0 +1,92 @@ +# x86 bootblock used in migration test +# repeatedly increments the first byte of each page in a 100MB +# range. +# Outputs an initial 'A' on serial followed by repeated 'B's +# +# run tests/migration/rebuild-x86-bootblock.sh +# to regenerate the hex, and remember to include both the .h and .s +# in any patches. +# +# Copyright (c) 2016 Red Hat, Inc. and/or its affiliates +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# Author: dgilbert@redhat.com + + +.code16 +.org 0x7c00 + .file "fill.s" + .text + .globl start + .type start, @function +start: # at 0x7c00 ? + cli + lgdt gdtdesc + mov $1,%eax + mov %eax,%cr0 # Protected mode enable + data32 ljmp $8,$0x7c20 + +.org 0x7c20 +.code32 + # A20 enable - not sure I actually need this + inb $0x92,%al + or $2,%al + outb %al, $0x92 + + # set up DS for the whole of RAM (needed on KVM) + mov $16,%eax + mov %eax,%ds + + mov $65,%ax + mov $0x3f8,%dx + outb %al,%dx + + # bl keeps a counter so we limit the output speed + mov $0, %bl +mainloop: + # Start from 1MB + mov $(1024*1024),%eax +innerloop: + incb (%eax) + add $4096,%eax + cmp $(100*1024*1024),%eax + jl innerloop + + inc %bl + jnz mainloop + + mov $66,%ax + mov $0x3f8,%dx + outb %al,%dx + + jmp mainloop + + # GDT magic from old (GPLv2) Grub startup.S + .p2align 2 /* force 4-byte alignment */ +gdt: + .word 0, 0 + .byte 0, 0, 0, 0 + + /* -- code segment -- + * base =3D 0x00000000, limit =3D 0xFFFFF (4 KiB Granularity), pre= sent + * type =3D 32bit code execute/read, DPL =3D 0 + */ + .word 0xFFFF, 0 + .byte 0, 0x9A, 0xCF, 0 + + /* -- data segment -- + * base =3D 0x00000000, limit 0xFFFFF (4 KiB Granularity), present + * type =3D 32 bit data read/write, DPL =3D 0 + */ + .word 0xFFFF, 0 + .byte 0, 0x92, 0xCF, 0 + +gdtdesc: + .word 0x27 /* limit */ + .long gdt /* addr */ + +/* I'm a bootable disk */ +.org 0x7dfe + .byte 0x55 + .byte 0xAA --=20 2.14.3 From nobody Fri Oct 24 21:59:45 2025 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 1518622931692236.63581962362582; Wed, 14 Feb 2018 07:42:11 -0800 (PST) Received: from localhost ([::1]:33289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzCB-0001UW-8l for importer@patchew.org; Wed, 14 Feb 2018 10:42:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzA3-0008IY-EM for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elzA0-00075Y-7W for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:55 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40565 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 1elz9z-00074Y-VK for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E1D224040856; Wed, 14 Feb 2018 15:39:49 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-251.ams2.redhat.com [10.36.116.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08EA5B3516; Wed, 14 Feb 2018 15:39:48 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com, groug@kaod.org, ross.lagerwall@citrix.com Date: Wed, 14 Feb 2018 15:39:32 +0000 Message-Id: <20180214153938.5410-5-dgilbert@redhat.com> In-Reply-To: <20180214153938.5410-1-dgilbert@redhat.com> References: <20180214153938.5410-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 14 Feb 2018 15:39:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 14 Feb 2018 15:39:49 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL 04/10] migration: Fix early failure cleanup 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" Avoid crash in cleanup after a very early migration failure (possibly due to my 688a3dcba980bf01344a 'Route errors down ...') Signed-off-by: Dr. David Alan Gilbert Message-Id: <20180212160340.15333-2-dgilbert@redhat.com> Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu --- migration/ram.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 8333d8e35e..7095c1040e 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1602,11 +1602,13 @@ static void xbzrle_load_cleanup(void) =20 static void ram_state_cleanup(RAMState **rsp) { - migration_page_queue_free(*rsp); - qemu_mutex_destroy(&(*rsp)->bitmap_mutex); - qemu_mutex_destroy(&(*rsp)->src_page_req_mutex); - g_free(*rsp); - *rsp =3D NULL; + if (*rsp) { + migration_page_queue_free(*rsp); + qemu_mutex_destroy(&(*rsp)->bitmap_mutex); + qemu_mutex_destroy(&(*rsp)->src_page_req_mutex); + g_free(*rsp); + *rsp =3D NULL; + } } =20 static void xbzrle_cleanup(void) --=20 2.14.3 From nobody Fri Oct 24 21:59:45 2025 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 1518622931665988.6751634304132; Wed, 14 Feb 2018 07:42:11 -0800 (PST) Received: from localhost ([::1]:33292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzCE-0001XW-SG for importer@patchew.org; Wed, 14 Feb 2018 10:42:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzA3-0008IZ-FO for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elzA0-00075m-8S for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:55 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49836 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 1elz9z-00074j-VP for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A94F8182D1E; Wed, 14 Feb 2018 15:39:51 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-251.ams2.redhat.com [10.36.116.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id 257B0B351A; Wed, 14 Feb 2018 15:39:50 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com, groug@kaod.org, ross.lagerwall@citrix.com Date: Wed, 14 Feb 2018 15:39:33 +0000 Message-Id: <20180214153938.5410-6-dgilbert@redhat.com> In-Reply-To: <20180214153938.5410-1-dgilbert@redhat.com> References: <20180214153938.5410-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 14 Feb 2018 15:39:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 14 Feb 2018 15:39:51 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL 05/10] tests/migration: Add test for migration to bad destination 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" Check the source survives. Signed-off-by: Dr. David Alan Gilbert Message-Id: <20180212160340.15333-3-dgilbert@redhat.com> Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Peter Xu --- tests/migration-test.c | 65 ++++++++++++++++++++++++++++++++++++++--------= ---- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index 97fdb1988e..74f9361bdd 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -434,28 +434,31 @@ static void test_migrate_start(QTestState **from, QTe= stState **to, g_free(cmd_dst); } =20 -static void test_migrate_end(QTestState *from, QTestState *to) +static void test_migrate_end(QTestState *from, QTestState *to, bool test_d= est) { unsigned char dest_byte_a, dest_byte_b, dest_byte_c, dest_byte_d; =20 qtest_quit(from); =20 - qtest_memread(to, start_address, &dest_byte_a, 1); + if (test_dest) { + qtest_memread(to, start_address, &dest_byte_a, 1); =20 - /* Destination still running, wait for a byte to change */ - do { - qtest_memread(to, start_address, &dest_byte_b, 1); - usleep(1000 * 10); - } while (dest_byte_a =3D=3D dest_byte_b); + /* Destination still running, wait for a byte to change */ + do { + qtest_memread(to, start_address, &dest_byte_b, 1); + usleep(1000 * 10); + } while (dest_byte_a =3D=3D dest_byte_b); + + qtest_qmp_discard_response(to, "{ 'execute' : 'stop'}"); =20 - qtest_qmp_discard_response(to, "{ 'execute' : 'stop'}"); - /* With it stopped, check nothing changes */ - qtest_memread(to, start_address, &dest_byte_c, 1); - usleep(1000 * 200); - qtest_memread(to, start_address, &dest_byte_d, 1); - g_assert_cmpint(dest_byte_c, =3D=3D, dest_byte_d); + /* With it stopped, check nothing changes */ + qtest_memread(to, start_address, &dest_byte_c, 1); + usleep(1000 * 200); + qtest_memread(to, start_address, &dest_byte_d, 1); + g_assert_cmpint(dest_byte_c, =3D=3D, dest_byte_d); =20 - check_guests_ram(to); + check_guests_ram(to); + } =20 qtest_quit(to); =20 @@ -547,7 +550,38 @@ static void test_migrate(void) =20 g_free(uri); =20 - test_migrate_end(from, to); + test_migrate_end(from, to, true); +} + +static void test_baddest(void) +{ + QTestState *from, *to; + QDict *rsp, *rsp_return; + const char *status; + bool failed; + + test_migrate_start(&from, &to, "tcp:0:0"); + migrate(from, "tcp:0:0"); + do { + rsp =3D wait_command(from, "{ 'execute': 'query-migrate' }"); + rsp_return =3D qdict_get_qdict(rsp, "return"); + + status =3D qdict_get_str(rsp_return, "status"); + + g_assert(!strcmp(status, "setup") || !(strcmp(status, "failed"))); + failed =3D !strcmp(status, "failed"); + QDECREF(rsp); + } while (!failed); + + /* Is the machine currently running? */ + rsp =3D wait_command(from, "{ 'execute': 'query-status' }"); + g_assert(qdict_haskey(rsp, "return")); + rsp_return =3D qdict_get_qdict(rsp, "return"); + g_assert(qdict_haskey(rsp_return, "running")); + g_assert(qdict_get_bool(rsp_return, "running")); + QDECREF(rsp); + + test_migrate_end(from, to, false); } =20 int main(int argc, char **argv) @@ -571,6 +605,7 @@ int main(int argc, char **argv) =20 qtest_add_func("/migration/postcopy/unix", test_migrate); qtest_add_func("/migration/deprecated", test_deprecated); + qtest_add_func("/migration/bad_dest", test_baddest); =20 ret =3D g_test_run(); =20 --=20 2.14.3 From nobody Fri Oct 24 21:59:45 2025 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518623124414910.0557741481282; Wed, 14 Feb 2018 07:45:24 -0800 (PST) Received: from localhost ([::1]:33307 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzFD-0005OM-BX for importer@patchew.org; Wed, 14 Feb 2018 10:45:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53921) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzA3-0008IW-BZ for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elzA0-00076E-UG for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:55 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40572 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 1elzA0-000763-L0 for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26BEB407244E; Wed, 14 Feb 2018 15:39:52 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-251.ams2.redhat.com [10.36.116.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42092F41A2; Wed, 14 Feb 2018 15:39:51 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com, groug@kaod.org, ross.lagerwall@citrix.com Date: Wed, 14 Feb 2018 15:39:34 +0000 Message-Id: <20180214153938.5410-7-dgilbert@redhat.com> In-Reply-To: <20180214153938.5410-1-dgilbert@redhat.com> References: <20180214153938.5410-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 14 Feb 2018 15:39:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 14 Feb 2018 15:39:52 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL 06/10] migration: better error handling with QEMUFile 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: Peter Xu If the postcopy down due to some reason, we can always see this on dst: qemu-system-x86_64: RP: Received invalid message 0x0000 length 0x0000 However in most cases that's not the real issue. The problem is that qemu_get_be16() has no way to show whether the returned data is valid or not, and we are _always_ assuming it is valid. That's possibly not wise. The best approach to solve this would be: refactoring QEMUFile interface to allow the APIs to return error if there is. However it needs quite a bit of work and testing. For now, let's explicitly check the validity first before using the data in all places for qemu_get_*(). This patch tries to fix most of the cases I can see. Only if we are with this, can we make sure we are processing the valid data, and also can we make sure we can capture the channel down events correctly. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20180208103132.28452-2-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/migration.c | 5 +++++ migration/ram.c | 21 +++++++++++++++++---- migration/savevm.c | 40 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 86d69120a6..e2a5a832c6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1709,6 +1709,11 @@ static void *source_return_path_thread(void *opaque) header_type =3D qemu_get_be16(rp); header_len =3D qemu_get_be16(rp); =20 + if (qemu_file_get_error(rp)) { + mark_source_rp_bad(ms); + goto out; + } + if (header_type >=3D MIG_RP_MSG_MAX || header_type =3D=3D MIG_RP_MSG_INVALID) { error_report("RP: Received invalid message 0x%04x length 0x%04= x", diff --git a/migration/ram.c b/migration/ram.c index 7095c1040e..5e33e5cc79 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2700,6 +2700,16 @@ static int ram_load_postcopy(QEMUFile *f) uint8_t ch; =20 addr =3D qemu_get_be64(f); + + /* + * If qemu file error, we should stop here, and then "addr" + * may be invalid + */ + ret =3D qemu_file_get_error(f); + if (ret) { + break; + } + flags =3D addr & ~TARGET_PAGE_MASK; addr &=3D TARGET_PAGE_MASK; =20 @@ -2780,9 +2790,15 @@ static int ram_load_postcopy(QEMUFile *f) error_report("Unknown combination of migration flags: %#x" " (postcopy mode)", flags); ret =3D -EINVAL; + break; + } + + /* Detect for any possible file errors */ + if (!ret && qemu_file_get_error(f)) { + ret =3D qemu_file_get_error(f); } =20 - if (place_needed) { + if (!ret && place_needed) { /* This gets called at the last target page in the host page */ void *place_dest =3D host + TARGET_PAGE_SIZE - block->page_siz= e; =20 @@ -2794,9 +2810,6 @@ static int ram_load_postcopy(QEMUFile *f) place_source, block); } } - if (!ret) { - ret =3D qemu_file_get_error(f); - } } =20 return ret; diff --git a/migration/savevm.c b/migration/savevm.c index 68b652ff76..967c3bca0d 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1781,6 +1781,11 @@ static int loadvm_process_command(QEMUFile *f) cmd =3D qemu_get_be16(f); len =3D qemu_get_be16(f); =20 + /* Check validity before continue processing of cmds */ + if (qemu_file_get_error(f)) { + return qemu_file_get_error(f); + } + trace_loadvm_process_command(cmd, len); if (cmd >=3D MIG_CMD_MAX || cmd =3D=3D MIG_CMD_INVALID) { error_report("MIG_CMD 0x%x unknown (len 0x%x)", cmd, len); @@ -1846,6 +1851,7 @@ static int loadvm_process_command(QEMUFile *f) */ static bool check_section_footer(QEMUFile *f, SaveStateEntry *se) { + int ret; uint8_t read_mark; uint32_t read_section_id; =20 @@ -1856,6 +1862,13 @@ static bool check_section_footer(QEMUFile *f, SaveSt= ateEntry *se) =20 read_mark =3D qemu_get_byte(f); =20 + ret =3D qemu_file_get_error(f); + if (ret) { + error_report("%s: Read section footer failed: %d", + __func__, ret); + return false; + } + if (read_mark !=3D QEMU_VM_SECTION_FOOTER) { error_report("Missing section footer for %s", se->idstr); return false; @@ -1891,6 +1904,13 @@ qemu_loadvm_section_start_full(QEMUFile *f, Migratio= nIncomingState *mis) instance_id =3D qemu_get_be32(f); version_id =3D qemu_get_be32(f); =20 + ret =3D qemu_file_get_error(f); + if (ret) { + error_report("%s: Failed to read instance/version ID: %d", + __func__, ret); + return ret; + } + trace_qemu_loadvm_state_section_startfull(section_id, idstr, instance_id, version_id); /* Find savevm section */ @@ -1938,6 +1958,13 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationI= ncomingState *mis) =20 section_id =3D qemu_get_be32(f); =20 + ret =3D qemu_file_get_error(f); + if (ret) { + error_report("%s: Failed to read section ID: %d", + __func__, ret); + return ret; + } + trace_qemu_loadvm_state_section_partend(section_id); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (se->load_section_id =3D=3D section_id) { @@ -2005,8 +2032,14 @@ static int qemu_loadvm_state_main(QEMUFile *f, Migra= tionIncomingState *mis) uint8_t section_type; int ret =3D 0; =20 - while ((section_type =3D qemu_get_byte(f)) !=3D QEMU_VM_EOF) { - ret =3D 0; + while (true) { + section_type =3D qemu_get_byte(f); + + if (qemu_file_get_error(f)) { + ret =3D qemu_file_get_error(f); + break; + } + trace_qemu_loadvm_state_section(section_type); switch (section_type) { case QEMU_VM_SECTION_START: @@ -2030,6 +2063,9 @@ static int qemu_loadvm_state_main(QEMUFile *f, Migrat= ionIncomingState *mis) goto out; } break; + case QEMU_VM_EOF: + /* This is the end of migration */ + goto out; default: error_report("Unknown savevm section type %d", section_type); ret =3D -EINVAL; --=20 2.14.3 From nobody Fri Oct 24 21:59:45 2025 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 151862293061617.730672168694127; Wed, 14 Feb 2018 07:42:10 -0800 (PST) Received: from localhost ([::1]:33291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzCD-0001X3-Or for importer@patchew.org; Wed, 14 Feb 2018 10:42:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzA3-0008Ic-SS for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elzA2-00076z-0M for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:55 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45878 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 1elzA1-00076d-OO for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:53 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 448AA40201A0; Wed, 14 Feb 2018 15:39:53 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-251.ams2.redhat.com [10.36.116.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E5B7D1EB1; Wed, 14 Feb 2018 15:39:52 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com, groug@kaod.org, ross.lagerwall@citrix.com Date: Wed, 14 Feb 2018 15:39:35 +0000 Message-Id: <20180214153938.5410-8-dgilbert@redhat.com> In-Reply-To: <20180214153938.5410-1-dgilbert@redhat.com> References: <20180214153938.5410-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 14 Feb 2018 15:39:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 14 Feb 2018 15:39:53 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL 07/10] migration: reuse mis->userfault_quit_fd 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: Peter Xu It was only used for quitting the page fault thread before. Let it be something more useful - now we can use it to notify a "wake" for the page fault thread (for any reason), and it only means "quit" if the fault_thread_quit is set. Since we changed what it does, renaming it to userfault_event_fd. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20180208103132.28452-3-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/migration.h | 6 ++++-- migration/postcopy-ram.c | 29 ++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index 848f638a20..75c72d3c8f 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -35,6 +35,8 @@ struct MigrationIncomingState { bool have_fault_thread; QemuThread fault_thread; QemuSemaphore fault_thread_sem; + /* Set this when we want the fault thread to quit */ + bool fault_thread_quit; =20 bool have_listen_thread; QemuThread listen_thread; @@ -42,8 +44,8 @@ struct MigrationIncomingState { =20 /* For the kernel to send us notifications */ int userfault_fd; - /* To tell the fault_thread to quit */ - int userfault_quit_fd; + /* To notify the fault_thread to wake, e.g., when need to quit */ + int userfault_event_fd; QEMUFile *to_src_file; QemuMutex rp_mutex; /* We send replies from multiple threads */ void *postcopy_tmp_page; diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index bec6c2c66b..9ad4f20f82 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -387,17 +387,18 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingSt= ate *mis) * currently be at 0, we're going to increment it to 1 */ tmp64 =3D 1; - if (write(mis->userfault_quit_fd, &tmp64, 8) =3D=3D 8) { + atomic_set(&mis->fault_thread_quit, 1); + if (write(mis->userfault_event_fd, &tmp64, 8) =3D=3D 8) { trace_postcopy_ram_incoming_cleanup_join(); qemu_thread_join(&mis->fault_thread); } else { /* Not much we can do here, but may as well report it */ - error_report("%s: incrementing userfault_quit_fd: %s", __func_= _, + error_report("%s: incrementing userfault_event_fd: %s", __func= __, strerror(errno)); } trace_postcopy_ram_incoming_cleanup_closeuf(); close(mis->userfault_fd); - close(mis->userfault_quit_fd); + close(mis->userfault_event_fd); mis->have_fault_thread =3D false; } =20 @@ -520,7 +521,7 @@ static void *postcopy_ram_fault_thread(void *opaque) pfd[0].fd =3D mis->userfault_fd; pfd[0].events =3D POLLIN; pfd[0].revents =3D 0; - pfd[1].fd =3D mis->userfault_quit_fd; + pfd[1].fd =3D mis->userfault_event_fd; pfd[1].events =3D POLLIN; /* Waiting for eventfd to go positive */ pfd[1].revents =3D 0; =20 @@ -530,8 +531,18 @@ static void *postcopy_ram_fault_thread(void *opaque) } =20 if (pfd[1].revents) { - trace_postcopy_ram_fault_thread_quit(); - break; + uint64_t tmp64 =3D 0; + + /* Consume the signal */ + if (read(mis->userfault_event_fd, &tmp64, 8) !=3D 8) { + /* Nothing obviously nicer than posting this error. */ + error_report("%s: read() failed", __func__); + } + + if (atomic_read(&mis->fault_thread_quit)) { + trace_postcopy_ram_fault_thread_quit(); + break; + } } =20 ret =3D read(mis->userfault_fd, &msg, sizeof(msg)); @@ -610,9 +621,9 @@ int postcopy_ram_enable_notify(MigrationIncomingState *= mis) } =20 /* Now an eventfd we use to tell the fault-thread to quit */ - mis->userfault_quit_fd =3D eventfd(0, EFD_CLOEXEC); - if (mis->userfault_quit_fd =3D=3D -1) { - error_report("%s: Opening userfault_quit_fd: %s", __func__, + mis->userfault_event_fd =3D eventfd(0, EFD_CLOEXEC); + if (mis->userfault_event_fd =3D=3D -1) { + error_report("%s: Opening userfault_event_fd: %s", __func__, strerror(errno)); close(mis->userfault_fd); return -1; --=20 2.14.3 From nobody Fri Oct 24 21:59:45 2025 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 1518623575717526.9213441092203; Wed, 14 Feb 2018 07:52:55 -0800 (PST) Received: from localhost ([::1]:33803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzMc-0003gX-Uv for importer@patchew.org; Wed, 14 Feb 2018 10:52:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzAA-0008SZ-FS for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:40:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elzA3-00077X-56 for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:40:02 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37570 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 1elzA2-000776-V4 for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:55 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 60F88EB70C; Wed, 14 Feb 2018 15:39:54 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-251.ams2.redhat.com [10.36.116.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C2BCD1EB1; Wed, 14 Feb 2018 15:39:53 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com, groug@kaod.org, ross.lagerwall@citrix.com Date: Wed, 14 Feb 2018 15:39:36 +0000 Message-Id: <20180214153938.5410-9-dgilbert@redhat.com> In-Reply-To: <20180214153938.5410-1-dgilbert@redhat.com> References: <20180214153938.5410-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 14 Feb 2018 15:39:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 14 Feb 2018 15:39:54 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL 08/10] migration: provide postcopy_fault_thread_notify() 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: Peter Xu A general helper to notify the fault thread. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20180208103132.28452-4-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/postcopy-ram.c | 35 ++++++++++++++++++++--------------- migration/postcopy-ram.h | 2 ++ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 9ad4f20f82..032abfbf1a 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -377,25 +377,15 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingSt= ate *mis) trace_postcopy_ram_incoming_cleanup_entry(); =20 if (mis->have_fault_thread) { - uint64_t tmp64; - if (qemu_ram_foreach_block(cleanup_range, mis)) { return -1; } - /* - * Tell the fault_thread to exit, it's an eventfd that should - * currently be at 0, we're going to increment it to 1 - */ - tmp64 =3D 1; + /* Let the fault thread quit */ atomic_set(&mis->fault_thread_quit, 1); - if (write(mis->userfault_event_fd, &tmp64, 8) =3D=3D 8) { - trace_postcopy_ram_incoming_cleanup_join(); - qemu_thread_join(&mis->fault_thread); - } else { - /* Not much we can do here, but may as well report it */ - error_report("%s: incrementing userfault_event_fd: %s", __func= __, - strerror(errno)); - } + postcopy_fault_thread_notify(mis); + trace_postcopy_ram_incoming_cleanup_join(); + qemu_thread_join(&mis->fault_thread); + trace_postcopy_ram_incoming_cleanup_closeuf(); close(mis->userfault_fd); close(mis->userfault_event_fd); @@ -824,6 +814,21 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mi= s) =20 /* -----------------------------------------------------------------------= -- */ =20 +void postcopy_fault_thread_notify(MigrationIncomingState *mis) +{ + uint64_t tmp64 =3D 1; + + /* + * Wakeup the fault_thread. It's an eventfd that should currently + * be at 0, we're going to increment it to 1 + */ + if (write(mis->userfault_event_fd, &tmp64, 8) !=3D 8) { + /* Not much we can do here, but may as well report it */ + error_report("%s: incrementing failed: %s", __func__, + strerror(errno)); + } +} + /** * postcopy_discard_send_init: Called at the start of each RAMBlock before * asking to discard individual ranges. diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index 77ea0fd264..14f6cadcbd 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -114,4 +114,6 @@ PostcopyState postcopy_state_get(void); /* Set the state and return the old state */ PostcopyState postcopy_state_set(PostcopyState new_state); =20 +void postcopy_fault_thread_notify(MigrationIncomingState *mis); + #endif --=20 2.14.3 From nobody Fri Oct 24 21:59:45 2025 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 1518623391836540.7732506147652; Wed, 14 Feb 2018 07:49:51 -0800 (PST) Received: from localhost ([::1]:33661 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzJe-0000mv-Ov for importer@patchew.org; Wed, 14 Feb 2018 10:49:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzA7-0008Mt-5S for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:40:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elzA4-00078s-E9 for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:58 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40576 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 1elzA4-00078J-09 for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:56 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D2A94040857; Wed, 14 Feb 2018 15:39:55 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-251.ams2.redhat.com [10.36.116.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id 978BCB3516; Wed, 14 Feb 2018 15:39:54 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com, groug@kaod.org, ross.lagerwall@citrix.com Date: Wed, 14 Feb 2018 15:39:37 +0000 Message-Id: <20180214153938.5410-10-dgilbert@redhat.com> In-Reply-To: <20180214153938.5410-1-dgilbert@redhat.com> References: <20180214153938.5410-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 14 Feb 2018 15:39:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 14 Feb 2018 15:39:55 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL 09/10] migration: allow send_rq to fail 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: Peter Xu We will not allow failures to happen when sending data from destination to source via the return path. However it is possible that there can be errors along the way. This patch allows the migrate_send_rp_message() to return error when it happens, and further extended it to migrate_send_rp_req_pages(). Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20180208103132.28452-9-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/migration.c | 35 ++++++++++++++++++++++++++++------- migration/migration.h | 2 +- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index e2a5a832c6..913f658c3e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -205,17 +205,35 @@ static void deferred_incoming_migration(Error **errp) * Send a message on the return channel back to the source * of the migration. */ -static void migrate_send_rp_message(MigrationIncomingState *mis, - enum mig_rp_message_type message_type, - uint16_t len, void *data) +static int migrate_send_rp_message(MigrationIncomingState *mis, + enum mig_rp_message_type message_type, + uint16_t len, void *data) { + int ret =3D 0; + trace_migrate_send_rp_message((int)message_type, len); qemu_mutex_lock(&mis->rp_mutex); + + /* + * It's possible that the file handle got lost due to network + * failures. + */ + if (!mis->to_src_file) { + ret =3D -EIO; + goto error; + } + qemu_put_be16(mis->to_src_file, (unsigned int)message_type); qemu_put_be16(mis->to_src_file, len); qemu_put_buffer(mis->to_src_file, data, len); qemu_fflush(mis->to_src_file); + + /* It's possible that qemu file got error during sending */ + ret =3D qemu_file_get_error(mis->to_src_file); + +error: qemu_mutex_unlock(&mis->rp_mutex); + return ret; } =20 /* Request a range of pages from the source VM at the given @@ -225,11 +243,12 @@ static void migrate_send_rp_message(MigrationIncoming= State *mis, * Start: Address offset within the RB * Len: Length in bytes required - must be a multiple of pagesize */ -void migrate_send_rp_req_pages(MigrationIncomingState *mis, const char *rb= name, - ram_addr_t start, size_t len) +int migrate_send_rp_req_pages(MigrationIncomingState *mis, const char *rbn= ame, + ram_addr_t start, size_t len) { uint8_t bufc[12 + 1 + 255]; /* start (8), len (4), rbname up to 256 */ size_t msglen =3D 12; /* start + len */ + enum mig_rp_message_type msg_type; =20 *(uint64_t *)bufc =3D cpu_to_be64((uint64_t)start); *(uint32_t *)(bufc + 8) =3D cpu_to_be32((uint32_t)len); @@ -241,10 +260,12 @@ void migrate_send_rp_req_pages(MigrationIncomingState= *mis, const char *rbname, bufc[msglen++] =3D rbname_len; memcpy(bufc + msglen, rbname, rbname_len); msglen +=3D rbname_len; - migrate_send_rp_message(mis, MIG_RP_MSG_REQ_PAGES_ID, msglen, bufc= ); + msg_type =3D MIG_RP_MSG_REQ_PAGES_ID; } else { - migrate_send_rp_message(mis, MIG_RP_MSG_REQ_PAGES, msglen, bufc); + msg_type =3D MIG_RP_MSG_REQ_PAGES; } + + return migrate_send_rp_message(mis, msg_type, msglen, bufc); } =20 void qemu_start_incoming_migration(const char *uri, Error **errp) diff --git a/migration/migration.h b/migration/migration.h index 75c72d3c8f..f515b8994f 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -230,7 +230,7 @@ void migrate_send_rp_shut(MigrationIncomingState *mis, uint32_t value); void migrate_send_rp_pong(MigrationIncomingState *mis, uint32_t value); -void migrate_send_rp_req_pages(MigrationIncomingState *mis, const char* rb= name, +int migrate_send_rp_req_pages(MigrationIncomingState *mis, const char* rbn= ame, ram_addr_t start, size_t len); =20 #endif --=20 2.14.3 From nobody Fri Oct 24 21:59:45 2025 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 1518623119867971.4057270804323; Wed, 14 Feb 2018 07:45:19 -0800 (PST) Received: from localhost ([::1]:33310 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzFG-0005R8-TB for importer@patchew.org; Wed, 14 Feb 2018 10:45:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elzA7-0008Nh-Ql for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:40:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elzA5-00079h-F6 for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:59 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40586 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 1elzA5-000795-2E for qemu-devel@nongnu.org; Wed, 14 Feb 2018 10:39:57 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 98B9F406AE1D; Wed, 14 Feb 2018 15:39:56 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-116-251.ams2.redhat.com [10.36.116.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4E42F41A2; Wed, 14 Feb 2018 15:39:55 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com, groug@kaod.org, ross.lagerwall@citrix.com Date: Wed, 14 Feb 2018 15:39:38 +0000 Message-Id: <20180214153938.5410-11-dgilbert@redhat.com> In-Reply-To: <20180214153938.5410-1-dgilbert@redhat.com> References: <20180214153938.5410-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 14 Feb 2018 15:39:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 14 Feb 2018 15:39:56 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL 10/10] migration: pass MigrationState to migrate_init() 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: Peter Xu Let the callers take the object, then pass it to migrate_init(). Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20180208103132.28452-12-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/migration.c | 7 ++----- migration/migration.h | 2 +- migration/savevm.c | 5 ++++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 913f658c3e..0aa596f867 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1258,10 +1258,8 @@ bool migration_is_idle(void) return false; } =20 -MigrationState *migrate_init(void) +void migrate_init(MigrationState *s) { - MigrationState *s =3D migrate_get_current(); - /* * Reinitialise all migration state, except * parameters/capabilities that the user set, and @@ -1291,7 +1289,6 @@ MigrationState *migrate_init(void) s->vm_was_running =3D false; s->iteration_initial_bytes =3D 0; s->threshold_size =3D 0; - return s; } =20 static GSList *migration_blockers; @@ -1399,7 +1396,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool = blk, migrate_set_block_incremental(s, true); } =20 - s =3D migrate_init(); + migrate_init(s); =20 if (strstart(uri, "tcp:", &p)) { tcp_start_outgoing_migration(s, p, &local_err); diff --git a/migration/migration.h b/migration/migration.h index f515b8994f..82cf926b17 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -193,7 +193,7 @@ void migrate_fd_error(MigrationState *s, const Error *e= rror); =20 void migrate_fd_connect(MigrationState *s, Error *error_in); =20 -MigrationState *migrate_init(void); +void migrate_init(MigrationState *s); bool migration_is_blocked(Error **errp); /* True if outgoing migration has entered postcopy phase */ bool migration_in_postcopy(void); diff --git a/migration/savevm.c b/migration/savevm.c index 967c3bca0d..8e6d872452 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1257,8 +1257,11 @@ void qemu_savevm_state_cleanup(void) static int qemu_savevm_state(QEMUFile *f, Error **errp) { int ret; - MigrationState *ms =3D migrate_init(); + MigrationState *ms =3D migrate_get_current(); MigrationStatus status; + + migrate_init(ms); + ms->to_dst_file =3D f; =20 if (migration_is_blocked(errp)) { --=20 2.14.3