aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-02-07 12:07:23 +0000
committerPeter Maydell <peter.maydell@linaro.org>2018-02-07 12:07:23 +0000
commit0833df03f4206a6cf416fbb3d380fa95c8e61fba (patch)
tree274b48f390f2c81d6d4bf6bf6aabcc68647eb583 /tests
parentbc2943d6caf787e1c9a5f3109cdb98f37630b89e (diff)
parent875fcd013ab68c64802998b22f54f0184479d21b (diff)
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20180206a' into staging
Migration pull 2018-02-06 This is based off Juan's last pull with a few extras, but also removing: Add migration xbzrle test Add migration precopy test As well as my normal test boxes, I also gave it a test on a 32 bit ARM box and it seems happy (a Calxeda highbank) and a big-endian power box. Dave # gpg: Signature made Tue 06 Feb 2018 15:33:31 GMT # gpg: using RSA key 0516331EBC5BFDE7 # gpg: Good signature from "Dr. David Alan Gilbert (RH2) <dgilbert@redhat.com>" # Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A 9FA9 0516 331E BC5B FDE7 * remotes/dgilbert/tags/pull-migration-20180206a: migration: incoming postcopy advise sanity checks migration: Don't leak IO channels migration: Recover block devices if failure in device state tests: Adjust sleeps for migration test tests: Create migrate-start-postcopy command tests: Add deprecated commands migration test tests: Use consistent names for migration tests: Consolidate accelerators declaration tests: Remove deprecated migration tests commands migration: Drop current address parameter from save_zero_page() migration: use s->threshold_size inside migration_update_counters migration/savevm.c: set MAX_VM_CMD_PACKAGED_SIZE to 1ul << 32 migration: Route errors down through migration_channel_connect migration: Allow migrate_fd_connect to take an Error * Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/migration-test.c144
1 files changed, 90 insertions, 54 deletions
diff --git a/tests/migration-test.c b/tests/migration-test.c
index 799e24ebc6..9efad95749 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -268,10 +268,9 @@ static uint64_t get_migration_pass(QTestState *who)
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;
rsp = wait_command(who, "{ 'execute': 'query-migrate' }");
@@ -280,8 +279,11 @@ static void wait_for_migration_complete(QTestState *who)
completed = strcmp(status, "completed") == 0;
g_assert_cmpstr(status, !=, "failed");
QDECREF(rsp);
- usleep(1000 * 100);
- } while (!completed);
+ if (completed) {
+ return;
+ }
+ usleep(1000);
+ }
}
static void wait_for_migration_pass(QTestState *who)
@@ -290,16 +292,13 @@ static void wait_for_migration_pass(QTestState *who)
uint64_t pass;
/* Wait for the 1st sync */
- do {
+ while (!got_stop && !initial_pass) {
+ usleep(1000);
initial_pass = get_migration_pass(who);
- if (got_stop || initial_pass) {
- break;
- }
- usleep(1000 * 100);
- } while (true);
+ }
do {
- usleep(1000 * 100);
+ usleep(1000);
pass = get_migration_pass(who);
} while (pass == initial_pass && !got_stop);
}
@@ -369,37 +368,20 @@ static void migrate_check_parameter(QTestState *who, const char *parameter,
QDECREF(rsp);
}
-static void migrate_set_downtime(QTestState *who, const double value)
+static void migrate_set_parameter(QTestState *who, const char *parameter,
+ const char *value)
{
QDict *rsp;
gchar *cmd;
- char *expected;
- int64_t result_int;
- cmd = g_strdup_printf("{ 'execute': 'migrate_set_downtime',"
- "'arguments': { 'value': %g } }", value);
+ cmd = g_strdup_printf("{ 'execute': 'migrate-set-parameters',"
+ "'arguments': { '%s': %s } }",
+ parameter, value);
rsp = qtest_qmp(who, cmd);
g_free(cmd);
g_assert(qdict_haskey(rsp, "return"));
QDECREF(rsp);
- result_int = value * 1000L;
- expected = g_strdup_printf("%" PRId64, result_int);
- migrate_check_parameter(who, "downtime-limit", expected);
- g_free(expected);
-}
-
-static void migrate_set_speed(QTestState *who, const char *value)
-{
- QDict *rsp;
- gchar *cmd;
-
- cmd = g_strdup_printf("{ 'execute': 'migrate_set_speed',"
- "'arguments': { 'value': %s } }", value);
- rsp = qtest_qmp(who, cmd);
- g_free(cmd);
- g_assert(qdict_haskey(rsp, "return"));
- QDECREF(rsp);
- migrate_check_parameter(who, "max-bandwidth", value);
+ migrate_check_parameter(who, parameter, value);
}
static void migrate_set_capability(QTestState *who, const char *capability,
@@ -433,41 +415,52 @@ static void migrate(QTestState *who, const char *uri)
QDECREF(rsp);
}
+static void migrate_start_postcopy(QTestState *who)
+{
+ QDict *rsp;
+
+ rsp = wait_command(who, "{ 'execute': 'migrate-start-postcopy' }");
+ g_assert(qdict_haskey(rsp, "return"));
+ QDECREF(rsp);
+}
+
static void test_migrate_start(QTestState **from, QTestState **to,
const char *uri)
{
gchar *cmd_src, *cmd_dst;
char *bootpath = g_strdup_printf("%s/bootsect", tmpfs);
const char *arch = qtest_get_arch();
+ const char *accel = "kvm:tcg";
got_stop = false;
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
init_bootfile_x86(bootpath);
- cmd_src = g_strdup_printf("-machine accel=kvm:tcg -m 150M"
- " -name pcsource,debug-threads=on"
+ cmd_src = g_strdup_printf("-machine accel=%s -m 150M"
+ " -name source,debug-threads=on"
" -serial file:%s/src_serial"
" -drive file=%s,format=raw",
- tmpfs, bootpath);
- cmd_dst = g_strdup_printf("-machine accel=kvm:tcg -m 150M"
- " -name pcdest,debug-threads=on"
+ accel, tmpfs, bootpath);
+ cmd_dst = g_strdup_printf("-machine accel=%s -m 150M"
+ " -name target,debug-threads=on"
" -serial file:%s/dest_serial"
" -drive file=%s,format=raw"
" -incoming %s",
- tmpfs, bootpath, uri);
+ accel, tmpfs, bootpath, uri);
} else if (strcmp(arch, "ppc64") == 0) {
- const char *accel;
/* On ppc64, the test only works with kvm-hv, but not with kvm-pr */
- accel = access("/sys/module/kvm_hv", F_OK) ? "tcg" : "kvm:tcg";
+ if (access("/sys/module/kvm_hv", F_OK)) {
+ accel = "tcg";
+ }
init_bootfile_ppc(bootpath);
cmd_src = g_strdup_printf("-machine accel=%s -m 256M"
- " -name pcsource,debug-threads=on"
+ " -name source,debug-threads=on"
" -serial file:%s/src_serial"
" -drive file=%s,if=pflash,format=raw",
accel, tmpfs, bootpath);
cmd_dst = g_strdup_printf("-machine accel=%s -m 256M"
- " -name pcdest,debug-threads=on"
+ " -name target,debug-threads=on"
" -serial file:%s/dest_serial"
" -incoming %s",
accel, tmpfs, uri);
@@ -495,13 +488,13 @@ static void test_migrate_end(QTestState *from, QTestState *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 == dest_byte_b);
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, ==, dest_byte_d);
@@ -515,11 +508,55 @@ static void test_migrate_end(QTestState *from, QTestState *to)
cleanup("dest_serial");
}
+static void deprecated_set_downtime(QTestState *who, const double value)
+{
+ QDict *rsp;
+ gchar *cmd;
+ char *expected;
+ int64_t result_int;
+
+ cmd = g_strdup_printf("{ 'execute': 'migrate_set_downtime',"
+ "'arguments': { 'value': %g } }", value);
+ rsp = qtest_qmp(who, cmd);
+ g_free(cmd);
+ g_assert(qdict_haskey(rsp, "return"));
+ QDECREF(rsp);
+ result_int = value * 1000L;
+ expected = g_strdup_printf("%" PRId64, result_int);
+ migrate_check_parameter(who, "downtime-limit", expected);
+ g_free(expected);
+}
+
+static void deprecated_set_speed(QTestState *who, const char *value)
+{
+ QDict *rsp;
+ gchar *cmd;
+
+ cmd = g_strdup_printf("{ 'execute': 'migrate_set_speed',"
+ "'arguments': { 'value': %s } }", value);
+ rsp = qtest_qmp(who, cmd);
+ g_free(cmd);
+ g_assert(qdict_haskey(rsp, "return"));
+ QDECREF(rsp);
+ migrate_check_parameter(who, "max-bandwidth", value);
+}
+
+static void test_deprecated(void)
+{
+ QTestState *from;
+
+ from = qtest_start("");
+
+ deprecated_set_downtime(from, 0.12345);
+ deprecated_set_speed(from, "12345");
+
+ qtest_quit(from);
+}
+
static void test_migrate(void)
{
char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
QTestState *from, *to;
- QDict *rsp;
test_migrate_start(&from, &to, uri);
@@ -530,8 +567,8 @@ static void test_migrate(void)
* quickly, but that it doesn't complete precopy even on a slow
* machine, so also set the downtime.
*/
- migrate_set_speed(from, "100000000");
- migrate_set_downtime(from, 0.001);
+ migrate_set_parameter(from, "max-bandwidth", "100000000");
+ migrate_set_parameter(from, "downtime-limit", "1");
/* Wait for the first serial output from the source */
wait_for_serial("src_serial");
@@ -540,9 +577,7 @@ static void test_migrate(void)
wait_for_migration_pass(from);
- rsp = wait_command(from, "{ 'execute': 'migrate-start-postcopy' }");
- g_assert(qdict_haskey(rsp, "return"));
- QDECREF(rsp);
+ migrate_start_postcopy(from);
if (!got_stop) {
qtest_qmp_eventwait(from, "STOP");
@@ -578,6 +613,7 @@ int main(int argc, char **argv)
module_call_init(MODULE_INIT_QOM);
qtest_add_func("/migration/postcopy/unix", test_migrate);
+ qtest_add_func("/migration/deprecated", test_deprecated);
ret = g_test_run();