From nobody Sun Nov 2 16:37:23 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509004496671751.8652577705741; Thu, 26 Oct 2017 00:54:56 -0700 (PDT) Received: from localhost ([::1]:51478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7czy-0005pG-CY for importer@patchew.org; Thu, 26 Oct 2017 03:54:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7cxw-0004fX-61 for qemu-devel@nongnu.org; Thu, 26 Oct 2017 03:52:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7cxv-00080q-3y for qemu-devel@nongnu.org; Thu, 26 Oct 2017 03:52:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45456) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e7cxu-0007zO-Rm for qemu-devel@nongnu.org; Thu, 26 Oct 2017 03:52:35 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E16EB7C82B for ; Thu, 26 Oct 2017 07:52:33 +0000 (UTC) Received: from secure.mitica (ovpn-116-124.ams2.redhat.com [10.36.116.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 860035DD6D; Thu, 26 Oct 2017 07:52:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E16EB7C82B Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 26 Oct 2017 09:52:16 +0200 Message-Id: <20171026075222.27798-5-quintela@redhat.com> In-Reply-To: <20171026075222.27798-1-quintela@redhat.com> References: <20171026075222.27798-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 26 Oct 2017 07:52:34 +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 v2 04/10] tests: Don't abuse global_qtest 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: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As we have two guests running, just pass always who we want to send a message to. Once there, refactor return_or_event() into wait_command. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- tests/migration-test.c | 55 +++++++++++++++++++++++++---------------------= ---- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index 91fb0277d6..c429a13403 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -223,20 +223,23 @@ static void wait_for_serial(const char *side) /* * Events can get in the way of responses we are actually waiting for. */ -static QDict *return_or_event(QDict *response) +static QDict *wait_command(QTestState *who, const char *command) { const char *event_string; - if (!qdict_haskey(response, "event")) { - return response; - } + QDict *response; + + response =3D qtest_qmp(who, command); =20 - /* OK, it was an event */ - event_string =3D qdict_get_str(response, "event"); - if (!strcmp(event_string, "STOP")) { - got_stop =3D true; + while (qdict_haskey(response, "event")) { + /* OK, it was an event */ + event_string =3D qdict_get_str(response, "event"); + if (!strcmp(event_string, "STOP")) { + got_stop =3D true; + } + QDECREF(response); + response =3D qtest_qmp_receive(who); } - QDECREF(response); - return return_or_event(qtest_qmp_receive(global_qtest)); + return response; } =20 =20 @@ -245,12 +248,12 @@ static QDict *return_or_event(QDict *response) * events suddenly appearing confuse the qmp()/hmp() responses. */ =20 -static uint64_t get_migration_pass(void) +static uint64_t get_migration_pass(QTestState *who) { QDict *rsp, *rsp_return, *rsp_ram; uint64_t result; =20 - rsp =3D return_or_event(qmp("{ 'execute': 'query-migrate' }")); + rsp =3D wait_command(who, "{ 'execute': 'query-migrate' }"); rsp_return =3D qdict_get_qdict(rsp, "return"); if (!qdict_haskey(rsp_return, "ram")) { /* Still in setup */ @@ -263,7 +266,7 @@ static uint64_t get_migration_pass(void) return result; } =20 -static void wait_for_migration_complete(void) +static void wait_for_migration_complete(QTestState *who) { QDict *rsp, *rsp_return; bool completed; @@ -271,7 +274,7 @@ static void wait_for_migration_complete(void) do { const char *status; =20 - rsp =3D return_or_event(qmp("{ 'execute': 'query-migrate' }")); + rsp =3D wait_command(who, "{ 'execute': 'query-migrate' }"); rsp_return =3D qdict_get_qdict(rsp, "return"); status =3D qdict_get_str(rsp_return, "status"); completed =3D strcmp(status, "completed") =3D=3D 0; @@ -281,14 +284,14 @@ static void wait_for_migration_complete(void) } while (!completed); } =20 -static void wait_for_migration_pass(void) +static void wait_for_migration_pass(QTestState *who) { - uint64_t initial_pass =3D get_migration_pass(); + uint64_t initial_pass =3D get_migration_pass(who); uint64_t pass; =20 /* Wait for the 1st sync */ do { - initial_pass =3D get_migration_pass(); + initial_pass =3D get_migration_pass(who); if (got_stop || initial_pass) { break; } @@ -297,7 +300,7 @@ static void wait_for_migration_pass(void) =20 do { usleep(1000 * 100); - pass =3D get_migration_pass(); + pass =3D get_migration_pass(who); } while (pass =3D=3D initial_pass && !got_stop); } =20 @@ -493,7 +496,7 @@ static void test_migrate_end(QTestState *from, QTestSta= te *to) static void test_migrate(void) { char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); - QTestState *global =3D global_qtest, *from, *to; + QTestState *from, *to; QDict *rsp; =20 test_migrate_start(&from, &to, uri); @@ -513,26 +516,22 @@ static void test_migrate(void) =20 migrate(from, uri); =20 - global_qtest =3D from; - wait_for_migration_pass(); + wait_for_migration_pass(from); =20 - rsp =3D return_or_event(qmp("{ 'execute': 'migrate-start-postcopy' }")= ); + rsp =3D wait_command(from, "{ 'execute': 'migrate-start-postcopy' }"); g_assert(qdict_haskey(rsp, "return")); QDECREF(rsp); =20 if (!got_stop) { - qmp_eventwait("STOP"); + qtest_qmp_eventwait(from, "STOP"); } =20 - global_qtest =3D to; - qmp_eventwait("RESUME"); + qtest_qmp_eventwait(to, "RESUME"); =20 wait_for_serial("dest_serial"); - global_qtest =3D from; - wait_for_migration_complete(); + wait_for_migration_complete(from); =20 g_free(uri); - global_qtest =3D global; =20 test_migrate_end(from, to); } --=20 2.13.6