2
#include <glib/gstdio.h>
3
#include <gio/gio.h>
4
#include "libqtest.h"
5
+#include "migration/migration-qmp.h"
6
#include "dbus-vmstate1.h"
6
-#include "migration-helpers.h"
7
8
static char *workdir;
9
29
30
typedef struct Test {
31
const char *id_list;
32
- bool migrate_fail;
32
+ int result;
33
bool without_dst_b;
34
TestServer srcA;
35
TestServer dstA;
190
g_autofree char *uri = NULL;
191
QTestState *src_qemu = NULL, *dst_qemu = NULL;
192
guint ownsrcA, ownsrcB, owndstA, owndstB;
193
+ QTestMigrationState src_state = { };
194
195
uri = g_strdup_printf("unix:%s/migsocket", workdir);
196
225
226
src_qemu = qtest_init(src_qemu_args);
227
dst_qemu = qtest_init(dst_qemu_args);
228
+
229
+ migrate_set_capability(src_qemu, "events", true);
230
+ qtest_qmp_set_event_callback(src_qemu, migrate_watch_for_events,
231
+ &src_state);
232
+
233
set_id_list(test, src_qemu);
234
set_id_list(test, dst_qemu);
235
236
thread = g_thread_new("dbus-vmstate-thread", dbus_vmstate_thread, loop);
237
238
migrate_incoming_qmp(dst_qemu, uri, NULL, "{}");
233
- migrate_qmp(src_qemu, uri, "{}");
239
+ migrate_ensure_converge(src_qemu);
240
+ migrate_qmp(src_qemu, NULL, uri, NULL, "{}");
241
test->src_qemu = src_qemu;
235
- if (test->migrate_fail) {
236
- wait_for_migration_fail(src_qemu, true);
237
- qtest_set_expected_status(dst_qemu, EXIT_FAILURE);
242
+
243
+ if (test->result != MIG_TEST_SUCCEED) {
244
+ QDict *rsp;
245
+
246
+ migration_event_wait(src_qemu, "failing");
247
+ wait_for_resume(src_qemu, &src_state);
248
+ migration_event_wait(src_qemu, "failed");
249
+
250
+ rsp = qtest_qmp_assert_success_ref(src_qemu,
251
+ "{ 'execute': 'query-status' }");
252
+ g_assert(qdict_haskey(rsp, "running"));
253
+ g_assert(qdict_get_bool(rsp, "running"));
254
+ qobject_unref(rsp);
255
} else {
256
wait_for_migration_complete(src_qemu);
257
}
287
}
288
289
static void
273
-test_dbus_vmstate_without_list(void)
290
+test_dbus_vmstate_without_list(char *name, MigrateCommon *args)
291
{
292
Test test = { 0, };
293
298
}
299
300
static void
284
-test_dbus_vmstate_with_list(void)
301
+test_dbus_vmstate_with_list(char *name, MigrateCommon *args)
302
{
303
Test test = { .id_list = "idA,idB" };
304
309
}
310
311
static void
295
-test_dbus_vmstate_only_a(void)
312
+test_dbus_vmstate_only_a(char *name, MigrateCommon *args)
313
{
314
Test test = { .id_list = "idA" };
315
320
}
321
322
static void
306
-test_dbus_vmstate_missing_src(void)
323
+test_dbus_vmstate_missing_src(char *name, MigrateCommon *args)
324
{
308
- Test test = { .id_list = "idA,idC", .migrate_fail = true };
325
+ Test test = { .id_list = "idA,idC",
326
+ .result = MIG_TEST_FAIL };
327
328
/* run in subprocess to silence QEMU error reporting */
329
if (g_test_subprocess()) {
338
}
339
340
static void
323
-test_dbus_vmstate_missing_dst(void)
341
+test_dbus_vmstate_missing_dst(char *name, MigrateCommon *args)
342
{
343
Test test = { .id_list = "idA,idB",
344
.without_dst_b = true,
327
- .migrate_fail = true };
345
+ .result = MIG_TEST_FAIL };
346
347
/* run in subprocess to silence QEMU error reporting */
348
if (g_test_subprocess()) {
361
main(int argc, char **argv)
362
{
363
GError *err = NULL;
346
- g_autofree char *dbus_daemon = NULL;
364
int ret;
365
349
- dbus_daemon = g_build_filename(G_STRINGIFY(SRCDIR),
350
- "tests",
351
- "dbus-vmstate-daemon.sh",
352
- NULL);
353
- g_setenv("G_TEST_DBUS_DAEMON", dbus_daemon, true);
354
-
366
g_test_init(&argc, &argv, NULL);
367
368
workdir = g_dir_make_tmp("dbus-vmstate-test-XXXXXX", &err);
373
374
g_setenv("DBUS_VMSTATE_TEST_TMPDIR", workdir, true);
375
365
- qtest_add_func("/dbus-vmstate/without-list",
366
- test_dbus_vmstate_without_list);
367
- qtest_add_func("/dbus-vmstate/with-list",
368
- test_dbus_vmstate_with_list);
369
- qtest_add_func("/dbus-vmstate/only-a",
370
- test_dbus_vmstate_only_a);
371
- qtest_add_func("/dbus-vmstate/missing-src",
372
- test_dbus_vmstate_missing_src);
373
- qtest_add_func("/dbus-vmstate/missing-dst",
374
- test_dbus_vmstate_missing_dst);
376
+ migration_test_add("/dbus-vmstate/without-list",
377
+ test_dbus_vmstate_without_list);
378
+ migration_test_add("/dbus-vmstate/with-list",
379
+ test_dbus_vmstate_with_list);
380
+ migration_test_add("/dbus-vmstate/only-a",
381
+ test_dbus_vmstate_only_a);
382
+ migration_test_add("/dbus-vmstate/missing-src",
383
+ test_dbus_vmstate_missing_src);
384
+ migration_test_add("/dbus-vmstate/missing-dst",
385
+ test_dbus_vmstate_missing_dst);
386
387
ret = g_test_run();
388