From nobody Tue Oct 28 12:14:10 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151518978937823.396835507027845; Fri, 5 Jan 2018 14:03:09 -0800 (PST) Received: from localhost ([::1]:60664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXa4y-00023X-K7 for importer@patchew.org; Fri, 05 Jan 2018 17:03:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXZvP-0002XE-1I for qemu-devel@nongnu.org; Fri, 05 Jan 2018 16:53:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eXZvN-0003Sc-QL for qemu-devel@nongnu.org; Fri, 05 Jan 2018 16:53:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36014) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eXZvN-0003Rd-90 for qemu-devel@nongnu.org; Fri, 05 Jan 2018 16:53:13 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5594A83F46 for ; Fri, 5 Jan 2018 21:53:12 +0000 (UTC) Received: from secure.mitica (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD8A0601B3; Fri, 5 Jan 2018 21:53:10 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 5 Jan 2018 22:52:45 +0100 Message-Id: <20180105215246.908-11-quintela@redhat.com> In-Reply-To: <20180105215246.908-1-quintela@redhat.com> References: <20180105215246.908-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 05 Jan 2018 21:53:12 +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 v4 10/11] tests: Adjust sleeps for migration test 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_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Also reorder code to not sleep when event already happened. Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- tests/migration-test.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index 70b3c0870b..8914829006 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -280,10 +280,9 @@ static void read_blocktime(QTestState *who) =20 static void wait_for_migration_complete(QTestState *who) { - QDict *rsp, *rsp_return; - bool completed; - - do { + while (true) { + QDict *rsp, *rsp_return; + bool completed; const char *status; =20 rsp =3D wait_command(who, "{ 'execute': 'query-migrate' }"); @@ -292,8 +291,11 @@ static void wait_for_migration_complete(QTestState *wh= o) completed =3D strcmp(status, "completed") =3D=3D 0; g_assert_cmpstr(status, !=3D, "failed"); QDECREF(rsp); - usleep(1000 * 100); - } while (!completed); + if (completed) { + return; + } + usleep(1000); + } } =20 static void wait_for_migration_pass(QTestState *who) @@ -302,16 +304,13 @@ static void wait_for_migration_pass(QTestState *who) uint64_t pass; =20 /* Wait for the 1st sync */ - do { + while (!got_stop && !initial_pass) { + usleep(1000); initial_pass =3D get_migration_pass(who); - if (got_stop || initial_pass) { - break; - } - usleep(1000 * 100); - } while (true); + } =20 do { - usleep(1000 * 100); + usleep(1000); pass =3D get_migration_pass(who); } while (pass =3D=3D initial_pass && !got_stop); } @@ -510,13 +509,13 @@ static void test_migrate_end(QTestState *from, QTestS= tate *to) /* Destination still running, wait for a byte to change */ do { qtest_memread(to, start_address, &dest_byte_b, 1); - usleep(10 * 1000); + usleep(1000 * 10); } while (dest_byte_a =3D=3D dest_byte_b); =20 qtest_qmp_discard_response(to, "{ 'execute' : 'stop'}"); /* With it stopped, check nothing changes */ qtest_memread(to, start_address, &dest_byte_c, 1); - sleep(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 --=20 2.14.3