From nobody Mon Apr 29 14:56:23 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 1518452407428573.6423462507051; Mon, 12 Feb 2018 08:20:07 -0800 (PST) Received: from localhost ([::1]:48041 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elGpq-0005BW-Jj for importer@patchew.org; Mon, 12 Feb 2018 11:20:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elGa1-0008AL-RB for qemu-devel@nongnu.org; Mon, 12 Feb 2018 11:03:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elGZz-0001WT-Ld for qemu-devel@nongnu.org; Mon, 12 Feb 2018 11:03:45 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33474 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 1elGZz-0001Vs-IG for qemu-devel@nongnu.org; Mon, 12 Feb 2018 11:03:43 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2DDB94084FE8 for ; Mon, 12 Feb 2018 16:03:43 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-179.ams2.redhat.com [10.36.117.179]) by smtp.corp.redhat.com (Postfix) with ESMTP id 838682166BAE; Mon, 12 Feb 2018 16:03:42 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com Date: Mon, 12 Feb 2018 16:03:39 +0000 Message-Id: <20180212160340.15333-2-dgilbert@redhat.com> In-Reply-To: <20180212160340.15333-1-dgilbert@redhat.com> References: <20180212160340.15333-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 12 Feb 2018 16:03:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 12 Feb 2018 16:03:43 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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 1/2] 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: , Cc: peterx@redhat.com 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 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 Mon Apr 29 14:56:23 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 1518453613378220.78037243391475; Mon, 12 Feb 2018 08:40:13 -0800 (PST) Received: from localhost ([::1]:50350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elH9G-0006kT-UA for importer@patchew.org; Mon, 12 Feb 2018 11:40:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elGa1-0008AO-S9 for qemu-devel@nongnu.org; Mon, 12 Feb 2018 11:03:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elGa0-0001XT-JW for qemu-devel@nongnu.org; Mon, 12 Feb 2018 11:03:45 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58838 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 1elGa0-0001X3-F0 for qemu-devel@nongnu.org; Mon, 12 Feb 2018 11:03:44 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 12B367CBDB for ; Mon, 12 Feb 2018 16:03:44 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-179.ams2.redhat.com [10.36.117.179]) by smtp.corp.redhat.com (Postfix) with ESMTP id 688692166BAE; Mon, 12 Feb 2018 16:03:43 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com Date: Mon, 12 Feb 2018 16:03:40 +0000 Message-Id: <20180212160340.15333-3-dgilbert@redhat.com> In-Reply-To: <20180212160340.15333-1-dgilbert@redhat.com> References: <20180212160340.15333-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 12 Feb 2018 16:03:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 12 Feb 2018 16:03:44 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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 2/2] 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: , Cc: peterx@redhat.com 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 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 d0abad40f5..c1ebbdf08f 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -478,28 +478,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 @@ -591,7 +594,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) @@ -615,6 +649,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