From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org, lvivier@redhat.com, peterx@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 04/10] tests: Don't abuse global_qtest
Date: Fri, 27 Oct 2017 03:37:08 +0100 [thread overview]
Message-ID: <20171027023706.GD2585@work-vm> (raw)
In-Reply-To: <20171026075222.27798-5-quintela@redhat.com>
* Juan Quintela (quintela@redhat.com) wrote:
> 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 <quintela@redhat.com>
Hmm was there anything else anywhere that relied on global_qtest?
Hopefully not.
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
> 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 = qtest_qmp(who, command);
>
> - /* OK, it was an event */
> - event_string = qdict_get_str(response, "event");
> - if (!strcmp(event_string, "STOP")) {
> - got_stop = true;
> + while (qdict_haskey(response, "event")) {
> + /* OK, it was an event */
> + event_string = qdict_get_str(response, "event");
> + if (!strcmp(event_string, "STOP")) {
> + got_stop = true;
> + }
> + QDECREF(response);
> + response = qtest_qmp_receive(who);
> }
> - QDECREF(response);
> - return return_or_event(qtest_qmp_receive(global_qtest));
> + return response;
> }
>
>
> @@ -245,12 +248,12 @@ static QDict *return_or_event(QDict *response)
> * events suddenly appearing confuse the qmp()/hmp() responses.
> */
>
> -static uint64_t get_migration_pass(void)
> +static uint64_t get_migration_pass(QTestState *who)
> {
> QDict *rsp, *rsp_return, *rsp_ram;
> uint64_t result;
>
> - rsp = return_or_event(qmp("{ 'execute': 'query-migrate' }"));
> + rsp = wait_command(who, "{ 'execute': 'query-migrate' }");
> rsp_return = 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;
> }
>
> -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;
>
> - rsp = return_or_event(qmp("{ 'execute': 'query-migrate' }"));
> + rsp = wait_command(who, "{ 'execute': 'query-migrate' }");
> rsp_return = qdict_get_qdict(rsp, "return");
> status = qdict_get_str(rsp_return, "status");
> completed = strcmp(status, "completed") == 0;
> @@ -281,14 +284,14 @@ static void wait_for_migration_complete(void)
> } while (!completed);
> }
>
> -static void wait_for_migration_pass(void)
> +static void wait_for_migration_pass(QTestState *who)
> {
> - uint64_t initial_pass = get_migration_pass();
> + uint64_t initial_pass = get_migration_pass(who);
> uint64_t pass;
>
> /* Wait for the 1st sync */
> do {
> - initial_pass = get_migration_pass();
> + initial_pass = get_migration_pass(who);
> if (got_stop || initial_pass) {
> break;
> }
> @@ -297,7 +300,7 @@ static void wait_for_migration_pass(void)
>
> do {
> usleep(1000 * 100);
> - pass = get_migration_pass();
> + pass = get_migration_pass(who);
> } while (pass == initial_pass && !got_stop);
> }
>
> @@ -493,7 +496,7 @@ static void test_migrate_end(QTestState *from, QTestState *to)
> static void test_migrate(void)
> {
> char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
> - QTestState *global = global_qtest, *from, *to;
> + QTestState *from, *to;
> QDict *rsp;
>
> test_migrate_start(&from, &to, uri);
> @@ -513,26 +516,22 @@ static void test_migrate(void)
>
> migrate(from, uri);
>
> - global_qtest = from;
> - wait_for_migration_pass();
> + wait_for_migration_pass(from);
>
> - rsp = return_or_event(qmp("{ 'execute': 'migrate-start-postcopy' }"));
> + rsp = wait_command(from, "{ 'execute': 'migrate-start-postcopy' }");
> g_assert(qdict_haskey(rsp, "return"));
> QDECREF(rsp);
>
> if (!got_stop) {
> - qmp_eventwait("STOP");
> + qtest_qmp_eventwait(from, "STOP");
> }
>
> - global_qtest = to;
> - qmp_eventwait("RESUME");
> + qtest_qmp_eventwait(to, "RESUME");
>
> wait_for_serial("dest_serial");
> - global_qtest = from;
> - wait_for_migration_complete();
> + wait_for_migration_complete(from);
>
> g_free(uri);
> - global_qtest = global;
>
> test_migrate_end(from, to);
> }
> --
> 2.13.6
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2017-10-27 2:37 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-26 7:52 [Qemu-devel] [PATCH v2 00/10] Add make check tests for Migration Juan Quintela
2017-10-26 7:52 ` [Qemu-devel] [PATCH v2 01/10] tests: rename postcopy-test to migration-test Juan Quintela
2017-10-27 1:50 ` Dr. David Alan Gilbert
2017-10-26 7:52 ` [Qemu-devel] [PATCH v2 02/10] tests: Refactor setting of parameters/capabilities Juan Quintela
2017-10-27 1:54 ` Dr. David Alan Gilbert
2017-10-26 7:52 ` [Qemu-devel] [PATCH v2 03/10] tests: Factorize out migrate_test_start/end Juan Quintela
2017-10-27 2:15 ` Dr. David Alan Gilbert
2017-10-26 7:52 ` [Qemu-devel] [PATCH v2 04/10] tests: Don't abuse global_qtest Juan Quintela
2017-10-27 2:37 ` Dr. David Alan Gilbert [this message]
2017-10-29 8:29 ` Juan Quintela
2017-10-26 7:52 ` [Qemu-devel] [PATCH v2 05/10] tests: check that migration parameters are really assigned Juan Quintela
2017-10-27 3:47 ` Dr. David Alan Gilbert
2017-10-29 8:30 ` Juan Quintela
2017-10-29 13:24 ` Peter Xu
2017-10-30 13:28 ` Juan Quintela
2017-10-26 7:52 ` [Qemu-devel] [PATCH v2 06/10] tests: Add migration precopy test Juan Quintela
2017-10-29 13:56 ` Peter Xu
2017-10-26 7:52 ` [Qemu-devel] [PATCH v2 07/10] tests: Add basic migration precopy tcp test Juan Quintela
2017-10-26 7:52 ` [Qemu-devel] [PATCH v2 08/10] tests: Add precopy test using deprecated commands Juan Quintela
2017-10-29 13:40 ` Peter Xu
2017-10-26 7:52 ` [Qemu-devel] [PATCH v2 09/10] tests: Add migration xbzrle test Juan Quintela
2017-10-26 7:52 ` [Qemu-devel] [PATCH v2 10/10] [RFH] tests: Add migration compress threads tests Juan Quintela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171027023706.GD2585@work-vm \
--to=dgilbert@redhat.com \
--cc=lvivier@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).