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