]> git.proxmox.com Git - mirror_qemu.git/blob - tests/migration-test.c
tests: Add migration test for aarch64
[mirror_qemu.git] / tests / migration-test.c
1 /*
2 * QTest testcase for migration
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 #include "qemu/osdep.h"
14
15 #include "libqtest.h"
16 #include "qapi/qmp/qdict.h"
17 #include "qapi/qmp/qjson.h"
18 #include "qemu/option.h"
19 #include "qemu/range.h"
20 #include "qemu/sockets.h"
21 #include "chardev/char.h"
22 #include "sysemu/sysemu.h"
23
24 #include "migration/migration-test.h"
25
26 /* TODO actually test the results and get rid of this */
27 #define qtest_qmp_discard_response(...) qobject_unref(qtest_qmp(__VA_ARGS__))
28
29 unsigned start_address;
30 unsigned end_address;
31 bool got_stop;
32 static bool uffd_feature_thread_id;
33
34 #if defined(__linux__)
35 #include <sys/syscall.h>
36 #include <sys/vfs.h>
37 #endif
38
39 #if defined(__linux__) && defined(__NR_userfaultfd) && defined(CONFIG_EVENTFD)
40 #include <sys/eventfd.h>
41 #include <sys/ioctl.h>
42 #include <linux/userfaultfd.h>
43
44 static bool ufd_version_check(void)
45 {
46 struct uffdio_api api_struct;
47 uint64_t ioctl_mask;
48
49 int ufd = syscall(__NR_userfaultfd, O_CLOEXEC);
50
51 if (ufd == -1) {
52 g_test_message("Skipping test: userfaultfd not available");
53 return false;
54 }
55
56 api_struct.api = UFFD_API;
57 api_struct.features = 0;
58 if (ioctl(ufd, UFFDIO_API, &api_struct)) {
59 g_test_message("Skipping test: UFFDIO_API failed");
60 return false;
61 }
62 uffd_feature_thread_id = api_struct.features & UFFD_FEATURE_THREAD_ID;
63
64 ioctl_mask = (__u64)1 << _UFFDIO_REGISTER |
65 (__u64)1 << _UFFDIO_UNREGISTER;
66 if ((api_struct.ioctls & ioctl_mask) != ioctl_mask) {
67 g_test_message("Skipping test: Missing userfault feature");
68 return false;
69 }
70
71 return true;
72 }
73
74 #else
75 static bool ufd_version_check(void)
76 {
77 g_test_message("Skipping test: Userfault not available (builtdtime)");
78 return false;
79 }
80
81 #endif
82
83 static const char *tmpfs;
84
85 /* The boot file modifies memory area in [start_address, end_address)
86 * repeatedly. It outputs a 'B' at a fixed rate while it's still running.
87 */
88 #include "tests/migration/i386/a-b-bootblock.h"
89 #include "tests/migration/aarch64/a-b-kernel.h"
90
91 static void init_bootfile(const char *bootpath, void *content)
92 {
93 FILE *bootfile = fopen(bootpath, "wb");
94
95 g_assert_cmpint(fwrite(content, 512, 1, bootfile), ==, 1);
96 fclose(bootfile);
97 }
98
99 /*
100 * Wait for some output in the serial output file,
101 * we get an 'A' followed by an endless string of 'B's
102 * but on the destination we won't have the A.
103 */
104 static void wait_for_serial(const char *side)
105 {
106 char *serialpath = g_strdup_printf("%s/%s", tmpfs, side);
107 FILE *serialfile = fopen(serialpath, "r");
108 const char *arch = qtest_get_arch();
109 int started = (strcmp(side, "src_serial") == 0 &&
110 strcmp(arch, "ppc64") == 0) ? 0 : 1;
111
112 g_free(serialpath);
113 do {
114 int readvalue = fgetc(serialfile);
115
116 if (!started) {
117 /* SLOF prints its banner before starting test,
118 * to ignore it, mark the start of the test with '_',
119 * ignore all characters until this marker
120 */
121 switch (readvalue) {
122 case '_':
123 started = 1;
124 break;
125 case EOF:
126 fseek(serialfile, 0, SEEK_SET);
127 usleep(1000);
128 break;
129 }
130 continue;
131 }
132 switch (readvalue) {
133 case 'A':
134 /* Fine */
135 break;
136
137 case 'B':
138 /* It's alive! */
139 fclose(serialfile);
140 return;
141
142 case EOF:
143 started = (strcmp(side, "src_serial") == 0 &&
144 strcmp(arch, "ppc64") == 0) ? 0 : 1;
145 fseek(serialfile, 0, SEEK_SET);
146 usleep(1000);
147 break;
148
149 default:
150 fprintf(stderr, "Unexpected %d on %s serial\n", readvalue, side);
151 g_assert_not_reached();
152 }
153 } while (true);
154 }
155
156 static void stop_cb(void *opaque, const char *name, QDict *data)
157 {
158 if (!strcmp(name, "STOP")) {
159 got_stop = true;
160 }
161 }
162
163 /*
164 * Events can get in the way of responses we are actually waiting for.
165 */
166 GCC_FMT_ATTR(2, 3)
167 static QDict *wait_command(QTestState *who, const char *command, ...)
168 {
169 va_list ap;
170
171 va_start(ap, command);
172 qtest_qmp_vsend(who, command, ap);
173 va_end(ap);
174
175 return qtest_qmp_receive_success(who, stop_cb, NULL);
176 }
177
178 /*
179 * Note: caller is responsible to free the returned object via
180 * qobject_unref() after use
181 */
182 static QDict *migrate_query(QTestState *who)
183 {
184 return wait_command(who, "{ 'execute': 'query-migrate' }");
185 }
186
187 /*
188 * Note: caller is responsible to free the returned object via
189 * g_free() after use
190 */
191 static gchar *migrate_query_status(QTestState *who)
192 {
193 QDict *rsp_return = migrate_query(who);
194 gchar *status = g_strdup(qdict_get_str(rsp_return, "status"));
195
196 g_assert(status);
197 qobject_unref(rsp_return);
198
199 return status;
200 }
201
202 /*
203 * It's tricky to use qemu's migration event capability with qtest,
204 * events suddenly appearing confuse the qmp()/hmp() responses.
205 */
206
207 static uint64_t get_migration_pass(QTestState *who)
208 {
209 QDict *rsp_return, *rsp_ram;
210 uint64_t result;
211
212 rsp_return = migrate_query(who);
213 if (!qdict_haskey(rsp_return, "ram")) {
214 /* Still in setup */
215 result = 0;
216 } else {
217 rsp_ram = qdict_get_qdict(rsp_return, "ram");
218 result = qdict_get_try_int(rsp_ram, "dirty-sync-count", 0);
219 }
220 qobject_unref(rsp_return);
221 return result;
222 }
223
224 static void read_blocktime(QTestState *who)
225 {
226 QDict *rsp_return;
227
228 rsp_return = migrate_query(who);
229 g_assert(qdict_haskey(rsp_return, "postcopy-blocktime"));
230 qobject_unref(rsp_return);
231 }
232
233 static void wait_for_migration_status(QTestState *who,
234 const char *goal)
235 {
236 while (true) {
237 bool completed;
238 char *status;
239
240 status = migrate_query_status(who);
241 completed = strcmp(status, goal) == 0;
242 g_assert_cmpstr(status, !=, "failed");
243 g_free(status);
244 if (completed) {
245 return;
246 }
247 usleep(1000);
248 }
249 }
250
251 static void wait_for_migration_complete(QTestState *who)
252 {
253 wait_for_migration_status(who, "completed");
254 }
255
256 static void wait_for_migration_pass(QTestState *who)
257 {
258 uint64_t initial_pass = get_migration_pass(who);
259 uint64_t pass;
260
261 /* Wait for the 1st sync */
262 while (!got_stop && !initial_pass) {
263 usleep(1000);
264 initial_pass = get_migration_pass(who);
265 }
266
267 do {
268 usleep(1000);
269 pass = get_migration_pass(who);
270 } while (pass == initial_pass && !got_stop);
271 }
272
273 static void check_guests_ram(QTestState *who)
274 {
275 /* Our ASM test will have been incrementing one byte from each page from
276 * start_address to < end_address in order. This gives us a constraint
277 * that any page's byte should be equal or less than the previous pages
278 * byte (mod 256); and they should all be equal except for one transition
279 * at the point where we meet the incrementer. (We're running this with
280 * the guest stopped).
281 */
282 unsigned address;
283 uint8_t first_byte;
284 uint8_t last_byte;
285 bool hit_edge = false;
286 bool bad = false;
287
288 qtest_memread(who, start_address, &first_byte, 1);
289 last_byte = first_byte;
290
291 for (address = start_address + TEST_MEM_PAGE_SIZE; address < end_address;
292 address += TEST_MEM_PAGE_SIZE)
293 {
294 uint8_t b;
295 qtest_memread(who, address, &b, 1);
296 if (b != last_byte) {
297 if (((b + 1) % 256) == last_byte && !hit_edge) {
298 /* This is OK, the guest stopped at the point of
299 * incrementing the previous page but didn't get
300 * to us yet.
301 */
302 hit_edge = true;
303 last_byte = b;
304 } else {
305 fprintf(stderr, "Memory content inconsistency at %x"
306 " first_byte = %x last_byte = %x current = %x"
307 " hit_edge = %x\n",
308 address, first_byte, last_byte, b, hit_edge);
309 bad = true;
310 }
311 }
312 }
313 g_assert_false(bad);
314 }
315
316 static void cleanup(const char *filename)
317 {
318 char *path = g_strdup_printf("%s/%s", tmpfs, filename);
319
320 unlink(path);
321 g_free(path);
322 }
323
324 static void migrate_check_parameter(QTestState *who, const char *parameter,
325 long long value)
326 {
327 QDict *rsp_return;
328
329 rsp_return = wait_command(who,
330 "{ 'execute': 'query-migrate-parameters' }");
331 g_assert_cmpint(qdict_get_int(rsp_return, parameter), ==, value);
332 qobject_unref(rsp_return);
333 }
334
335 static void migrate_set_parameter(QTestState *who, const char *parameter,
336 long long value)
337 {
338 QDict *rsp;
339
340 rsp = qtest_qmp(who,
341 "{ 'execute': 'migrate-set-parameters',"
342 "'arguments': { %s: %lld } }",
343 parameter, value);
344 g_assert(qdict_haskey(rsp, "return"));
345 qobject_unref(rsp);
346 migrate_check_parameter(who, parameter, value);
347 }
348
349 static void migrate_pause(QTestState *who)
350 {
351 QDict *rsp;
352
353 rsp = wait_command(who, "{ 'execute': 'migrate-pause' }");
354 qobject_unref(rsp);
355 }
356
357 static void migrate_recover(QTestState *who, const char *uri)
358 {
359 QDict *rsp;
360
361 rsp = wait_command(who,
362 "{ 'execute': 'migrate-recover', "
363 " 'id': 'recover-cmd', "
364 " 'arguments': { 'uri': %s } }",
365 uri);
366 qobject_unref(rsp);
367 }
368
369 static void migrate_set_capability(QTestState *who, const char *capability,
370 bool value)
371 {
372 QDict *rsp;
373
374 rsp = qtest_qmp(who,
375 "{ 'execute': 'migrate-set-capabilities',"
376 "'arguments': { "
377 "'capabilities': [ { "
378 "'capability': %s, 'state': %i } ] } }",
379 capability, value);
380 g_assert(qdict_haskey(rsp, "return"));
381 qobject_unref(rsp);
382 }
383
384 /*
385 * Send QMP command "migrate".
386 * Arguments are built from @fmt... (formatted like
387 * qobject_from_jsonf_nofail()) with "uri": @uri spliced in.
388 */
389 GCC_FMT_ATTR(3, 4)
390 static void migrate(QTestState *who, const char *uri, const char *fmt, ...)
391 {
392 va_list ap;
393 QDict *args, *rsp;
394
395 va_start(ap, fmt);
396 args = qdict_from_vjsonf_nofail(fmt, ap);
397 va_end(ap);
398
399 g_assert(!qdict_haskey(args, "uri"));
400 qdict_put_str(args, "uri", uri);
401
402 rsp = qmp("{ 'execute': 'migrate', 'arguments': %p}", args);
403 g_assert(qdict_haskey(rsp, "return"));
404 qobject_unref(rsp);
405 }
406
407 static void migrate_postcopy_start(QTestState *from, QTestState *to)
408 {
409 QDict *rsp;
410
411 rsp = wait_command(from, "{ 'execute': 'migrate-start-postcopy' }");
412 qobject_unref(rsp);
413
414 if (!got_stop) {
415 qtest_qmp_eventwait(from, "STOP");
416 }
417
418 qtest_qmp_eventwait(to, "RESUME");
419 }
420
421 static int test_migrate_start(QTestState **from, QTestState **to,
422 const char *uri, bool hide_stderr)
423 {
424 gchar *cmd_src, *cmd_dst;
425 char *bootpath = g_strdup_printf("%s/bootsect", tmpfs);
426 const char *arch = qtest_get_arch();
427 const char *accel = "kvm:tcg";
428
429 got_stop = false;
430
431 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
432 init_bootfile(bootpath, x86_bootsect);
433 cmd_src = g_strdup_printf("-machine accel=%s -m 150M"
434 " -name source,debug-threads=on"
435 " -serial file:%s/src_serial"
436 " -drive file=%s,format=raw",
437 accel, tmpfs, bootpath);
438 cmd_dst = g_strdup_printf("-machine accel=%s -m 150M"
439 " -name target,debug-threads=on"
440 " -serial file:%s/dest_serial"
441 " -drive file=%s,format=raw"
442 " -incoming %s",
443 accel, tmpfs, bootpath, uri);
444 start_address = X86_TEST_MEM_START;
445 end_address = X86_TEST_MEM_END;
446 } else if (strcmp(arch, "ppc64") == 0) {
447 cmd_src = g_strdup_printf("-machine accel=%s -m 256M -nodefaults"
448 " -name source,debug-threads=on"
449 " -serial file:%s/src_serial"
450 " -prom-env 'use-nvramrc?=true' -prom-env "
451 "'nvramrc=hex .\" _\" begin %x %x "
452 "do i c@ 1 + i c! 1000 +loop .\" B\" 0 "
453 "until'", accel, tmpfs, end_address,
454 start_address);
455 cmd_dst = g_strdup_printf("-machine accel=%s -m 256M"
456 " -name target,debug-threads=on"
457 " -serial file:%s/dest_serial"
458 " -incoming %s",
459 accel, tmpfs, uri);
460
461 start_address = PPC_TEST_MEM_START;
462 end_address = PPC_TEST_MEM_END;
463 } else if (strcmp(arch, "aarch64") == 0) {
464 init_bootfile(bootpath, aarch64_kernel);
465 cmd_src = g_strdup_printf("-machine virt,accel=%s,gic-version=max "
466 "-name vmsource,debug-threads=on -cpu max "
467 "-m 150M -serial file:%s/src_serial "
468 "-kernel %s ",
469 accel, tmpfs, bootpath);
470 cmd_dst = g_strdup_printf("-machine virt,accel=%s,gic-version=max "
471 "-name vmdest,debug-threads=on -cpu max "
472 "-m 150M -serial file:%s/dest_serial "
473 "-kernel %s "
474 "-incoming %s ",
475 accel, tmpfs, bootpath, uri);
476
477 start_address = ARM_TEST_MEM_START;
478 end_address = ARM_TEST_MEM_END;
479
480 g_assert(sizeof(aarch64_kernel) <= ARM_TEST_MAX_KERNEL_SIZE);
481 } else {
482 g_assert_not_reached();
483 }
484
485 g_free(bootpath);
486
487 if (hide_stderr) {
488 gchar *tmp;
489 tmp = g_strdup_printf("%s 2>/dev/null", cmd_src);
490 g_free(cmd_src);
491 cmd_src = tmp;
492
493 tmp = g_strdup_printf("%s 2>/dev/null", cmd_dst);
494 g_free(cmd_dst);
495 cmd_dst = tmp;
496 }
497
498 *from = qtest_start(cmd_src);
499 g_free(cmd_src);
500
501 *to = qtest_init(cmd_dst);
502 g_free(cmd_dst);
503 return 0;
504 }
505
506 static void test_migrate_end(QTestState *from, QTestState *to, bool test_dest)
507 {
508 unsigned char dest_byte_a, dest_byte_b, dest_byte_c, dest_byte_d;
509
510 qtest_quit(from);
511
512 if (test_dest) {
513 qtest_memread(to, start_address, &dest_byte_a, 1);
514
515 /* Destination still running, wait for a byte to change */
516 do {
517 qtest_memread(to, start_address, &dest_byte_b, 1);
518 usleep(1000 * 10);
519 } while (dest_byte_a == dest_byte_b);
520
521 qtest_qmp_discard_response(to, "{ 'execute' : 'stop'}");
522
523 /* With it stopped, check nothing changes */
524 qtest_memread(to, start_address, &dest_byte_c, 1);
525 usleep(1000 * 200);
526 qtest_memread(to, start_address, &dest_byte_d, 1);
527 g_assert_cmpint(dest_byte_c, ==, dest_byte_d);
528
529 check_guests_ram(to);
530 }
531
532 qtest_quit(to);
533
534 cleanup("bootsect");
535 cleanup("migsocket");
536 cleanup("src_serial");
537 cleanup("dest_serial");
538 }
539
540 static void deprecated_set_downtime(QTestState *who, const double value)
541 {
542 QDict *rsp;
543
544 rsp = qtest_qmp(who,
545 "{ 'execute': 'migrate_set_downtime',"
546 " 'arguments': { 'value': %f } }", value);
547 g_assert(qdict_haskey(rsp, "return"));
548 qobject_unref(rsp);
549 migrate_check_parameter(who, "downtime-limit", value * 1000);
550 }
551
552 static void deprecated_set_speed(QTestState *who, long long value)
553 {
554 QDict *rsp;
555
556 rsp = qtest_qmp(who, "{ 'execute': 'migrate_set_speed',"
557 "'arguments': { 'value': %lld } }", value);
558 g_assert(qdict_haskey(rsp, "return"));
559 qobject_unref(rsp);
560 migrate_check_parameter(who, "max-bandwidth", value);
561 }
562
563 static void test_deprecated(void)
564 {
565 QTestState *from;
566
567 from = qtest_start("-machine none");
568
569 deprecated_set_downtime(from, 0.12345);
570 deprecated_set_speed(from, 12345);
571
572 qtest_quit(from);
573 }
574
575 static int migrate_postcopy_prepare(QTestState **from_ptr,
576 QTestState **to_ptr,
577 bool hide_error)
578 {
579 char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
580 QTestState *from, *to;
581
582 if (test_migrate_start(&from, &to, uri, hide_error)) {
583 return -1;
584 }
585
586 migrate_set_capability(from, "postcopy-ram", true);
587 migrate_set_capability(to, "postcopy-ram", true);
588 migrate_set_capability(to, "postcopy-blocktime", true);
589
590 /* We want to pick a speed slow enough that the test completes
591 * quickly, but that it doesn't complete precopy even on a slow
592 * machine, so also set the downtime.
593 */
594 migrate_set_parameter(from, "max-bandwidth", 100000000);
595 migrate_set_parameter(from, "downtime-limit", 1);
596
597 /* Wait for the first serial output from the source */
598 wait_for_serial("src_serial");
599
600 migrate(from, uri, "{}");
601 g_free(uri);
602
603 wait_for_migration_pass(from);
604
605 *from_ptr = from;
606 *to_ptr = to;
607
608 return 0;
609 }
610
611 static void migrate_postcopy_complete(QTestState *from, QTestState *to)
612 {
613 wait_for_migration_complete(from);
614
615 /* Make sure we get at least one "B" on destination */
616 wait_for_serial("dest_serial");
617
618 if (uffd_feature_thread_id) {
619 read_blocktime(to);
620 }
621
622 test_migrate_end(from, to, true);
623 }
624
625 static void test_postcopy(void)
626 {
627 QTestState *from, *to;
628
629 if (migrate_postcopy_prepare(&from, &to, false)) {
630 return;
631 }
632 migrate_postcopy_start(from, to);
633 migrate_postcopy_complete(from, to);
634 }
635
636 static void test_postcopy_recovery(void)
637 {
638 QTestState *from, *to;
639 char *uri;
640
641 if (migrate_postcopy_prepare(&from, &to, true)) {
642 return;
643 }
644
645 /* Turn postcopy speed down, 4K/s is slow enough on any machines */
646 migrate_set_parameter(from, "max-postcopy-bandwidth", 4096);
647
648 /* Now we start the postcopy */
649 migrate_postcopy_start(from, to);
650
651 /*
652 * Wait until postcopy is really started; we can only run the
653 * migrate-pause command during a postcopy
654 */
655 wait_for_migration_status(from, "postcopy-active");
656
657 /*
658 * Manually stop the postcopy migration. This emulates a network
659 * failure with the migration socket
660 */
661 migrate_pause(from);
662
663 /*
664 * Wait for destination side to reach postcopy-paused state. The
665 * migrate-recover command can only succeed if destination machine
666 * is in the paused state
667 */
668 wait_for_migration_status(to, "postcopy-paused");
669
670 /*
671 * Create a new socket to emulate a new channel that is different
672 * from the broken migration channel; tell the destination to
673 * listen to the new port
674 */
675 uri = g_strdup_printf("unix:%s/migsocket-recover", tmpfs);
676 migrate_recover(to, uri);
677
678 /*
679 * Try to rebuild the migration channel using the resume flag and
680 * the newly created channel
681 */
682 wait_for_migration_status(from, "postcopy-paused");
683 migrate(from, uri, "{'resume': true}");
684 g_free(uri);
685
686 /* Restore the postcopy bandwidth to unlimited */
687 migrate_set_parameter(from, "max-postcopy-bandwidth", 0);
688
689 migrate_postcopy_complete(from, to);
690 }
691
692 static void test_baddest(void)
693 {
694 QTestState *from, *to;
695 QDict *rsp_return;
696 char *status;
697 bool failed;
698
699 if (test_migrate_start(&from, &to, "tcp:0:0", true)) {
700 return;
701 }
702 migrate(from, "tcp:0:0", "{}");
703 do {
704 status = migrate_query_status(from);
705 g_assert(!strcmp(status, "setup") || !(strcmp(status, "failed")));
706 failed = !strcmp(status, "failed");
707 g_free(status);
708 } while (!failed);
709
710 /* Is the machine currently running? */
711 rsp_return = wait_command(from, "{ 'execute': 'query-status' }");
712 g_assert(qdict_haskey(rsp_return, "running"));
713 g_assert(qdict_get_bool(rsp_return, "running"));
714 qobject_unref(rsp_return);
715
716 test_migrate_end(from, to, false);
717 }
718
719 static void test_precopy_unix(void)
720 {
721 char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
722 QTestState *from, *to;
723
724 if (test_migrate_start(&from, &to, uri, false)) {
725 return;
726 }
727
728 /* We want to pick a speed slow enough that the test completes
729 * quickly, but that it doesn't complete precopy even on a slow
730 * machine, so also set the downtime.
731 */
732 /* 1 ms should make it not converge*/
733 migrate_set_parameter(from, "downtime-limit", 1);
734 /* 1GB/s */
735 migrate_set_parameter(from, "max-bandwidth", 1000000000);
736
737 /* Wait for the first serial output from the source */
738 wait_for_serial("src_serial");
739
740 migrate(from, uri, "{}");
741
742 wait_for_migration_pass(from);
743
744 /* 300 ms should converge */
745 migrate_set_parameter(from, "downtime-limit", 300);
746
747 if (!got_stop) {
748 qtest_qmp_eventwait(from, "STOP");
749 }
750
751 qtest_qmp_eventwait(to, "RESUME");
752
753 wait_for_serial("dest_serial");
754 wait_for_migration_complete(from);
755
756 test_migrate_end(from, to, true);
757 g_free(uri);
758 }
759
760 int main(int argc, char **argv)
761 {
762 char template[] = "/tmp/migration-test-XXXXXX";
763 int ret;
764
765 g_test_init(&argc, &argv, NULL);
766
767 if (!ufd_version_check()) {
768 return 0;
769 }
770
771 /*
772 * On ppc64, the test only works with kvm-hv, but not with kvm-pr and TCG
773 * is touchy due to race conditions on dirty bits (especially on PPC for
774 * some reason)
775 */
776 if (g_str_equal(qtest_get_arch(), "ppc64") &&
777 access("/sys/module/kvm_hv", F_OK)) {
778 g_test_message("Skipping test: kvm_hv not available");
779 return 0;
780 }
781
782 tmpfs = mkdtemp(template);
783 if (!tmpfs) {
784 g_test_message("mkdtemp on path (%s): %s\n", template, strerror(errno));
785 }
786 g_assert(tmpfs);
787
788 module_call_init(MODULE_INIT_QOM);
789
790 qtest_add_func("/migration/postcopy/unix", test_postcopy);
791 qtest_add_func("/migration/postcopy/recovery", test_postcopy_recovery);
792 qtest_add_func("/migration/deprecated", test_deprecated);
793 qtest_add_func("/migration/bad_dest", test_baddest);
794 qtest_add_func("/migration/precopy/unix", test_precopy_unix);
795
796 ret = g_test_run();
797
798 g_assert_cmpint(ret, ==, 0);
799
800 ret = rmdir(tmpfs);
801 if (ret != 0) {
802 g_test_message("unable to rmdir: path (%s): %s\n",
803 tmpfs, strerror(errno));
804 }
805
806 return ret;
807 }