From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com,
groug@kaod.org, ross.lagerwall@citrix.com
Subject: [Qemu-devel] [PULL 05/10] tests/migration: Add test for migration to bad destination
Date: Wed, 14 Feb 2018 15:39:33 +0000 [thread overview]
Message-ID: <20180214153938.5410-6-dgilbert@redhat.com> (raw)
In-Reply-To: <20180214153938.5410-1-dgilbert@redhat.com>
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Check the source survives.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20180212160340.15333-3-dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
---
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, QTestState **to,
g_free(cmd_dst);
}
-static void test_migrate_end(QTestState *from, QTestState *to)
+static void test_migrate_end(QTestState *from, QTestState *to, bool test_dest)
{
unsigned char dest_byte_a, dest_byte_b, dest_byte_c, dest_byte_d;
qtest_quit(from);
- qtest_memread(to, start_address, &dest_byte_a, 1);
+ if (test_dest) {
+ qtest_memread(to, start_address, &dest_byte_a, 1);
- /* 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 == 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 == dest_byte_b);
+
+ qtest_qmp_discard_response(to, "{ 'execute' : 'stop'}");
- 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, ==, 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, ==, dest_byte_d);
- check_guests_ram(to);
+ check_guests_ram(to);
+ }
qtest_quit(to);
@@ -547,7 +550,38 @@ static void test_migrate(void)
g_free(uri);
- 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 = wait_command(from, "{ 'execute': 'query-migrate' }");
+ rsp_return = qdict_get_qdict(rsp, "return");
+
+ status = qdict_get_str(rsp_return, "status");
+
+ g_assert(!strcmp(status, "setup") || !(strcmp(status, "failed")));
+ failed = !strcmp(status, "failed");
+ QDECREF(rsp);
+ } while (!failed);
+
+ /* Is the machine currently running? */
+ rsp = wait_command(from, "{ 'execute': 'query-status' }");
+ g_assert(qdict_haskey(rsp, "return"));
+ rsp_return = 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);
}
int main(int argc, char **argv)
@@ -571,6 +605,7 @@ int main(int argc, char **argv)
qtest_add_func("/migration/postcopy/unix", test_migrate);
qtest_add_func("/migration/deprecated", test_deprecated);
+ qtest_add_func("/migration/bad_dest", test_baddest);
ret = g_test_run();
--
2.14.3
next prev parent reply other threads:[~2018-02-14 15:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-14 15:39 [Qemu-devel] [PULL 00/10] migration queue Dr. David Alan Gilbert (git)
2018-02-14 15:39 ` [Qemu-devel] [PULL 01/10] migration/xen: Check return value of qemu_fclose Dr. David Alan Gilbert (git)
2018-02-14 15:39 ` [Qemu-devel] [PULL 02/10] migration: improve documentation of postcopy-ram Dr. David Alan Gilbert (git)
2018-02-14 15:39 ` [Qemu-devel] [PULL 03/10] tests/migration: Add source to PC boot block Dr. David Alan Gilbert (git)
2018-02-14 15:39 ` [Qemu-devel] [PULL 04/10] migration: Fix early failure cleanup Dr. David Alan Gilbert (git)
2018-02-14 15:39 ` Dr. David Alan Gilbert (git) [this message]
2018-02-14 15:39 ` [Qemu-devel] [PULL 06/10] migration: better error handling with QEMUFile Dr. David Alan Gilbert (git)
2018-02-14 15:39 ` [Qemu-devel] [PULL 07/10] migration: reuse mis->userfault_quit_fd Dr. David Alan Gilbert (git)
2018-02-14 15:39 ` [Qemu-devel] [PULL 08/10] migration: provide postcopy_fault_thread_notify() Dr. David Alan Gilbert (git)
2018-02-14 15:39 ` [Qemu-devel] [PULL 09/10] migration: allow send_rq to fail Dr. David Alan Gilbert (git)
2018-02-14 15:39 ` [Qemu-devel] [PULL 10/10] migration: pass MigrationState to migrate_init() Dr. David Alan Gilbert (git)
2018-02-15 15:45 ` [Qemu-devel] [PULL 00/10] migration queue Peter Maydell
2018-02-15 20:19 ` Dr. David Alan Gilbert
2018-02-16 6:14 ` Thomas Huth
2018-02-16 14:25 ` Peter Maydell
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=20180214153938.5410-6-dgilbert@redhat.com \
--to=dgilbert@redhat.com \
--cc=groug@kaod.org \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=ross.lagerwall@citrix.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).