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 "qemu/module.h" 18 #include "qemu/option.h" 19 #include "qemu/range.h" 20 #include "qemu/sockets.h" 21 #include "chardev/char.h" 22 #include "qapi/qapi-visit-sockets.h" 23 #include "qapi/qobject-input-visitor.h" 24 #include "qapi/qobject-output-visitor.h" 25 26 #include "migration-helpers.h" 27 #include "migration/migration-test.h" 28 29 /* TODO actually test the results and get rid of this */ 30 #define qtest_qmp_discard_response(...) qobject_unref(qtest_qmp(__VA_ARGS__)) 31 32 unsigned start_address; 33 unsigned end_address; 34 static bool uffd_feature_thread_id; 35 36 #if defined(__linux__) 37 #include <sys/syscall.h> 38 #include <sys/vfs.h> 39 #endif 40 41 #if defined(__linux__) && defined(__NR_userfaultfd) && defined(CONFIG_EVENTFD) 42 #include <sys/eventfd.h> 43 #include <sys/ioctl.h> 44 #include <linux/userfaultfd.h> 45 46 static bool ufd_version_check(void) 47 { 48 struct uffdio_api api_struct; 49 uint64_t ioctl_mask; 50 51 int ufd = syscall(__NR_userfaultfd, O_CLOEXEC); 52 53 if (ufd == -1) { 54 g_test_message("Skipping test: userfaultfd not available"); 55 return false; 56 } 57 58 api_struct.api = UFFD_API; 59 api_struct.features = 0; 60 if (ioctl(ufd, UFFDIO_API, &api_struct)) { 61 g_test_message("Skipping test: UFFDIO_API failed"); 62 return false; 63 } 64 uffd_feature_thread_id = api_struct.features & UFFD_FEATURE_THREAD_ID; 65 66 ioctl_mask = (__u64)1 << _UFFDIO_REGISTER | 67 (__u64)1 << _UFFDIO_UNREGISTER; 68 if ((api_struct.ioctls & ioctl_mask) != ioctl_mask) { 69 g_test_message("Skipping test: Missing userfault feature"); 70 return false; 71 } 72 73 return true; 74 } 75 76 #else 77 static bool ufd_version_check(void) 78 { 79 g_test_message("Skipping test: Userfault not available (builtdtime)"); 80 return false; 81 } 82 83 #endif 84 85 static const char *tmpfs; 86 87 /* The boot file modifies memory area in [start_address, end_address) 88 * repeatedly. It outputs a 'B' at a fixed rate while it's still running. 89 */ 90 #include "tests/migration/i386/a-b-bootblock.h" 91 #include "tests/migration/aarch64/a-b-kernel.h" 92 #include "tests/migration/s390x/a-b-bios.h" 93 94 static void init_bootfile(const char *bootpath, void *content, size_t len) 95 { 96 FILE *bootfile = fopen(bootpath, "wb"); 97 98 g_assert_cmpint(fwrite(content, len, 1, bootfile), ==, 1); 99 fclose(bootfile); 100 } 101 102 /* 103 * Wait for some output in the serial output file, 104 * we get an 'A' followed by an endless string of 'B's 105 * but on the destination we won't have the A. 106 */ 107 static void wait_for_serial(const char *side) 108 { 109 char *serialpath = g_strdup_printf("%s/%s", tmpfs, side); 110 FILE *serialfile = fopen(serialpath, "r"); 111 const char *arch = qtest_get_arch(); 112 int started = (strcmp(side, "src_serial") == 0 && 113 strcmp(arch, "ppc64") == 0) ? 0 : 1; 114 115 g_free(serialpath); 116 do { 117 int readvalue = fgetc(serialfile); 118 119 if (!started) { 120 /* SLOF prints its banner before starting test, 121 * to ignore it, mark the start of the test with '_', 122 * ignore all characters until this marker 123 */ 124 switch (readvalue) { 125 case '_': 126 started = 1; 127 break; 128 case EOF: 129 fseek(serialfile, 0, SEEK_SET); 130 usleep(1000); 131 break; 132 } 133 continue; 134 } 135 switch (readvalue) { 136 case 'A': 137 /* Fine */ 138 break; 139 140 case 'B': 141 /* It's alive! */ 142 fclose(serialfile); 143 return; 144 145 case EOF: 146 started = (strcmp(side, "src_serial") == 0 && 147 strcmp(arch, "ppc64") == 0) ? 0 : 1; 148 fseek(serialfile, 0, SEEK_SET); 149 usleep(1000); 150 break; 151 152 default: 153 fprintf(stderr, "Unexpected %d on %s serial\n", readvalue, side); 154 g_assert_not_reached(); 155 } 156 } while (true); 157 } 158 159 /* 160 * It's tricky to use qemu's migration event capability with qtest, 161 * events suddenly appearing confuse the qmp()/hmp() responses. 162 */ 163 164 static int64_t read_ram_property_int(QTestState *who, const char *property) 165 { 166 QDict *rsp_return, *rsp_ram; 167 int64_t result; 168 169 rsp_return = migrate_query(who); 170 if (!qdict_haskey(rsp_return, "ram")) { 171 /* Still in setup */ 172 result = 0; 173 } else { 174 rsp_ram = qdict_get_qdict(rsp_return, "ram"); 175 result = qdict_get_try_int(rsp_ram, property, 0); 176 } 177 qobject_unref(rsp_return); 178 return result; 179 } 180 181 static int64_t read_migrate_property_int(QTestState *who, const char *property) 182 { 183 QDict *rsp_return; 184 int64_t result; 185 186 rsp_return = migrate_query(who); 187 result = qdict_get_try_int(rsp_return, property, 0); 188 qobject_unref(rsp_return); 189 return result; 190 } 191 192 static uint64_t get_migration_pass(QTestState *who) 193 { 194 return read_ram_property_int(who, "dirty-sync-count"); 195 } 196 197 static void read_blocktime(QTestState *who) 198 { 199 QDict *rsp_return; 200 201 rsp_return = migrate_query(who); 202 g_assert(qdict_haskey(rsp_return, "postcopy-blocktime")); 203 qobject_unref(rsp_return); 204 } 205 206 static void wait_for_migration_pass(QTestState *who) 207 { 208 uint64_t initial_pass = get_migration_pass(who); 209 uint64_t pass; 210 211 /* Wait for the 1st sync */ 212 while (!got_stop && !initial_pass) { 213 usleep(1000); 214 initial_pass = get_migration_pass(who); 215 } 216 217 do { 218 usleep(1000); 219 pass = get_migration_pass(who); 220 } while (pass == initial_pass && !got_stop); 221 } 222 223 static void check_guests_ram(QTestState *who) 224 { 225 /* Our ASM test will have been incrementing one byte from each page from 226 * start_address to < end_address in order. This gives us a constraint 227 * that any page's byte should be equal or less than the previous pages 228 * byte (mod 256); and they should all be equal except for one transition 229 * at the point where we meet the incrementer. (We're running this with 230 * the guest stopped). 231 */ 232 unsigned address; 233 uint8_t first_byte; 234 uint8_t last_byte; 235 bool hit_edge = false; 236 int bad = 0; 237 238 qtest_memread(who, start_address, &first_byte, 1); 239 last_byte = first_byte; 240 241 for (address = start_address + TEST_MEM_PAGE_SIZE; address < end_address; 242 address += TEST_MEM_PAGE_SIZE) 243 { 244 uint8_t b; 245 qtest_memread(who, address, &b, 1); 246 if (b != last_byte) { 247 if (((b + 1) % 256) == last_byte && !hit_edge) { 248 /* This is OK, the guest stopped at the point of 249 * incrementing the previous page but didn't get 250 * to us yet. 251 */ 252 hit_edge = true; 253 last_byte = b; 254 } else { 255 bad++; 256 if (bad <= 10) { 257 fprintf(stderr, "Memory content inconsistency at %x" 258 " first_byte = %x last_byte = %x current = %x" 259 " hit_edge = %x\n", 260 address, first_byte, last_byte, b, hit_edge); 261 } 262 } 263 } 264 } 265 if (bad >= 10) { 266 fprintf(stderr, "and in another %d pages", bad - 10); 267 } 268 g_assert(bad == 0); 269 } 270 271 static void cleanup(const char *filename) 272 { 273 char *path = g_strdup_printf("%s/%s", tmpfs, filename); 274 275 unlink(path); 276 g_free(path); 277 } 278 279 static char *SocketAddress_to_str(SocketAddress *addr) 280 { 281 switch (addr->type) { 282 case SOCKET_ADDRESS_TYPE_INET: 283 return g_strdup_printf("tcp:%s:%s", 284 addr->u.inet.host, 285 addr->u.inet.port); 286 case SOCKET_ADDRESS_TYPE_UNIX: 287 return g_strdup_printf("unix:%s", 288 addr->u.q_unix.path); 289 case SOCKET_ADDRESS_TYPE_FD: 290 return g_strdup_printf("fd:%s", addr->u.fd.str); 291 case SOCKET_ADDRESS_TYPE_VSOCK: 292 return g_strdup_printf("tcp:%s:%s", 293 addr->u.vsock.cid, 294 addr->u.vsock.port); 295 default: 296 return g_strdup("unknown address type"); 297 } 298 } 299 300 static char *migrate_get_socket_address(QTestState *who, const char *parameter) 301 { 302 QDict *rsp; 303 char *result; 304 Error *local_err = NULL; 305 SocketAddressList *addrs; 306 Visitor *iv = NULL; 307 QObject *object; 308 309 rsp = migrate_query(who); 310 object = qdict_get(rsp, parameter); 311 312 iv = qobject_input_visitor_new(object); 313 visit_type_SocketAddressList(iv, NULL, &addrs, &local_err); 314 visit_free(iv); 315 316 /* we are only using a single address */ 317 result = SocketAddress_to_str(addrs->value); 318 319 qapi_free_SocketAddressList(addrs); 320 qobject_unref(rsp); 321 return result; 322 } 323 324 static long long migrate_get_parameter_int(QTestState *who, 325 const char *parameter) 326 { 327 QDict *rsp; 328 long long result; 329 330 rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); 331 result = qdict_get_int(rsp, parameter); 332 qobject_unref(rsp); 333 return result; 334 } 335 336 static void migrate_check_parameter_int(QTestState *who, const char *parameter, 337 long long value) 338 { 339 long long result; 340 341 result = migrate_get_parameter_int(who, parameter); 342 g_assert_cmpint(result, ==, value); 343 } 344 345 static void migrate_set_parameter_int(QTestState *who, const char *parameter, 346 long long value) 347 { 348 QDict *rsp; 349 350 rsp = qtest_qmp(who, 351 "{ 'execute': 'migrate-set-parameters'," 352 "'arguments': { %s: %lld } }", 353 parameter, value); 354 g_assert(qdict_haskey(rsp, "return")); 355 qobject_unref(rsp); 356 migrate_check_parameter_int(who, parameter, value); 357 } 358 359 static char *migrate_get_parameter_str(QTestState *who, 360 const char *parameter) 361 { 362 QDict *rsp; 363 char *result; 364 365 rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); 366 result = g_strdup(qdict_get_str(rsp, parameter)); 367 qobject_unref(rsp); 368 return result; 369 } 370 371 static void migrate_check_parameter_str(QTestState *who, const char *parameter, 372 const char *value) 373 { 374 char *result; 375 376 result = migrate_get_parameter_str(who, parameter); 377 g_assert_cmpstr(result, ==, value); 378 g_free(result); 379 } 380 381 __attribute__((unused)) 382 static void migrate_set_parameter_str(QTestState *who, const char *parameter, 383 const char *value) 384 { 385 QDict *rsp; 386 387 rsp = qtest_qmp(who, 388 "{ 'execute': 'migrate-set-parameters'," 389 "'arguments': { %s: %s } }", 390 parameter, value); 391 g_assert(qdict_haskey(rsp, "return")); 392 qobject_unref(rsp); 393 migrate_check_parameter_str(who, parameter, value); 394 } 395 396 static void migrate_pause(QTestState *who) 397 { 398 QDict *rsp; 399 400 rsp = wait_command(who, "{ 'execute': 'migrate-pause' }"); 401 qobject_unref(rsp); 402 } 403 404 static void migrate_continue(QTestState *who, const char *state) 405 { 406 QDict *rsp; 407 408 rsp = wait_command(who, 409 "{ 'execute': 'migrate-continue'," 410 " 'arguments': { 'state': %s } }", 411 state); 412 qobject_unref(rsp); 413 } 414 415 static void migrate_recover(QTestState *who, const char *uri) 416 { 417 QDict *rsp; 418 419 rsp = wait_command(who, 420 "{ 'execute': 'migrate-recover', " 421 " 'id': 'recover-cmd', " 422 " 'arguments': { 'uri': %s } }", 423 uri); 424 qobject_unref(rsp); 425 } 426 427 static void migrate_cancel(QTestState *who) 428 { 429 QDict *rsp; 430 431 rsp = wait_command(who, "{ 'execute': 'migrate_cancel' }"); 432 qobject_unref(rsp); 433 } 434 435 static void migrate_set_capability(QTestState *who, const char *capability, 436 bool value) 437 { 438 QDict *rsp; 439 440 rsp = qtest_qmp(who, 441 "{ 'execute': 'migrate-set-capabilities'," 442 "'arguments': { " 443 "'capabilities': [ { " 444 "'capability': %s, 'state': %i } ] } }", 445 capability, value); 446 g_assert(qdict_haskey(rsp, "return")); 447 qobject_unref(rsp); 448 } 449 450 static void migrate_postcopy_start(QTestState *from, QTestState *to) 451 { 452 QDict *rsp; 453 454 rsp = wait_command(from, "{ 'execute': 'migrate-start-postcopy' }"); 455 qobject_unref(rsp); 456 457 if (!got_stop) { 458 qtest_qmp_eventwait(from, "STOP"); 459 } 460 461 qtest_qmp_eventwait(to, "RESUME"); 462 } 463 464 typedef struct { 465 bool hide_stderr; 466 bool use_shmem; 467 /* only launch the target process */ 468 bool only_target; 469 char *opts_source; 470 char *opts_target; 471 } MigrateStart; 472 473 static MigrateStart *migrate_start_new(void) 474 { 475 MigrateStart *args = g_new0(MigrateStart, 1); 476 477 args->opts_source = g_strdup(""); 478 args->opts_target = g_strdup(""); 479 return args; 480 } 481 482 static void migrate_start_destroy(MigrateStart *args) 483 { 484 g_free(args->opts_source); 485 g_free(args->opts_target); 486 g_free(args); 487 } 488 489 static int test_migrate_start(QTestState **from, QTestState **to, 490 const char *uri, MigrateStart *args) 491 { 492 gchar *arch_source, *arch_target; 493 gchar *cmd_source, *cmd_target; 494 const gchar *ignore_stderr; 495 char *bootpath = NULL; 496 char *shmem_opts; 497 char *shmem_path; 498 const char *arch = qtest_get_arch(); 499 const char *machine_opts = NULL; 500 const char *memory_size; 501 502 if (args->use_shmem) { 503 if (!g_file_test("/dev/shm", G_FILE_TEST_IS_DIR)) { 504 g_test_skip("/dev/shm is not supported"); 505 return -1; 506 } 507 } 508 509 got_stop = false; 510 bootpath = g_strdup_printf("%s/bootsect", tmpfs); 511 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { 512 /* the assembled x86 boot sector should be exactly one sector large */ 513 assert(sizeof(x86_bootsect) == 512); 514 init_bootfile(bootpath, x86_bootsect, sizeof(x86_bootsect)); 515 memory_size = "150M"; 516 arch_source = g_strdup_printf("-drive file=%s,format=raw", bootpath); 517 arch_target = g_strdup(arch_source); 518 start_address = X86_TEST_MEM_START; 519 end_address = X86_TEST_MEM_END; 520 } else if (g_str_equal(arch, "s390x")) { 521 init_bootfile(bootpath, s390x_elf, sizeof(s390x_elf)); 522 memory_size = "128M"; 523 arch_source = g_strdup_printf("-bios %s", bootpath); 524 arch_target = g_strdup(arch_source); 525 start_address = S390_TEST_MEM_START; 526 end_address = S390_TEST_MEM_END; 527 } else if (strcmp(arch, "ppc64") == 0) { 528 machine_opts = "vsmt=8"; 529 memory_size = "256M"; 530 start_address = PPC_TEST_MEM_START; 531 end_address = PPC_TEST_MEM_END; 532 arch_source = g_strdup_printf("-nodefaults " 533 "-prom-env 'use-nvramrc?=true' -prom-env " 534 "'nvramrc=hex .\" _\" begin %x %x " 535 "do i c@ 1 + i c! 1000 +loop .\" B\" 0 " 536 "until'", end_address, start_address); 537 arch_target = g_strdup(""); 538 } else if (strcmp(arch, "aarch64") == 0) { 539 init_bootfile(bootpath, aarch64_kernel, sizeof(aarch64_kernel)); 540 machine_opts = "virt,gic-version=max"; 541 memory_size = "150M"; 542 arch_source = g_strdup_printf("-cpu max " 543 "-kernel %s", 544 bootpath); 545 arch_target = g_strdup(arch_source); 546 start_address = ARM_TEST_MEM_START; 547 end_address = ARM_TEST_MEM_END; 548 549 g_assert(sizeof(aarch64_kernel) <= ARM_TEST_MAX_KERNEL_SIZE); 550 } else { 551 g_assert_not_reached(); 552 } 553 554 g_free(bootpath); 555 556 if (args->hide_stderr) { 557 ignore_stderr = "2>/dev/null"; 558 } else { 559 ignore_stderr = ""; 560 } 561 562 if (args->use_shmem) { 563 shmem_path = g_strdup_printf("/dev/shm/qemu-%d", getpid()); 564 shmem_opts = g_strdup_printf( 565 "-object memory-backend-file,id=mem0,size=%s" 566 ",mem-path=%s,share=on -numa node,memdev=mem0", 567 memory_size, shmem_path); 568 } else { 569 shmem_path = NULL; 570 shmem_opts = g_strdup(""); 571 } 572 573 cmd_source = g_strdup_printf("-accel kvm -accel tcg%s%s " 574 "-name source,debug-threads=on " 575 "-m %s " 576 "-serial file:%s/src_serial " 577 "%s %s %s %s", 578 machine_opts ? " -machine " : "", 579 machine_opts ? machine_opts : "", 580 memory_size, tmpfs, 581 arch_source, shmem_opts, args->opts_source, 582 ignore_stderr); 583 g_free(arch_source); 584 if (!args->only_target) { 585 *from = qtest_init(cmd_source); 586 } 587 g_free(cmd_source); 588 589 cmd_target = g_strdup_printf("-accel kvm -accel tcg%s%s " 590 "-name target,debug-threads=on " 591 "-m %s " 592 "-serial file:%s/dest_serial " 593 "-incoming %s " 594 "%s %s %s %s", 595 machine_opts ? " -machine " : "", 596 machine_opts ? machine_opts : "", 597 memory_size, tmpfs, uri, 598 arch_target, shmem_opts, 599 args->opts_target, ignore_stderr); 600 g_free(arch_target); 601 *to = qtest_init(cmd_target); 602 g_free(cmd_target); 603 604 g_free(shmem_opts); 605 /* 606 * Remove shmem file immediately to avoid memory leak in test failed case. 607 * It's valid becase QEMU has already opened this file 608 */ 609 if (args->use_shmem) { 610 unlink(shmem_path); 611 g_free(shmem_path); 612 } 613 614 migrate_start_destroy(args); 615 return 0; 616 } 617 618 static void test_migrate_end(QTestState *from, QTestState *to, bool test_dest) 619 { 620 unsigned char dest_byte_a, dest_byte_b, dest_byte_c, dest_byte_d; 621 622 qtest_quit(from); 623 624 if (test_dest) { 625 qtest_memread(to, start_address, &dest_byte_a, 1); 626 627 /* Destination still running, wait for a byte to change */ 628 do { 629 qtest_memread(to, start_address, &dest_byte_b, 1); 630 usleep(1000 * 10); 631 } while (dest_byte_a == dest_byte_b); 632 633 qtest_qmp_discard_response(to, "{ 'execute' : 'stop'}"); 634 635 /* With it stopped, check nothing changes */ 636 qtest_memread(to, start_address, &dest_byte_c, 1); 637 usleep(1000 * 200); 638 qtest_memread(to, start_address, &dest_byte_d, 1); 639 g_assert_cmpint(dest_byte_c, ==, dest_byte_d); 640 641 check_guests_ram(to); 642 } 643 644 qtest_quit(to); 645 646 cleanup("bootsect"); 647 cleanup("migsocket"); 648 cleanup("src_serial"); 649 cleanup("dest_serial"); 650 } 651 652 static void deprecated_set_downtime(QTestState *who, const double value) 653 { 654 QDict *rsp; 655 656 rsp = qtest_qmp(who, 657 "{ 'execute': 'migrate_set_downtime'," 658 " 'arguments': { 'value': %f } }", value); 659 g_assert(qdict_haskey(rsp, "return")); 660 qobject_unref(rsp); 661 migrate_check_parameter_int(who, "downtime-limit", value * 1000); 662 } 663 664 static void deprecated_set_speed(QTestState *who, long long value) 665 { 666 QDict *rsp; 667 668 rsp = qtest_qmp(who, "{ 'execute': 'migrate_set_speed'," 669 "'arguments': { 'value': %lld } }", value); 670 g_assert(qdict_haskey(rsp, "return")); 671 qobject_unref(rsp); 672 migrate_check_parameter_int(who, "max-bandwidth", value); 673 } 674 675 static void deprecated_set_cache_size(QTestState *who, long long value) 676 { 677 QDict *rsp; 678 679 rsp = qtest_qmp(who, "{ 'execute': 'migrate-set-cache-size'," 680 "'arguments': { 'value': %lld } }", value); 681 g_assert(qdict_haskey(rsp, "return")); 682 qobject_unref(rsp); 683 migrate_check_parameter_int(who, "xbzrle-cache-size", value); 684 } 685 686 static void test_deprecated(void) 687 { 688 QTestState *from; 689 690 from = qtest_init("-machine none"); 691 692 deprecated_set_downtime(from, 0.12345); 693 deprecated_set_speed(from, 12345); 694 deprecated_set_cache_size(from, 4096); 695 696 qtest_quit(from); 697 } 698 699 static int migrate_postcopy_prepare(QTestState **from_ptr, 700 QTestState **to_ptr, 701 MigrateStart *args) 702 { 703 char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); 704 QTestState *from, *to; 705 706 if (test_migrate_start(&from, &to, uri, args)) { 707 return -1; 708 } 709 710 migrate_set_capability(from, "postcopy-ram", true); 711 migrate_set_capability(to, "postcopy-ram", true); 712 migrate_set_capability(to, "postcopy-blocktime", true); 713 714 /* We want to pick a speed slow enough that the test completes 715 * quickly, but that it doesn't complete precopy even on a slow 716 * machine, so also set the downtime. 717 */ 718 migrate_set_parameter_int(from, "max-bandwidth", 30000000); 719 migrate_set_parameter_int(from, "downtime-limit", 1); 720 721 /* Wait for the first serial output from the source */ 722 wait_for_serial("src_serial"); 723 724 migrate_qmp(from, uri, "{}"); 725 g_free(uri); 726 727 wait_for_migration_pass(from); 728 729 *from_ptr = from; 730 *to_ptr = to; 731 732 return 0; 733 } 734 735 static void migrate_postcopy_complete(QTestState *from, QTestState *to) 736 { 737 wait_for_migration_complete(from); 738 739 /* Make sure we get at least one "B" on destination */ 740 wait_for_serial("dest_serial"); 741 742 if (uffd_feature_thread_id) { 743 read_blocktime(to); 744 } 745 746 test_migrate_end(from, to, true); 747 } 748 749 static void test_postcopy(void) 750 { 751 MigrateStart *args = migrate_start_new(); 752 QTestState *from, *to; 753 754 if (migrate_postcopy_prepare(&from, &to, args)) { 755 return; 756 } 757 migrate_postcopy_start(from, to); 758 migrate_postcopy_complete(from, to); 759 } 760 761 static void test_postcopy_recovery(void) 762 { 763 MigrateStart *args = migrate_start_new(); 764 QTestState *from, *to; 765 char *uri; 766 767 args->hide_stderr = true; 768 769 if (migrate_postcopy_prepare(&from, &to, args)) { 770 return; 771 } 772 773 /* Turn postcopy speed down, 4K/s is slow enough on any machines */ 774 migrate_set_parameter_int(from, "max-postcopy-bandwidth", 4096); 775 776 /* Now we start the postcopy */ 777 migrate_postcopy_start(from, to); 778 779 /* 780 * Wait until postcopy is really started; we can only run the 781 * migrate-pause command during a postcopy 782 */ 783 wait_for_migration_status(from, "postcopy-active", NULL); 784 785 /* 786 * Manually stop the postcopy migration. This emulates a network 787 * failure with the migration socket 788 */ 789 migrate_pause(from); 790 791 /* 792 * Wait for destination side to reach postcopy-paused state. The 793 * migrate-recover command can only succeed if destination machine 794 * is in the paused state 795 */ 796 wait_for_migration_status(to, "postcopy-paused", 797 (const char * []) { "failed", "active", 798 "completed", NULL }); 799 800 /* 801 * Create a new socket to emulate a new channel that is different 802 * from the broken migration channel; tell the destination to 803 * listen to the new port 804 */ 805 uri = g_strdup_printf("unix:%s/migsocket-recover", tmpfs); 806 migrate_recover(to, uri); 807 808 /* 809 * Try to rebuild the migration channel using the resume flag and 810 * the newly created channel 811 */ 812 wait_for_migration_status(from, "postcopy-paused", 813 (const char * []) { "failed", "active", 814 "completed", NULL }); 815 migrate_qmp(from, uri, "{'resume': true}"); 816 g_free(uri); 817 818 /* Restore the postcopy bandwidth to unlimited */ 819 migrate_set_parameter_int(from, "max-postcopy-bandwidth", 0); 820 821 migrate_postcopy_complete(from, to); 822 } 823 824 static void test_baddest(void) 825 { 826 MigrateStart *args = migrate_start_new(); 827 QTestState *from, *to; 828 829 args->hide_stderr = true; 830 831 if (test_migrate_start(&from, &to, "tcp:0:0", args)) { 832 return; 833 } 834 migrate_qmp(from, "tcp:0:0", "{}"); 835 wait_for_migration_fail(from, false); 836 test_migrate_end(from, to, false); 837 } 838 839 static void test_precopy_unix(void) 840 { 841 char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); 842 MigrateStart *args = migrate_start_new(); 843 QTestState *from, *to; 844 845 if (test_migrate_start(&from, &to, uri, args)) { 846 return; 847 } 848 849 /* We want to pick a speed slow enough that the test completes 850 * quickly, but that it doesn't complete precopy even on a slow 851 * machine, so also set the downtime. 852 */ 853 /* 1 ms should make it not converge*/ 854 migrate_set_parameter_int(from, "downtime-limit", 1); 855 /* 1GB/s */ 856 migrate_set_parameter_int(from, "max-bandwidth", 1000000000); 857 858 /* Wait for the first serial output from the source */ 859 wait_for_serial("src_serial"); 860 861 migrate_qmp(from, uri, "{}"); 862 863 wait_for_migration_pass(from); 864 865 /* 300 ms should converge */ 866 migrate_set_parameter_int(from, "downtime-limit", 300); 867 868 if (!got_stop) { 869 qtest_qmp_eventwait(from, "STOP"); 870 } 871 872 qtest_qmp_eventwait(to, "RESUME"); 873 874 wait_for_serial("dest_serial"); 875 wait_for_migration_complete(from); 876 877 test_migrate_end(from, to, true); 878 g_free(uri); 879 } 880 881 #if 0 882 /* Currently upset on aarch64 TCG */ 883 static void test_ignore_shared(void) 884 { 885 char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); 886 QTestState *from, *to; 887 888 if (test_migrate_start(&from, &to, uri, false, true, NULL, NULL)) { 889 return; 890 } 891 892 migrate_set_capability(from, "x-ignore-shared", true); 893 migrate_set_capability(to, "x-ignore-shared", true); 894 895 /* Wait for the first serial output from the source */ 896 wait_for_serial("src_serial"); 897 898 migrate_qmp(from, uri, "{}"); 899 900 wait_for_migration_pass(from); 901 902 if (!got_stop) { 903 qtest_qmp_eventwait(from, "STOP"); 904 } 905 906 qtest_qmp_eventwait(to, "RESUME"); 907 908 wait_for_serial("dest_serial"); 909 wait_for_migration_complete(from); 910 911 /* Check whether shared RAM has been really skipped */ 912 g_assert_cmpint(read_ram_property_int(from, "transferred"), <, 1024 * 1024); 913 914 test_migrate_end(from, to, true); 915 g_free(uri); 916 } 917 #endif 918 919 static void test_xbzrle(const char *uri) 920 { 921 MigrateStart *args = migrate_start_new(); 922 QTestState *from, *to; 923 924 if (test_migrate_start(&from, &to, uri, args)) { 925 return; 926 } 927 928 /* 929 * We want to pick a speed slow enough that the test completes 930 * quickly, but that it doesn't complete precopy even on a slow 931 * machine, so also set the downtime. 932 */ 933 /* 1 ms should make it not converge*/ 934 migrate_set_parameter_int(from, "downtime-limit", 1); 935 /* 1GB/s */ 936 migrate_set_parameter_int(from, "max-bandwidth", 1000000000); 937 938 migrate_set_parameter_int(from, "xbzrle-cache-size", 33554432); 939 940 migrate_set_capability(from, "xbzrle", "true"); 941 migrate_set_capability(to, "xbzrle", "true"); 942 /* Wait for the first serial output from the source */ 943 wait_for_serial("src_serial"); 944 945 migrate_qmp(from, uri, "{}"); 946 947 wait_for_migration_pass(from); 948 949 /* 300ms should converge */ 950 migrate_set_parameter_int(from, "downtime-limit", 300); 951 952 if (!got_stop) { 953 qtest_qmp_eventwait(from, "STOP"); 954 } 955 qtest_qmp_eventwait(to, "RESUME"); 956 957 wait_for_serial("dest_serial"); 958 wait_for_migration_complete(from); 959 960 test_migrate_end(from, to, true); 961 } 962 963 static void test_xbzrle_unix(void) 964 { 965 char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); 966 967 test_xbzrle(uri); 968 g_free(uri); 969 } 970 971 static void test_precopy_tcp(void) 972 { 973 MigrateStart *args = migrate_start_new(); 974 char *uri; 975 QTestState *from, *to; 976 977 if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", args)) { 978 return; 979 } 980 981 /* 982 * We want to pick a speed slow enough that the test completes 983 * quickly, but that it doesn't complete precopy even on a slow 984 * machine, so also set the downtime. 985 */ 986 /* 1 ms should make it not converge*/ 987 migrate_set_parameter_int(from, "downtime-limit", 1); 988 /* 1GB/s */ 989 migrate_set_parameter_int(from, "max-bandwidth", 1000000000); 990 991 /* Wait for the first serial output from the source */ 992 wait_for_serial("src_serial"); 993 994 uri = migrate_get_socket_address(to, "socket-address"); 995 996 migrate_qmp(from, uri, "{}"); 997 998 wait_for_migration_pass(from); 999 1000 /* 300ms should converge */ 1001 migrate_set_parameter_int(from, "downtime-limit", 300); 1002 1003 if (!got_stop) { 1004 qtest_qmp_eventwait(from, "STOP"); 1005 } 1006 qtest_qmp_eventwait(to, "RESUME"); 1007 1008 wait_for_serial("dest_serial"); 1009 wait_for_migration_complete(from); 1010 1011 test_migrate_end(from, to, true); 1012 g_free(uri); 1013 } 1014 1015 static void test_migrate_fd_proto(void) 1016 { 1017 MigrateStart *args = migrate_start_new(); 1018 QTestState *from, *to; 1019 int ret; 1020 int pair[2]; 1021 QDict *rsp; 1022 const char *error_desc; 1023 1024 if (test_migrate_start(&from, &to, "defer", args)) { 1025 return; 1026 } 1027 1028 /* 1029 * We want to pick a speed slow enough that the test completes 1030 * quickly, but that it doesn't complete precopy even on a slow 1031 * machine, so also set the downtime. 1032 */ 1033 /* 1 ms should make it not converge */ 1034 migrate_set_parameter_int(from, "downtime-limit", 1); 1035 /* 1GB/s */ 1036 migrate_set_parameter_int(from, "max-bandwidth", 1000000000); 1037 1038 /* Wait for the first serial output from the source */ 1039 wait_for_serial("src_serial"); 1040 1041 /* Create two connected sockets for migration */ 1042 ret = socketpair(PF_LOCAL, SOCK_STREAM, 0, pair); 1043 g_assert_cmpint(ret, ==, 0); 1044 1045 /* Send the 1st socket to the target */ 1046 rsp = wait_command_fd(to, pair[0], 1047 "{ 'execute': 'getfd'," 1048 " 'arguments': { 'fdname': 'fd-mig' }}"); 1049 qobject_unref(rsp); 1050 close(pair[0]); 1051 1052 /* Start incoming migration from the 1st socket */ 1053 rsp = wait_command(to, "{ 'execute': 'migrate-incoming'," 1054 " 'arguments': { 'uri': 'fd:fd-mig' }}"); 1055 qobject_unref(rsp); 1056 1057 /* Send the 2nd socket to the target */ 1058 rsp = wait_command_fd(from, pair[1], 1059 "{ 'execute': 'getfd'," 1060 " 'arguments': { 'fdname': 'fd-mig' }}"); 1061 qobject_unref(rsp); 1062 close(pair[1]); 1063 1064 /* Start migration to the 2nd socket*/ 1065 migrate_qmp(from, "fd:fd-mig", "{}"); 1066 1067 wait_for_migration_pass(from); 1068 1069 /* 300ms should converge */ 1070 migrate_set_parameter_int(from, "downtime-limit", 300); 1071 1072 if (!got_stop) { 1073 qtest_qmp_eventwait(from, "STOP"); 1074 } 1075 qtest_qmp_eventwait(to, "RESUME"); 1076 1077 /* Test closing fds */ 1078 /* We assume, that QEMU removes named fd from its list, 1079 * so this should fail */ 1080 rsp = qtest_qmp(from, "{ 'execute': 'closefd'," 1081 " 'arguments': { 'fdname': 'fd-mig' }}"); 1082 g_assert_true(qdict_haskey(rsp, "error")); 1083 error_desc = qdict_get_str(qdict_get_qdict(rsp, "error"), "desc"); 1084 g_assert_cmpstr(error_desc, ==, "File descriptor named 'fd-mig' not found"); 1085 qobject_unref(rsp); 1086 1087 rsp = qtest_qmp(to, "{ 'execute': 'closefd'," 1088 " 'arguments': { 'fdname': 'fd-mig' }}"); 1089 g_assert_true(qdict_haskey(rsp, "error")); 1090 error_desc = qdict_get_str(qdict_get_qdict(rsp, "error"), "desc"); 1091 g_assert_cmpstr(error_desc, ==, "File descriptor named 'fd-mig' not found"); 1092 qobject_unref(rsp); 1093 1094 /* Complete migration */ 1095 wait_for_serial("dest_serial"); 1096 wait_for_migration_complete(from); 1097 test_migrate_end(from, to, true); 1098 } 1099 1100 static void do_test_validate_uuid(MigrateStart *args, bool should_fail) 1101 { 1102 char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); 1103 QTestState *from, *to; 1104 1105 if (test_migrate_start(&from, &to, uri, args)) { 1106 return; 1107 } 1108 1109 /* 1110 * UUID validation is at the begin of migration. So, the main process of 1111 * migration is not interesting for us here. Thus, set huge downtime for 1112 * very fast migration. 1113 */ 1114 migrate_set_parameter_int(from, "downtime-limit", 1000000); 1115 migrate_set_capability(from, "validate-uuid", true); 1116 1117 /* Wait for the first serial output from the source */ 1118 wait_for_serial("src_serial"); 1119 1120 migrate_qmp(from, uri, "{}"); 1121 1122 if (should_fail) { 1123 qtest_set_expected_status(to, 1); 1124 wait_for_migration_fail(from, true); 1125 } else { 1126 wait_for_migration_complete(from); 1127 } 1128 1129 test_migrate_end(from, to, false); 1130 g_free(uri); 1131 } 1132 1133 static void test_validate_uuid(void) 1134 { 1135 MigrateStart *args = migrate_start_new(); 1136 1137 args->opts_source = g_strdup("-uuid 11111111-1111-1111-1111-111111111111"); 1138 args->opts_target = g_strdup("-uuid 11111111-1111-1111-1111-111111111111"); 1139 do_test_validate_uuid(args, false); 1140 } 1141 1142 static void test_validate_uuid_error(void) 1143 { 1144 MigrateStart *args = migrate_start_new(); 1145 1146 args->opts_source = g_strdup("-uuid 11111111-1111-1111-1111-111111111111"); 1147 args->opts_target = g_strdup("-uuid 22222222-2222-2222-2222-222222222222"); 1148 args->hide_stderr = true; 1149 do_test_validate_uuid(args, true); 1150 } 1151 1152 static void test_validate_uuid_src_not_set(void) 1153 { 1154 MigrateStart *args = migrate_start_new(); 1155 1156 args->opts_target = g_strdup("-uuid 22222222-2222-2222-2222-222222222222"); 1157 args->hide_stderr = true; 1158 do_test_validate_uuid(args, false); 1159 } 1160 1161 static void test_validate_uuid_dst_not_set(void) 1162 { 1163 MigrateStart *args = migrate_start_new(); 1164 1165 args->opts_source = g_strdup("-uuid 11111111-1111-1111-1111-111111111111"); 1166 args->hide_stderr = true; 1167 do_test_validate_uuid(args, false); 1168 } 1169 1170 static void test_migrate_auto_converge(void) 1171 { 1172 char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); 1173 MigrateStart *args = migrate_start_new(); 1174 QTestState *from, *to; 1175 int64_t remaining, percentage; 1176 1177 /* 1178 * We want the test to be stable and as fast as possible. 1179 * E.g., with 1Gb/s bandwith migration may pass without throttling, 1180 * so we need to decrease a bandwidth. 1181 */ 1182 const int64_t init_pct = 5, inc_pct = 50, max_pct = 95; 1183 const int64_t max_bandwidth = 400000000; /* ~400Mb/s */ 1184 const int64_t downtime_limit = 250; /* 250ms */ 1185 /* 1186 * We migrate through unix-socket (> 500Mb/s). 1187 * Thus, expected migration speed ~= bandwidth limit (< 500Mb/s). 1188 * So, we can predict expected_threshold 1189 */ 1190 const int64_t expected_threshold = max_bandwidth * downtime_limit / 1000; 1191 1192 if (test_migrate_start(&from, &to, uri, args)) { 1193 return; 1194 } 1195 1196 migrate_set_capability(from, "auto-converge", true); 1197 migrate_set_parameter_int(from, "cpu-throttle-initial", init_pct); 1198 migrate_set_parameter_int(from, "cpu-throttle-increment", inc_pct); 1199 migrate_set_parameter_int(from, "max-cpu-throttle", max_pct); 1200 1201 /* 1202 * Set the initial parameters so that the migration could not converge 1203 * without throttling. 1204 */ 1205 migrate_set_parameter_int(from, "downtime-limit", 1); 1206 migrate_set_parameter_int(from, "max-bandwidth", 100000000); /* ~100Mb/s */ 1207 1208 /* To check remaining size after precopy */ 1209 migrate_set_capability(from, "pause-before-switchover", true); 1210 1211 /* Wait for the first serial output from the source */ 1212 wait_for_serial("src_serial"); 1213 1214 migrate_qmp(from, uri, "{}"); 1215 1216 /* Wait for throttling begins */ 1217 percentage = 0; 1218 while (percentage == 0) { 1219 percentage = read_migrate_property_int(from, "cpu-throttle-percentage"); 1220 usleep(100); 1221 g_assert_false(got_stop); 1222 } 1223 /* The first percentage of throttling should be equal to init_pct */ 1224 g_assert_cmpint(percentage, ==, init_pct); 1225 /* Now, when we tested that throttling works, let it converge */ 1226 migrate_set_parameter_int(from, "downtime-limit", downtime_limit); 1227 migrate_set_parameter_int(from, "max-bandwidth", max_bandwidth); 1228 1229 /* 1230 * Wait for pre-switchover status to check last throttle percentage 1231 * and remaining. These values will be zeroed later 1232 */ 1233 wait_for_migration_status(from, "pre-switchover", NULL); 1234 1235 /* The final percentage of throttling shouldn't be greater than max_pct */ 1236 percentage = read_migrate_property_int(from, "cpu-throttle-percentage"); 1237 g_assert_cmpint(percentage, <=, max_pct); 1238 1239 remaining = read_ram_property_int(from, "remaining"); 1240 g_assert_cmpint(remaining, <, expected_threshold); 1241 1242 migrate_continue(from, "pre-switchover"); 1243 1244 qtest_qmp_eventwait(to, "RESUME"); 1245 1246 wait_for_serial("dest_serial"); 1247 wait_for_migration_complete(from); 1248 1249 g_free(uri); 1250 1251 test_migrate_end(from, to, true); 1252 } 1253 1254 static void test_multifd_tcp(void) 1255 { 1256 MigrateStart *args = migrate_start_new(); 1257 QTestState *from, *to; 1258 QDict *rsp; 1259 char *uri; 1260 1261 if (test_migrate_start(&from, &to, "defer", args)) { 1262 return; 1263 } 1264 1265 /* 1266 * We want to pick a speed slow enough that the test completes 1267 * quickly, but that it doesn't complete precopy even on a slow 1268 * machine, so also set the downtime. 1269 */ 1270 /* 1 ms should make it not converge*/ 1271 migrate_set_parameter_int(from, "downtime-limit", 1); 1272 /* 1GB/s */ 1273 migrate_set_parameter_int(from, "max-bandwidth", 1000000000); 1274 1275 migrate_set_parameter_int(from, "multifd-channels", 16); 1276 migrate_set_parameter_int(to, "multifd-channels", 16); 1277 1278 migrate_set_capability(from, "multifd", "true"); 1279 migrate_set_capability(to, "multifd", "true"); 1280 1281 /* Start incoming migration from the 1st socket */ 1282 rsp = wait_command(to, "{ 'execute': 'migrate-incoming'," 1283 " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}"); 1284 qobject_unref(rsp); 1285 1286 /* Wait for the first serial output from the source */ 1287 wait_for_serial("src_serial"); 1288 1289 uri = migrate_get_socket_address(to, "socket-address"); 1290 1291 migrate_qmp(from, uri, "{}"); 1292 1293 wait_for_migration_pass(from); 1294 1295 /* 300ms it should converge */ 1296 migrate_set_parameter_int(from, "downtime-limit", 300); 1297 1298 if (!got_stop) { 1299 qtest_qmp_eventwait(from, "STOP"); 1300 } 1301 qtest_qmp_eventwait(to, "RESUME"); 1302 1303 wait_for_serial("dest_serial"); 1304 wait_for_migration_complete(from); 1305 test_migrate_end(from, to, true); 1306 g_free(uri); 1307 } 1308 1309 /* 1310 * This test does: 1311 * source target 1312 * migrate_incoming 1313 * migrate 1314 * migrate_cancel 1315 * launch another target 1316 * migrate 1317 * 1318 * And see that it works 1319 */ 1320 1321 static void test_multifd_tcp_cancel(void) 1322 { 1323 MigrateStart *args = migrate_start_new(); 1324 QTestState *from, *to, *to2; 1325 QDict *rsp; 1326 char *uri; 1327 1328 args->hide_stderr = true; 1329 1330 if (test_migrate_start(&from, &to, "defer", args)) { 1331 return; 1332 } 1333 1334 /* 1335 * We want to pick a speed slow enough that the test completes 1336 * quickly, but that it doesn't complete precopy even on a slow 1337 * machine, so also set the downtime. 1338 */ 1339 /* 1 ms should make it not converge*/ 1340 migrate_set_parameter_int(from, "downtime-limit", 1); 1341 /* 300MB/s */ 1342 migrate_set_parameter_int(from, "max-bandwidth", 30000000); 1343 1344 migrate_set_parameter_int(from, "multifd-channels", 16); 1345 migrate_set_parameter_int(to, "multifd-channels", 16); 1346 1347 migrate_set_capability(from, "multifd", "true"); 1348 migrate_set_capability(to, "multifd", "true"); 1349 1350 /* Start incoming migration from the 1st socket */ 1351 rsp = wait_command(to, "{ 'execute': 'migrate-incoming'," 1352 " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}"); 1353 qobject_unref(rsp); 1354 1355 /* Wait for the first serial output from the source */ 1356 wait_for_serial("src_serial"); 1357 1358 uri = migrate_get_socket_address(to, "socket-address"); 1359 1360 migrate_qmp(from, uri, "{}"); 1361 1362 wait_for_migration_pass(from); 1363 1364 migrate_cancel(from); 1365 1366 args = migrate_start_new(); 1367 args->only_target = true; 1368 1369 if (test_migrate_start(&from, &to2, "defer", args)) { 1370 return; 1371 } 1372 1373 migrate_set_parameter_int(to2, "multifd-channels", 16); 1374 1375 migrate_set_capability(to2, "multifd", "true"); 1376 1377 /* Start incoming migration from the 1st socket */ 1378 rsp = wait_command(to2, "{ 'execute': 'migrate-incoming'," 1379 " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}"); 1380 qobject_unref(rsp); 1381 1382 uri = migrate_get_socket_address(to2, "socket-address"); 1383 1384 wait_for_migration_status(from, "cancelled", NULL); 1385 1386 /* 300ms it should converge */ 1387 migrate_set_parameter_int(from, "downtime-limit", 300); 1388 /* 1GB/s */ 1389 migrate_set_parameter_int(from, "max-bandwidth", 1000000000); 1390 1391 migrate_qmp(from, uri, "{}"); 1392 1393 wait_for_migration_pass(from); 1394 1395 if (!got_stop) { 1396 qtest_qmp_eventwait(from, "STOP"); 1397 } 1398 qtest_qmp_eventwait(to2, "RESUME"); 1399 1400 wait_for_serial("dest_serial"); 1401 wait_for_migration_complete(from); 1402 test_migrate_end(from, to2, true); 1403 g_free(uri); 1404 } 1405 1406 int main(int argc, char **argv) 1407 { 1408 char template[] = "/tmp/migration-test-XXXXXX"; 1409 int ret; 1410 1411 g_test_init(&argc, &argv, NULL); 1412 1413 if (!ufd_version_check()) { 1414 return g_test_run(); 1415 } 1416 1417 /* 1418 * On ppc64, the test only works with kvm-hv, but not with kvm-pr and TCG 1419 * is touchy due to race conditions on dirty bits (especially on PPC for 1420 * some reason) 1421 */ 1422 if (g_str_equal(qtest_get_arch(), "ppc64") && 1423 (access("/sys/module/kvm_hv", F_OK) || 1424 access("/dev/kvm", R_OK | W_OK))) { 1425 g_test_message("Skipping test: kvm_hv not available"); 1426 return g_test_run(); 1427 } 1428 1429 /* 1430 * Similar to ppc64, s390x seems to be touchy with TCG, so disable it 1431 * there until the problems are resolved 1432 */ 1433 if (g_str_equal(qtest_get_arch(), "s390x")) { 1434 #if defined(HOST_S390X) 1435 if (access("/dev/kvm", R_OK | W_OK)) { 1436 g_test_message("Skipping test: kvm not available"); 1437 return g_test_run(); 1438 } 1439 #else 1440 g_test_message("Skipping test: Need s390x host to work properly"); 1441 return g_test_run(); 1442 #endif 1443 } 1444 1445 tmpfs = mkdtemp(template); 1446 if (!tmpfs) { 1447 g_test_message("mkdtemp on path (%s): %s", template, strerror(errno)); 1448 } 1449 g_assert(tmpfs); 1450 1451 module_call_init(MODULE_INIT_QOM); 1452 1453 qtest_add_func("/migration/postcopy/unix", test_postcopy); 1454 qtest_add_func("/migration/postcopy/recovery", test_postcopy_recovery); 1455 qtest_add_func("/migration/deprecated", test_deprecated); 1456 qtest_add_func("/migration/bad_dest", test_baddest); 1457 qtest_add_func("/migration/precopy/unix", test_precopy_unix); 1458 qtest_add_func("/migration/precopy/tcp", test_precopy_tcp); 1459 /* qtest_add_func("/migration/ignore_shared", test_ignore_shared); */ 1460 qtest_add_func("/migration/xbzrle/unix", test_xbzrle_unix); 1461 qtest_add_func("/migration/fd_proto", test_migrate_fd_proto); 1462 qtest_add_func("/migration/validate_uuid", test_validate_uuid); 1463 qtest_add_func("/migration/validate_uuid_error", test_validate_uuid_error); 1464 qtest_add_func("/migration/validate_uuid_src_not_set", 1465 test_validate_uuid_src_not_set); 1466 qtest_add_func("/migration/validate_uuid_dst_not_set", 1467 test_validate_uuid_dst_not_set); 1468 1469 qtest_add_func("/migration/auto_converge", test_migrate_auto_converge); 1470 qtest_add_func("/migration/multifd/tcp", test_multifd_tcp); 1471 qtest_add_func("/migration/multifd/tcp/cancel", test_multifd_tcp_cancel); 1472 1473 ret = g_test_run(); 1474 1475 g_assert_cmpint(ret, ==, 0); 1476 1477 ret = rmdir(tmpfs); 1478 if (ret != 0) { 1479 g_test_message("unable to rmdir: path (%s): %s", 1480 tmpfs, strerror(errno)); 1481 } 1482 1483 return ret; 1484 } 1485