1 /*
2  * QTest migration helpers
3  *
4  * Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates
5  *   based on the vhost-user-test.c that is:
6  *      Copyright (c) 2014 Virtual Open Systems Sarl.
7  *
8  * This work is licensed under the terms of the GNU GPL, version 2 or later.
9  * See the COPYING file in the top-level directory.
10  *
11  */
12 
13 #ifndef MIGRATION_HELPERS_H
14 #define MIGRATION_HELPERS_H
15 
16 #include "libqtest.h"
17 
18 typedef struct QTestMigrationState {
19     bool stop_seen;
20     bool resume_seen;
21     bool suspend_seen;
22     bool suspend_me;
23 } QTestMigrationState;
24 
25 bool migrate_watch_for_events(QTestState *who, const char *name,
26                               QDict *event, void *opaque);
27 
28 G_GNUC_PRINTF(5, 6)
29 void migrate_qmp(QTestState *who, QTestState *to, const char *uri,
30                  const char *channels, const char *fmt, ...);
31 
32 G_GNUC_PRINTF(3, 4)
33 void migrate_incoming_qmp(QTestState *who, const char *uri,
34                           const char *fmt, ...);
35 
36 G_GNUC_PRINTF(4, 5)
37 void migrate_qmp_fail(QTestState *who, const char *uri,
38                       const char *channels, const char *fmt, ...);
39 
40 void migrate_set_capability(QTestState *who, const char *capability,
41                             bool value);
42 
43 QDict *migrate_query(QTestState *who);
44 QDict *migrate_query_not_failed(QTestState *who);
45 
46 void wait_for_migration_status(QTestState *who,
47                                const char *goal, const char **ungoals);
48 
49 void wait_for_migration_complete(QTestState *who);
50 
51 void wait_for_migration_fail(QTestState *from, bool allow_active);
52 
53 char *find_common_machine_version(const char *mtype, const char *var1,
54                                   const char *var2);
55 char *resolve_machine_version(const char *alias, const char *var1,
56                               const char *var2);
57 #ifdef O_DIRECT
58 bool probe_o_direct_support(const char *tmpfs);
59 #else
60 static inline bool probe_o_direct_support(const char *tmpfs)
61 {
62     return false;
63 }
64 #endif
65 void migration_test_add(const char *path, void (*fn)(void));
66 void migration_event_wait(QTestState *s, const char *target);
67 
68 #endif /* MIGRATION_HELPERS_H */
69