@@ -329,9 +329,9 @@ endif
tpmemu_files = ['tpm-emu.c', 'tpm-util.c', 'tpm-tests.c']
migration_files = [files(
- 'migration-helpers.c',
'migration/bootfile.c',
'migration/migration-qmp.c',
+ 'migration/migration-util.c',
)]
if gnutls.found()
@@ -345,7 +345,7 @@ endif
qtests = {
'bios-tables-test': [io, 'boot-sector.c', 'acpi-utils.c', 'tpm-emu.c'],
'cdrom-test': files('boot-sector.c'),
- 'dbus-vmstate-test': files('migration-helpers.c') + dbus_vmstate1,
+ 'dbus-vmstate-test': files('migration/migration-qmp.c', 'migration/migration-util.c') + dbus_vmstate1,
'erst-test': files('erst-test.c'),
'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'],
'migration-test': migration_files,
deleted file mode 100644
@@ -1,54 +0,0 @@
-/*
- * QTest migration helpers
- *
- * Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates
- * based on the vhost-user-test.c that is:
- * Copyright (c) 2014 Virtual Open Systems Sarl.
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- *
- */
-
-#ifndef MIGRATION_HELPERS_H
-#define MIGRATION_HELPERS_H
-
-#include "libqtest.h"
-
-typedef struct QTestMigrationState {
- bool stop_seen;
- bool resume_seen;
- bool suspend_seen;
- bool suspend_me;
-} QTestMigrationState;
-
-bool migrate_watch_for_events(QTestState *who, const char *name,
- QDict *event, void *opaque);
-
-QDict *migrate_query(QTestState *who);
-QDict *migrate_query_not_failed(QTestState *who);
-
-void wait_for_migration_status(QTestState *who,
- const char *goal, const char **ungoals);
-
-void wait_for_migration_complete(QTestState *who);
-
-void wait_for_migration_fail(QTestState *from, bool allow_active);
-
-char *find_common_machine_version(const char *mtype, const char *var1,
- const char *var2);
-char *resolve_machine_version(const char *alias, const char *var1,
- const char *var2);
-#ifdef O_DIRECT
-bool probe_o_direct_support(const char *tmpfs);
-#else
-static inline bool probe_o_direct_support(const char *tmpfs)
-{
- return false;
-}
-#endif
-void migration_test_add(const char *path, void (*fn)(void));
-char *migrate_get_connect_uri(QTestState *who);
-void migrate_set_ports(QTestState *to, QList *channel_list);
-
-#endif /* MIGRATION_HELPERS_H */
@@ -22,7 +22,6 @@
#include "crypto/tlscredspsk.h"
#include "ppc-util.h"
-#include "migration-helpers.h"
#include "migration/bootfile.h"
#include "migration/migration-util.h"
#ifdef CONFIG_GNUTLS
@@ -12,7 +12,6 @@
#include "qemu/osdep.h"
#include "libqtest.h"
-#include "migration-helpers.h"
#include "migration-util.h"
#include "qapi/error.h"
#include "qapi/qmp/qdict.h"
similarity index 99%
rename from tests/qtest/migration-helpers.c
rename to tests/qtest/migration/migration-util.c
@@ -1,5 +1,5 @@
/*
- * QTest migration helpers
+ * QTest migration utilities
*
* Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates
* based on the vhost-user-test.c that is:
@@ -19,8 +19,8 @@
#include "qemu/cutils.h"
#include "qemu/memalign.h"
-#include "migration-helpers.h"
#include "migration/bootfile.h"
+#include "migration/migration-util.h"
static char *SocketAddress_to_str(SocketAddress *addr)
{
@@ -1,7 +1,77 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * QTest migration helpers
+ *
+ * Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates
+ * based on the vhost-user-test.c that is:
+ * Copyright (c) 2014 Virtual Open Systems Sarl.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
#ifndef MIGRATION_UTIL_H
#define MIGRATION_UTIL_H
+#include "libqtest.h"
+
+#define QEMU_ENV_SRC "QTEST_QEMU_BINARY_SRC"
+#define QEMU_ENV_DST "QTEST_QEMU_BINARY_DST"
+
+typedef struct QTestMigrationState {
+ bool stop_seen;
+ bool resume_seen;
+ bool suspend_seen;
+ bool suspend_me;
+} QTestMigrationState;
+
+typedef struct MigrationTestEnv {
+ bool has_kvm;
+ bool has_tcg;
+ bool has_uffd;
+ bool has_dirty_ring;
+ bool is_x86;
+ const char *arch;
+ const char *qemu_src;
+ const char *qemu_dst;
+ char *tmpfs;
+} MigrationTestEnv;
+
+/* migration-util.c */
+
+void migration_env_init(MigrationTestEnv *env);
+int migration_env_clean(MigrationTestEnv *env);
+
+bool migrate_watch_for_events(QTestState *who, const char *name,
+ QDict *event, void *opaque);
+
+QDict *migrate_query(QTestState *who);
+QDict *migrate_query_not_failed(QTestState *who);
+
+void wait_for_migration_status(QTestState *who,
+ const char *goal, const char **ungoals);
+
+void wait_for_migration_complete(QTestState *who);
+
+void wait_for_migration_fail(QTestState *from, bool allow_active);
+
+char *find_common_machine_version(const char *mtype, const char *var1,
+ const char *var2);
+char *resolve_machine_version(const char *alias, const char *var1,
+ const char *var2);
+#ifdef O_DIRECT
+bool probe_o_direct_support(const char *tmpfs);
+#else
+static inline bool probe_o_direct_support(const char *tmpfs)
+{
+ return false;
+}
+#endif
+void migration_test_add(const char *path, void (*fn)(void));
+char *migrate_get_connect_uri(QTestState *who);
+void migrate_set_ports(QTestState *to, QList *channel_list);
+
+
/* migration-qmp.c */
G_GNUC_PRINTF(4, 5)
void migrate_qmp_fail(QTestState *who, const char *uri,
@@ -11,7 +11,6 @@
#include "libqtest.h"
#include "libqos/pci.h"
#include "libqos/pci-pc.h"
-#include "migration-helpers.h"
#include "migration/migration-util.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qlist.h"
Rename migration-helpers.c to migration-util.c to make its purpose more explicit and avoid the "helper" terminology. Move the file to the qtest/migration/ directory along with the rest of the migration files. Merge migration-helpers.h into migration-util.h, we don't need two separate headers. Signed-off-by: Fabiano Rosas <farosas@suse.de> --- tests/qtest/meson.build | 4 +- tests/qtest/migration-helpers.h | 54 -------------- tests/qtest/migration-test.c | 1 - tests/qtest/migration/migration-qmp.c | 1 - .../migration-util.c} | 4 +- tests/qtest/migration/migration-util.h | 72 ++++++++++++++++++- tests/qtest/virtio-net-failover.c | 1 - 7 files changed, 75 insertions(+), 62 deletions(-) delete mode 100644 tests/qtest/migration-helpers.h rename tests/qtest/{migration-helpers.c => migration/migration-util.c} (99%)