aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-07-15 15:19:54 +0100
committerPeter Maydell <peter.maydell@linaro.org>2019-07-15 15:19:54 +0100
commita68725f930a0d186fe3f8941941e2047e03589d4 (patch)
treead73c6f9fde9efe06d2d9817de8726733ca3709a /tests
parent0dc6284710afa2342fbe3932f4a73c41204da8e9 (diff)
parent40c4d4a835453452a262f32450a0449886aa19ce (diff)
downloadqemu-a68725f930a0d186fe3f8941941e2047e03589d4.zip
qemu-a68725f930a0d186fe3f8941941e2047e03589d4.tar.gz
qemu-a68725f930a0d186fe3f8941941e2047e03589d4.tar.bz2
Merge remote-tracking branch 'remotes/juanquintela/tags/migration-pull-request' into staging
Pull request # gpg: Signature made Mon 15 Jul 2019 14:49:41 BST # gpg: using RSA key 1899FF8EDEBF58CCEE034B82F487EF185872D723 # gpg: Good signature from "Juan Quintela <quintela@redhat.com>" [full] # gpg: aka "Juan Quintela <quintela@trasno.org>" [full] # Primary key fingerprint: 1899 FF8E DEBF 58CC EE03 4B82 F487 EF18 5872 D723 * remotes/juanquintela/tags/migration-pull-request: (21 commits) migration: always initial RAMBlock.bmap to 1 for new migration migration/postcopy: remove redundant cpu_synchronize_all_post_init migration/postcopy: fix document of postcopy_send_discard_bm_ram() migration: allow private destination ram with x-ignore-shared migration: Split log_clear() into smaller chunks kvm: Support KVM_CLEAR_DIRTY_LOG kvm: Introduce slots lock for memory listener kvm: Persistent per kvmslot dirty bitmap kvm: Update comments for sync_dirty_bitmap memory: Introduce memory listener hook log_clear() memory: Pass mr into snapshot_and_clear_dirty bitmap: Add bitmap_copy_with_{src|dst}_offset() memory: Don't set migration bitmap when without migration migration: No need to take rcu during sync_dirty_bitmap migration/ram.c: reset complete_round when we gets a queued page migration/multifd: sync packet_num after all thread are done cutils: remove one unnecessary pointer operation migration/xbzrle: update cache and current_data in one place migration/multifd: call multifd_send_sync_main when sending RAM_SAVE_FLAG_EOS migration-test: rename parameter to parameter_int ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.include2
-rw-r--r--tests/migration-test.c55
-rw-r--r--tests/test-bitmap.c72
3 files changed, 102 insertions, 27 deletions
diff --git a/tests/Makefile.include b/tests/Makefile.include
index a983dd3..fd7fdb8 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -65,6 +65,7 @@ check-unit-y += tests/test-opts-visitor$(EXESUF)
check-unit-$(CONFIG_BLOCK) += tests/test-coroutine$(EXESUF)
check-unit-y += tests/test-visitor-serialization$(EXESUF)
check-unit-y += tests/test-iov$(EXESUF)
+check-unit-y += tests/test-bitmap$(EXESUF)
check-unit-$(CONFIG_BLOCK) += tests/test-aio$(EXESUF)
check-unit-$(CONFIG_BLOCK) += tests/test-aio-multithread$(EXESUF)
check-unit-$(CONFIG_BLOCK) += tests/test-throttle$(EXESUF)
@@ -538,6 +539,7 @@ tests/test-image-locking$(EXESUF): tests/test-image-locking.o $(test-block-obj-y
tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y)
tests/test-iov$(EXESUF): tests/test-iov.o $(test-util-obj-y)
tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o $(test-util-obj-y) $(test-crypto-obj-y)
+tests/test-bitmap$(EXESUF): tests/test-bitmap.o $(test-util-obj-y)
tests/test-x86-cpuid$(EXESUF): tests/test-x86-cpuid.o
tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-util-obj-y)
tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o $(test-util-obj-y)
diff --git a/tests/migration-test.c b/tests/migration-test.c
index b643462..a4feb95 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -398,7 +398,8 @@ static char *migrate_get_socket_address(QTestState *who, const char *parameter)
return result;
}
-static long long migrate_get_parameter(QTestState *who, const char *parameter)
+static long long migrate_get_parameter_int(QTestState *who,
+ const char *parameter)
{
QDict *rsp;
long long result;
@@ -409,17 +410,17 @@ static long long migrate_get_parameter(QTestState *who, const char *parameter)
return result;
}
-static void migrate_check_parameter(QTestState *who, const char *parameter,
- long long value)
+static void migrate_check_parameter_int(QTestState *who, const char *parameter,
+ long long value)
{
long long result;
- result = migrate_get_parameter(who, parameter);
+ result = migrate_get_parameter_int(who, parameter);
g_assert_cmpint(result, ==, value);
}
-static void migrate_set_parameter(QTestState *who, const char *parameter,
- long long value)
+static void migrate_set_parameter_int(QTestState *who, const char *parameter,
+ long long value)
{
QDict *rsp;
@@ -429,7 +430,7 @@ static void migrate_set_parameter(QTestState *who, const char *parameter,
parameter, value);
g_assert(qdict_haskey(rsp, "return"));
qobject_unref(rsp);
- migrate_check_parameter(who, parameter, value);
+ migrate_check_parameter_int(who, parameter, value);
}
static void migrate_pause(QTestState *who)
@@ -681,7 +682,7 @@ static void deprecated_set_downtime(QTestState *who, const double value)
" 'arguments': { 'value': %f } }", value);
g_assert(qdict_haskey(rsp, "return"));
qobject_unref(rsp);
- migrate_check_parameter(who, "downtime-limit", value * 1000);
+ migrate_check_parameter_int(who, "downtime-limit", value * 1000);
}
static void deprecated_set_speed(QTestState *who, long long value)
@@ -692,7 +693,7 @@ static void deprecated_set_speed(QTestState *who, long long value)
"'arguments': { 'value': %lld } }", value);
g_assert(qdict_haskey(rsp, "return"));
qobject_unref(rsp);
- migrate_check_parameter(who, "max-bandwidth", value);
+ migrate_check_parameter_int(who, "max-bandwidth", value);
}
static void deprecated_set_cache_size(QTestState *who, long long value)
@@ -703,7 +704,7 @@ static void deprecated_set_cache_size(QTestState *who, long long value)
"'arguments': { 'value': %lld } }", value);
g_assert(qdict_haskey(rsp, "return"));
qobject_unref(rsp);
- migrate_check_parameter(who, "xbzrle-cache-size", value);
+ migrate_check_parameter_int(who, "xbzrle-cache-size", value);
}
static void test_deprecated(void)
@@ -738,8 +739,8 @@ static int migrate_postcopy_prepare(QTestState **from_ptr,
* quickly, but that it doesn't complete precopy even on a slow
* machine, so also set the downtime.
*/
- migrate_set_parameter(from, "max-bandwidth", 100000000);
- migrate_set_parameter(from, "downtime-limit", 1);
+ migrate_set_parameter_int(from, "max-bandwidth", 100000000);
+ migrate_set_parameter_int(from, "downtime-limit", 1);
/* Wait for the first serial output from the source */
wait_for_serial("src_serial");
@@ -790,7 +791,7 @@ static void test_postcopy_recovery(void)
}
/* Turn postcopy speed down, 4K/s is slow enough on any machines */
- migrate_set_parameter(from, "max-postcopy-bandwidth", 4096);
+ migrate_set_parameter_int(from, "max-postcopy-bandwidth", 4096);
/* Now we start the postcopy */
migrate_postcopy_start(from, to);
@@ -831,7 +832,7 @@ static void test_postcopy_recovery(void)
g_free(uri);
/* Restore the postcopy bandwidth to unlimited */
- migrate_set_parameter(from, "max-postcopy-bandwidth", 0);
+ migrate_set_parameter_int(from, "max-postcopy-bandwidth", 0);
migrate_postcopy_complete(from, to);
}
@@ -877,9 +878,9 @@ static void test_precopy_unix(void)
* machine, so also set the downtime.
*/
/* 1 ms should make it not converge*/
- migrate_set_parameter(from, "downtime-limit", 1);
+ migrate_set_parameter_int(from, "downtime-limit", 1);
/* 1GB/s */
- migrate_set_parameter(from, "max-bandwidth", 1000000000);
+ migrate_set_parameter_int(from, "max-bandwidth", 1000000000);
/* Wait for the first serial output from the source */
wait_for_serial("src_serial");
@@ -889,7 +890,7 @@ static void test_precopy_unix(void)
wait_for_migration_pass(from);
/* 300 ms should converge */
- migrate_set_parameter(from, "downtime-limit", 300);
+ migrate_set_parameter_int(from, "downtime-limit", 300);
if (!got_stop) {
qtest_qmp_eventwait(from, "STOP");
@@ -956,11 +957,11 @@ static void test_xbzrle(const char *uri)
* machine, so also set the downtime.
*/
/* 1 ms should make it not converge*/
- migrate_set_parameter(from, "downtime-limit", 1);
+ migrate_set_parameter_int(from, "downtime-limit", 1);
/* 1GB/s */
- migrate_set_parameter(from, "max-bandwidth", 1000000000);
+ migrate_set_parameter_int(from, "max-bandwidth", 1000000000);
- migrate_set_parameter(from, "xbzrle-cache-size", 33554432);
+ migrate_set_parameter_int(from, "xbzrle-cache-size", 33554432);
migrate_set_capability(from, "xbzrle", "true");
migrate_set_capability(to, "xbzrle", "true");
@@ -972,7 +973,7 @@ static void test_xbzrle(const char *uri)
wait_for_migration_pass(from);
/* 300ms should converge */
- migrate_set_parameter(from, "downtime-limit", 300);
+ migrate_set_parameter_int(from, "downtime-limit", 300);
if (!got_stop) {
qtest_qmp_eventwait(from, "STOP");
@@ -1008,9 +1009,9 @@ static void test_precopy_tcp(void)
* machine, so also set the downtime.
*/
/* 1 ms should make it not converge*/
- migrate_set_parameter(from, "downtime-limit", 1);
+ migrate_set_parameter_int(from, "downtime-limit", 1);
/* 1GB/s */
- migrate_set_parameter(from, "max-bandwidth", 1000000000);
+ migrate_set_parameter_int(from, "max-bandwidth", 1000000000);
/* Wait for the first serial output from the source */
wait_for_serial("src_serial");
@@ -1022,7 +1023,7 @@ static void test_precopy_tcp(void)
wait_for_migration_pass(from);
/* 300ms should converge */
- migrate_set_parameter(from, "downtime-limit", 300);
+ migrate_set_parameter_int(from, "downtime-limit", 300);
if (!got_stop) {
qtest_qmp_eventwait(from, "STOP");
@@ -1054,9 +1055,9 @@ static void test_migrate_fd_proto(void)
* machine, so also set the downtime.
*/
/* 1 ms should make it not converge */
- migrate_set_parameter(from, "downtime-limit", 1);
+ migrate_set_parameter_int(from, "downtime-limit", 1);
/* 1GB/s */
- migrate_set_parameter(from, "max-bandwidth", 1000000000);
+ migrate_set_parameter_int(from, "max-bandwidth", 1000000000);
/* Wait for the first serial output from the source */
wait_for_serial("src_serial");
@@ -1090,7 +1091,7 @@ static void test_migrate_fd_proto(void)
wait_for_migration_pass(from);
/* 300ms should converge */
- migrate_set_parameter(from, "downtime-limit", 300);
+ migrate_set_parameter_int(from, "downtime-limit", 300);
if (!got_stop) {
qtest_qmp_eventwait(from, "STOP");
diff --git a/tests/test-bitmap.c b/tests/test-bitmap.c
new file mode 100644
index 0000000..cb7c5e4
--- /dev/null
+++ b/tests/test-bitmap.c
@@ -0,0 +1,72 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Bitmap.c unit-tests.
+ *
+ * Copyright (C) 2019, Red Hat, Inc.
+ *
+ * Author: Peter Xu <peterx@redhat.com>
+ */
+
+#include <stdlib.h>
+#include "qemu/osdep.h"
+#include "qemu/bitmap.h"
+
+#define BMAP_SIZE 1024
+
+static void check_bitmap_copy_with_offset(void)
+{
+ unsigned long *bmap1, *bmap2, *bmap3, total;
+
+ bmap1 = bitmap_new(BMAP_SIZE);
+ bmap2 = bitmap_new(BMAP_SIZE);
+ bmap3 = bitmap_new(BMAP_SIZE);
+
+ bmap1[0] = random();
+ bmap1[1] = random();
+ bmap1[2] = random();
+ bmap1[3] = random();
+ total = BITS_PER_LONG * 4;
+
+ /* Shift 115 bits into bmap2 */
+ bitmap_copy_with_dst_offset(bmap2, bmap1, 115, total);
+ /* Shift another 85 bits into bmap3 */
+ bitmap_copy_with_dst_offset(bmap3, bmap2, 85, total + 115);
+ /* Shift back 200 bits back */
+ bitmap_copy_with_src_offset(bmap2, bmap3, 200, total);
+
+ g_assert_cmpmem(bmap1, total / BITS_PER_LONG,
+ bmap2, total / BITS_PER_LONG);
+
+ bitmap_clear(bmap1, 0, BMAP_SIZE);
+ /* Set bits in bmap1 are 100-245 */
+ bitmap_set(bmap1, 100, 145);
+
+ /* Set bits in bmap2 are 60-205 */
+ bitmap_copy_with_src_offset(bmap2, bmap1, 40, 250);
+ g_assert_cmpint(find_first_bit(bmap2, 60), ==, 60);
+ g_assert_cmpint(find_next_zero_bit(bmap2, 205, 60), ==, 205);
+ g_assert(test_bit(205, bmap2) == 0);
+
+ /* Set bits in bmap3 are 135-280 */
+ bitmap_copy_with_dst_offset(bmap3, bmap1, 35, 250);
+ g_assert_cmpint(find_first_bit(bmap3, 135), ==, 135);
+ g_assert_cmpint(find_next_zero_bit(bmap3, 280, 135), ==, 280);
+ g_assert(test_bit(280, bmap3) == 0);
+
+ g_free(bmap1);
+ g_free(bmap2);
+ g_free(bmap3);
+}
+
+int main(int argc, char **argv)
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/bitmap/bitmap_copy_with_offset",
+ check_bitmap_copy_with_offset);
+
+ g_test_run();
+
+ return 0;
+}