[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 6/6] tests: Add migration dirtylimit capability test
From: |
huangy81 |
Subject: |
[RFC 6/6] tests: Add migration dirtylimit capability test |
Date: |
Tue, 17 May 2022 14:35:06 +0800 |
From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
Add migration dirtylimit capability test if kernel support
dirty ring.
Migration dirtylimit capability introduce dirtylimit capability
, two parameters: vcpu-dirtylimit-period and vcpu-dirtylimit to
implement the live migration with dirtylimit.
The test case enable the capability and set the corresponding
parameters to test migration. When migration switch to
pre-switchover phase, like the auto-converge, checking if
migration satisfy the convergence condition.
Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
---
tests/qtest/migration-test.c | 89 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index 40f2873..b0a53d7 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -1650,6 +1650,93 @@ static void test_vcpu_dirty_limit(void)
dirtylimit_stop_vm(vm);
}
+static void test_migrate_dirty_limit(void)
+{
+ g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
+ MigrateStart *args = migrate_start_new();
+ QTestState *from, *to;
+ int64_t remaining, throttle_us_per_full;
+ /*
+ * We want the test to be stable and as fast as possible.
+ * E.g., with 1Gb/s bandwith migration may pass without dirtylimit,
+ * so we need to decrease a bandwidth.
+ */
+ const int64_t dirtylimit_period = 1000, dirtylimit_value = 50;
+ const int64_t max_bandwidth = 400000000; /* ~400Mb/s */
+ const int64_t downtime_limit = 250; /* 250ms */
+ /*
+ * We migrate through unix-socket (> 500Mb/s).
+ * Thus, expected migration speed ~= bandwidth limit (< 500Mb/s).
+ * So, we can predict expected_threshold
+ */
+ const int64_t expected_threshold = max_bandwidth * downtime_limit / 1000;
+
+ /* Enable dirty ring logging */
+ args->use_dirty_ring = true;
+
+ if (test_migrate_start(&from, &to, uri, &args)) {
+ return;
+ }
+
+ migrate_set_capability(from, "dirtylimit", true);
+ migrate_set_parameter_int(from, "vcpu-dirtylimit-period",
+ dirtylimit_period);
+ migrate_set_parameter_int(from, "vcpu-dirtylimit", dirtylimit_value);
+
+ /*
+ * Set the initial parameters so that the migration could not converge
+ * without dirtylimit.
+ */
+ migrate_set_parameter_int(from, "downtime-limit", 1);
+ migrate_set_parameter_int(from, "max-bandwidth", 100000000); /* ~100Mb/s */
+
+ /* To check limit rate after precopy */
+ migrate_set_capability(from, "pause-before-switchover", true);
+
+ /* Wait for the first serial output from the source */
+ wait_for_serial("src_serial");
+
+ migrate_qmp(from, uri, "{}");
+
+ /* Wait for dirtylimit begins */
+ throttle_us_per_full = 0;
+ while (throttle_us_per_full == 0) {
+ throttle_us_per_full =
+ read_migrate_property_int(from, "dirtylimit-throttle-us-per-full");
+ usleep(100);
+ g_assert_false(got_stop);
+ }
+
+ /*
+ * The dirtylimit rate should equals the return value of
+ * query-vcpu-dirty-limit if dirtylimit cap set
+ */
+ g_assert_cmpint(dirtylimit_value, ==, get_limit_rate(from));
+
+ /* Now, when we tested if dirtylimit works, let it converge */
+ migrate_set_parameter_int(from, "downtime-limit", downtime_limit);
+ migrate_set_parameter_int(from, "max-bandwidth", max_bandwidth);
+
+ /*
+ * Wait for pre-switchover status to check if migration
+ * satisfy the convergence condition
+ */
+ wait_for_migration_status(from, "pre-switchover", NULL);
+
+ remaining = read_ram_property_int(from, "remaining");
+ g_assert_cmpint(remaining, <,
+ (expected_threshold + expected_threshold / 100));
+
+ migrate_continue(from, "pre-switchover");
+
+ qtest_qmp_eventwait(to, "RESUME");
+
+ wait_for_serial("dest_serial");
+ wait_for_migration_complete(from);
+
+ test_migrate_end(from, to, true);
+}
+
static bool kvm_dirty_ring_supported(void)
{
#if defined(__linux__) && defined(HOST_X86_64)
@@ -1741,6 +1828,8 @@ int main(int argc, char **argv)
test_precopy_unix_dirty_ring);
qtest_add_func("/migration/vcpu_dirty_limit",
test_vcpu_dirty_limit);
+ qtest_add_func("/migration/dirty_limit",
+ test_migrate_dirty_limit);
}
ret = g_test_run();
--
1.8.3.1
- [RFC 0/6] migration: introduce dirtylimit capability, huangy81, 2022/05/17
- [RFC 4/6] migration: Introduce dirtylimit capability, huangy81, 2022/05/17
- [RFC 2/6] qapi/migration: Introduce vcpu-dirtylimit parameters, huangy81, 2022/05/17
- [RFC 1/6] qapi/migration: Introduce vcpu-dirtylimit-period parameters, huangy81, 2022/05/17
- [RFC 5/6] migration: Add dirtylimit data into migration info, huangy81, 2022/05/17
- [RFC 6/6] tests: Add migration dirtylimit capability test,
huangy81 <=
- [RFC 3/6] migration: Implement dirtylimit convergence algo, huangy81, 2022/05/17