2 * QTest testcase for migration
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.
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.
13 #include "qemu/osdep.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 #include "crypto/tlscredspsk.h"
27 #include "qapi/qmp/qlist.h"
29 #include "migration-helpers.h"
30 #include "tests/migration/migration-test.h"
32 # include "tests/unit/crypto-tls-psk-helpers.h"
34 # include "tests/unit/crypto-tls-x509-helpers.h"
35 # endif /* CONFIG_TASN1 */
36 #endif /* CONFIG_GNUTLS */
38 /* For dirty ring test; so far only x86_64 is supported */
39 #if defined(__linux__) && defined(HOST_X86_64)
40 #include "linux/kvm.h"
43 unsigned start_address
;
45 static bool uffd_feature_thread_id
;
46 static bool got_src_stop
;
47 static bool got_dst_resume
;
50 * An initial 3 MB offset is used as that corresponds
51 * to ~1 sec of data transfer with our bandwidth setting.
53 #define MAGIC_OFFSET_BASE (3 * 1024 * 1024)
55 * A further 1k is added to ensure we're not a multiple
56 * of TEST_MEM_PAGE_SIZE, thus avoid clash with writes
57 * from the migration guest workload.
59 #define MAGIC_OFFSET_SHUFFLE 1024
60 #define MAGIC_OFFSET (MAGIC_OFFSET_BASE + MAGIC_OFFSET_SHUFFLE)
61 #define MAGIC_MARKER 0xFEED12345678CAFEULL
64 * Dirtylimit stop working if dirty page rate error
65 * value less than DIRTYLIMIT_TOLERANCE_RANGE
67 #define DIRTYLIMIT_TOLERANCE_RANGE 25 /* MB/s */
69 #define ANALYZE_SCRIPT "scripts/analyze-migration.py"
71 #define QEMU_VM_FILE_MAGIC 0x5145564d
72 #define FILE_TEST_FILENAME "migfile"
73 #define FILE_TEST_OFFSET 0x1000
74 #define QEMU_ENV_SRC "QTEST_QEMU_BINARY_SRC"
75 #define QEMU_ENV_DST "QTEST_QEMU_BINARY_DST"
77 #if defined(__linux__)
78 #include <sys/syscall.h>
82 #if defined(__linux__) && defined(__NR_userfaultfd) && defined(CONFIG_EVENTFD)
83 #include <sys/eventfd.h>
84 #include <sys/ioctl.h>
85 #include "qemu/userfaultfd.h"
87 static bool ufd_version_check(void)
89 struct uffdio_api api_struct
;
92 int ufd
= uffd_open(O_CLOEXEC
);
95 g_test_message("Skipping test: userfaultfd not available");
99 api_struct
.api
= UFFD_API
;
100 api_struct
.features
= 0;
101 if (ioctl(ufd
, UFFDIO_API
, &api_struct
)) {
102 g_test_message("Skipping test: UFFDIO_API failed");
105 uffd_feature_thread_id
= api_struct
.features
& UFFD_FEATURE_THREAD_ID
;
107 ioctl_mask
= (__u64
)1 << _UFFDIO_REGISTER
|
108 (__u64
)1 << _UFFDIO_UNREGISTER
;
109 if ((api_struct
.ioctls
& ioctl_mask
) != ioctl_mask
) {
110 g_test_message("Skipping test: Missing userfault feature");
118 static bool ufd_version_check(void)
120 g_test_message("Skipping test: Userfault not available (builtdtime)");
127 static char *bootpath
;
129 /* The boot file modifies memory area in [start_address, end_address)
130 * repeatedly. It outputs a 'B' at a fixed rate while it's still running.
132 #include "tests/migration/i386/a-b-bootblock.h"
133 #include "tests/migration/aarch64/a-b-kernel.h"
134 #include "tests/migration/s390x/a-b-bios.h"
136 static void bootfile_create(char *dir
)
138 const char *arch
= qtest_get_arch();
139 unsigned char *content
;
142 bootpath
= g_strdup_printf("%s/bootsect", dir
);
143 if (strcmp(arch
, "i386") == 0 || strcmp(arch
, "x86_64") == 0) {
144 /* the assembled x86 boot sector should be exactly one sector large */
145 g_assert(sizeof(x86_bootsect
) == 512);
146 content
= x86_bootsect
;
147 len
= sizeof(x86_bootsect
);
148 } else if (g_str_equal(arch
, "s390x")) {
150 len
= sizeof(s390x_elf
);
151 } else if (strcmp(arch
, "ppc64") == 0) {
153 * sane architectures can be programmed at the boot prompt
156 } else if (strcmp(arch
, "aarch64") == 0) {
157 content
= aarch64_kernel
;
158 len
= sizeof(aarch64_kernel
);
159 g_assert(sizeof(aarch64_kernel
) <= ARM_TEST_MAX_KERNEL_SIZE
);
161 g_assert_not_reached();
164 FILE *bootfile
= fopen(bootpath
, "wb");
166 g_assert_cmpint(fwrite(content
, len
, 1, bootfile
), ==, 1);
170 static void bootfile_delete(void)
178 * Wait for some output in the serial output file,
179 * we get an 'A' followed by an endless string of 'B's
180 * but on the destination we won't have the A.
182 static void wait_for_serial(const char *side
)
184 g_autofree
char *serialpath
= g_strdup_printf("%s/%s", tmpfs
, side
);
185 FILE *serialfile
= fopen(serialpath
, "r");
186 const char *arch
= qtest_get_arch();
187 int started
= (strcmp(side
, "src_serial") == 0 &&
188 strcmp(arch
, "ppc64") == 0) ? 0 : 1;
191 int readvalue
= fgetc(serialfile
);
194 /* SLOF prints its banner before starting test,
195 * to ignore it, mark the start of the test with '_',
196 * ignore all characters until this marker
203 fseek(serialfile
, 0, SEEK_SET
);
220 started
= (strcmp(side
, "src_serial") == 0 &&
221 strcmp(arch
, "ppc64") == 0) ? 0 : 1;
222 fseek(serialfile
, 0, SEEK_SET
);
227 fprintf(stderr
, "Unexpected %d on %s serial\n", readvalue
, side
);
228 g_assert_not_reached();
234 * It's tricky to use qemu's migration event capability with qtest,
235 * events suddenly appearing confuse the qmp()/hmp() responses.
238 static int64_t read_ram_property_int(QTestState
*who
, const char *property
)
240 QDict
*rsp_return
, *rsp_ram
;
243 rsp_return
= migrate_query_not_failed(who
);
244 if (!qdict_haskey(rsp_return
, "ram")) {
248 rsp_ram
= qdict_get_qdict(rsp_return
, "ram");
249 result
= qdict_get_try_int(rsp_ram
, property
, 0);
251 qobject_unref(rsp_return
);
255 static int64_t read_migrate_property_int(QTestState
*who
, const char *property
)
260 rsp_return
= migrate_query_not_failed(who
);
261 result
= qdict_get_try_int(rsp_return
, property
, 0);
262 qobject_unref(rsp_return
);
266 static uint64_t get_migration_pass(QTestState
*who
)
268 return read_ram_property_int(who
, "dirty-sync-count");
271 static void read_blocktime(QTestState
*who
)
275 rsp_return
= migrate_query_not_failed(who
);
276 g_assert(qdict_haskey(rsp_return
, "postcopy-blocktime"));
277 qobject_unref(rsp_return
);
280 static void wait_for_migration_pass(QTestState
*who
)
282 uint64_t initial_pass
= get_migration_pass(who
);
285 /* Wait for the 1st sync */
286 while (!got_src_stop
&& !initial_pass
) {
288 initial_pass
= get_migration_pass(who
);
293 pass
= get_migration_pass(who
);
294 } while (pass
== initial_pass
&& !got_src_stop
);
297 static void check_guests_ram(QTestState
*who
)
299 /* Our ASM test will have been incrementing one byte from each page from
300 * start_address to < end_address in order. This gives us a constraint
301 * that any page's byte should be equal or less than the previous pages
302 * byte (mod 256); and they should all be equal except for one transition
303 * at the point where we meet the incrementer. (We're running this with
304 * the guest stopped).
309 bool hit_edge
= false;
312 qtest_memread(who
, start_address
, &first_byte
, 1);
313 last_byte
= first_byte
;
315 for (address
= start_address
+ TEST_MEM_PAGE_SIZE
; address
< end_address
;
316 address
+= TEST_MEM_PAGE_SIZE
)
319 qtest_memread(who
, address
, &b
, 1);
320 if (b
!= last_byte
) {
321 if (((b
+ 1) % 256) == last_byte
&& !hit_edge
) {
322 /* This is OK, the guest stopped at the point of
323 * incrementing the previous page but didn't get
331 fprintf(stderr
, "Memory content inconsistency at %x"
332 " first_byte = %x last_byte = %x current = %x"
334 address
, first_byte
, last_byte
, b
, hit_edge
);
340 fprintf(stderr
, "and in another %d pages", bad
- 10);
345 static void cleanup(const char *filename
)
347 g_autofree
char *path
= g_strdup_printf("%s/%s", tmpfs
, filename
);
352 static char *SocketAddress_to_str(SocketAddress
*addr
)
354 switch (addr
->type
) {
355 case SOCKET_ADDRESS_TYPE_INET
:
356 return g_strdup_printf("tcp:%s:%s",
359 case SOCKET_ADDRESS_TYPE_UNIX
:
360 return g_strdup_printf("unix:%s",
361 addr
->u
.q_unix
.path
);
362 case SOCKET_ADDRESS_TYPE_FD
:
363 return g_strdup_printf("fd:%s", addr
->u
.fd
.str
);
364 case SOCKET_ADDRESS_TYPE_VSOCK
:
365 return g_strdup_printf("tcp:%s:%s",
369 return g_strdup("unknown address type");
373 static char *migrate_get_socket_address(QTestState
*who
, const char *parameter
)
377 SocketAddressList
*addrs
;
381 rsp
= migrate_query(who
);
382 object
= qdict_get(rsp
, parameter
);
384 iv
= qobject_input_visitor_new(object
);
385 visit_type_SocketAddressList(iv
, NULL
, &addrs
, &error_abort
);
388 /* we are only using a single address */
389 result
= SocketAddress_to_str(addrs
->value
);
391 qapi_free_SocketAddressList(addrs
);
396 static long long migrate_get_parameter_int(QTestState
*who
,
397 const char *parameter
)
402 rsp
= qtest_qmp_assert_success_ref(
403 who
, "{ 'execute': 'query-migrate-parameters' }");
404 result
= qdict_get_int(rsp
, parameter
);
409 static void migrate_check_parameter_int(QTestState
*who
, const char *parameter
,
414 result
= migrate_get_parameter_int(who
, parameter
);
415 g_assert_cmpint(result
, ==, value
);
418 static void migrate_set_parameter_int(QTestState
*who
, const char *parameter
,
421 qtest_qmp_assert_success(who
,
422 "{ 'execute': 'migrate-set-parameters',"
423 "'arguments': { %s: %lld } }",
425 migrate_check_parameter_int(who
, parameter
, value
);
428 static char *migrate_get_parameter_str(QTestState
*who
,
429 const char *parameter
)
434 rsp
= qtest_qmp_assert_success_ref(
435 who
, "{ 'execute': 'query-migrate-parameters' }");
436 result
= g_strdup(qdict_get_str(rsp
, parameter
));
441 static void migrate_check_parameter_str(QTestState
*who
, const char *parameter
,
444 g_autofree
char *result
= migrate_get_parameter_str(who
, parameter
);
445 g_assert_cmpstr(result
, ==, value
);
448 static void migrate_set_parameter_str(QTestState
*who
, const char *parameter
,
451 qtest_qmp_assert_success(who
,
452 "{ 'execute': 'migrate-set-parameters',"
453 "'arguments': { %s: %s } }",
455 migrate_check_parameter_str(who
, parameter
, value
);
458 static long long migrate_get_parameter_bool(QTestState
*who
,
459 const char *parameter
)
464 rsp
= qtest_qmp_assert_success_ref(
465 who
, "{ 'execute': 'query-migrate-parameters' }");
466 result
= qdict_get_bool(rsp
, parameter
);
471 static void migrate_check_parameter_bool(QTestState
*who
, const char *parameter
,
476 result
= migrate_get_parameter_bool(who
, parameter
);
477 g_assert_cmpint(result
, ==, value
);
480 static void migrate_set_parameter_bool(QTestState
*who
, const char *parameter
,
483 qtest_qmp_assert_success(who
,
484 "{ 'execute': 'migrate-set-parameters',"
485 "'arguments': { %s: %i } }",
487 migrate_check_parameter_bool(who
, parameter
, value
);
490 static void migrate_ensure_non_converge(QTestState
*who
)
492 /* Can't converge with 1ms downtime + 3 mbs bandwidth limit */
493 migrate_set_parameter_int(who
, "max-bandwidth", 3 * 1000 * 1000);
494 migrate_set_parameter_int(who
, "downtime-limit", 1);
497 static void migrate_ensure_converge(QTestState
*who
)
499 /* Should converge with 30s downtime + 1 gbs bandwidth limit */
500 migrate_set_parameter_int(who
, "max-bandwidth", 1 * 1000 * 1000 * 1000);
501 migrate_set_parameter_int(who
, "downtime-limit", 30 * 1000);
505 * Our goal is to ensure that we run a single full migration
506 * iteration, and also dirty memory, ensuring that at least
507 * one further iteration is required.
509 * We can't directly synchronize with the start of a migration
510 * so we have to apply some tricks monitoring memory that is
513 * Initially we set the migration bandwidth to an insanely
514 * low value, with tiny max downtime too. This basically
515 * guarantees migration will never complete.
517 * This will result in a test that is unacceptably slow though,
518 * so we can't let the entire migration pass run at this speed.
519 * Our intent is to let it run just long enough that we can
520 * prove data prior to the marker has been transferred *AND*
521 * also prove this transferred data is dirty again.
523 * Before migration starts, we write a 64-bit magic marker
524 * into a fixed location in the src VM RAM.
526 * Then watch dst memory until the marker appears. This is
527 * proof that start_address -> MAGIC_OFFSET_BASE has been
530 * Finally we go back to the source and read a byte just
531 * before the marker until we see it flip in value. This
532 * is proof that start_address -> MAGIC_OFFSET_BASE
533 * is now dirty again.
535 * IOW, we're guaranteed at least a 2nd migration pass
538 * We can now let migration run at full speed to finish
541 static void migrate_prepare_for_dirty_mem(QTestState
*from
)
544 * The guest workflow iterates from start_address to
545 * end_address, writing 1 byte every TEST_MEM_PAGE_SIZE
548 * IOW, if we write to mem at a point which is NOT
549 * a multiple of TEST_MEM_PAGE_SIZE, our write won't
550 * conflict with the migration workflow.
552 * We put in a marker here, that we'll use to determine
553 * when the data has been transferred to the dst.
555 qtest_writeq(from
, start_address
+ MAGIC_OFFSET
, MAGIC_MARKER
);
558 static void migrate_wait_for_dirty_mem(QTestState
*from
,
561 uint64_t watch_address
= start_address
+ MAGIC_OFFSET_BASE
;
562 uint64_t marker_address
= start_address
+ MAGIC_OFFSET
;
566 * Wait for the MAGIC_MARKER to get transferred, as an
567 * indicator that a migration pass has made some known
568 * amount of progress.
572 } while (qtest_readq(to
, marker_address
) != MAGIC_MARKER
);
575 * Now ensure that already transferred bytes are
576 * dirty again from the guest workload. Note the
577 * guest byte value will wrap around and by chance
578 * match the original watch_byte. This is harmless
579 * as we'll eventually see a different value if we
582 watch_byte
= qtest_readb(from
, watch_address
);
585 } while (qtest_readb(from
, watch_address
) == watch_byte
);
589 static void migrate_pause(QTestState
*who
)
591 qtest_qmp_assert_success(who
, "{ 'execute': 'migrate-pause' }");
594 static void migrate_continue(QTestState
*who
, const char *state
)
596 qtest_qmp_assert_success(who
,
597 "{ 'execute': 'migrate-continue',"
598 " 'arguments': { 'state': %s } }",
602 static void migrate_recover(QTestState
*who
, const char *uri
)
604 qtest_qmp_assert_success(who
,
605 "{ 'execute': 'migrate-recover', "
606 " 'id': 'recover-cmd', "
607 " 'arguments': { 'uri': %s } }",
611 static void migrate_cancel(QTestState
*who
)
613 qtest_qmp_assert_success(who
, "{ 'execute': 'migrate_cancel' }");
616 static void migrate_postcopy_start(QTestState
*from
, QTestState
*to
)
618 qtest_qmp_assert_success(from
, "{ 'execute': 'migrate-start-postcopy' }");
621 qtest_qmp_eventwait(from
, "STOP");
624 qtest_qmp_eventwait(to
, "RESUME");
629 * QTEST_LOG=1 may override this. When QTEST_LOG=1, we always dump errors
630 * unconditionally, because it means the user would like to be verbose.
634 /* only launch the target process */
636 /* Use dirty ring if true; dirty logging otherwise */
638 const char *opts_source
;
639 const char *opts_target
;
643 * A hook that runs after the src and dst QEMUs have been
644 * created, but before the migration is started. This can
645 * be used to set migration parameters and capabilities.
647 * Returns: NULL, or a pointer to opaque state to be
648 * later passed to the TestMigrateFinishHook
650 typedef void * (*TestMigrateStartHook
)(QTestState
*from
,
654 * A hook that runs after the migration has finished,
655 * regardless of whether it succeeded or failed, but
656 * before QEMU has terminated (unless it self-terminated
657 * due to migration error)
659 * @opaque is a pointer to state previously returned
660 * by the TestMigrateStartHook if any, or NULL.
662 typedef void (*TestMigrateFinishHook
)(QTestState
*from
,
667 /* Optional: fine tune start parameters */
670 /* Required: the URI for the dst QEMU to listen on */
671 const char *listen_uri
;
674 * Optional: the URI for the src QEMU to connect to
675 * If NULL, then it will query the dst QEMU for its actual
676 * listening address and use that as the connect address.
677 * This allows for dynamically picking a free TCP port.
679 const char *connect_uri
;
681 /* Optional: callback to run at start to set migration parameters */
682 TestMigrateStartHook start_hook
;
683 /* Optional: callback to run at finish to cleanup */
684 TestMigrateFinishHook finish_hook
;
687 * Optional: normally we expect the migration process to complete.
689 * There can be a variety of reasons and stages in which failure
690 * can happen during tests.
692 * If a failure is expected to happen at time of establishing
693 * the connection, then MIG_TEST_FAIL will indicate that the dst
694 * QEMU is expected to stay running and accept future migration
697 * If a failure is expected to happen while processing the
698 * migration stream, then MIG_TEST_FAIL_DEST_QUIT_ERR will indicate
699 * that the dst QEMU is expected to quit with non-zero exit status
702 /* This test should succeed, the default */
703 MIG_TEST_SUCCEED
= 0,
704 /* This test should fail, dest qemu should keep alive */
706 /* This test should fail, dest qemu should fail with abnormal status */
707 MIG_TEST_FAIL_DEST_QUIT_ERR
,
708 /* The QMP command for this migration should fail with an error */
713 * Optional: set number of migration passes to wait for, if live==true.
714 * If zero, then merely wait for a few MB of dirty data
716 unsigned int iterations
;
719 * Optional: whether the guest CPUs should be running during a precopy
720 * migration test. We used to always run with live but it took much
721 * longer so we reduced live tests to only the ones that have solid
722 * reason to be tested live-only. For each of the new test cases for
723 * precopy please provide justifications to use live explicitly (please
724 * refer to existing ones with live=true), or use live=off by default.
728 /* Postcopy specific fields */
730 bool postcopy_preempt
;
731 bool postcopy_recovery_test_fail
;
734 static int test_migrate_start(QTestState
**from
, QTestState
**to
,
735 const char *uri
, MigrateStart
*args
)
737 g_autofree gchar
*arch_source
= NULL
;
738 g_autofree gchar
*arch_target
= NULL
;
739 /* options for source and target */
740 g_autofree gchar
*arch_opts
= NULL
;
741 g_autofree gchar
*cmd_source
= NULL
;
742 g_autofree gchar
*cmd_target
= NULL
;
743 const gchar
*ignore_stderr
;
744 g_autofree
char *shmem_opts
= NULL
;
745 g_autofree
char *shmem_path
= NULL
;
746 const char *kvm_opts
= NULL
;
747 const char *arch
= qtest_get_arch();
748 const char *memory_size
;
749 const char *machine_alias
, *machine_opts
= "";
750 g_autofree
char *machine
= NULL
;
752 if (args
->use_shmem
) {
753 if (!g_file_test("/dev/shm", G_FILE_TEST_IS_DIR
)) {
754 g_test_skip("/dev/shm is not supported");
759 got_src_stop
= false;
760 got_dst_resume
= false;
761 if (strcmp(arch
, "i386") == 0 || strcmp(arch
, "x86_64") == 0) {
762 memory_size
= "150M";
764 if (g_str_equal(arch
, "i386")) {
765 machine_alias
= "pc";
767 machine_alias
= "q35";
769 arch_opts
= g_strdup_printf(
770 "-drive if=none,id=d0,file=%s,format=raw "
771 "-device ide-hd,drive=d0,secs=1,cyls=1,heads=1", bootpath
);
772 start_address
= X86_TEST_MEM_START
;
773 end_address
= X86_TEST_MEM_END
;
774 } else if (g_str_equal(arch
, "s390x")) {
775 memory_size
= "128M";
776 machine_alias
= "s390-ccw-virtio";
777 arch_opts
= g_strdup_printf("-bios %s", bootpath
);
778 start_address
= S390_TEST_MEM_START
;
779 end_address
= S390_TEST_MEM_END
;
780 } else if (strcmp(arch
, "ppc64") == 0) {
781 memory_size
= "256M";
782 start_address
= PPC_TEST_MEM_START
;
783 end_address
= PPC_TEST_MEM_END
;
784 arch_source
= g_strdup_printf("-prom-env 'use-nvramrc?=true' -prom-env "
785 "'nvramrc=hex .\" _\" begin %x %x "
786 "do i c@ 1 + i c! 1000 +loop .\" B\" 0 "
787 "until'", end_address
, start_address
);
788 machine_alias
= "pseries";
789 machine_opts
= "vsmt=8";
790 arch_opts
= g_strdup("-nodefaults");
791 } else if (strcmp(arch
, "aarch64") == 0) {
792 memory_size
= "150M";
793 machine_alias
= "virt";
794 machine_opts
= "gic-version=max";
795 arch_opts
= g_strdup_printf("-cpu max -kernel %s", bootpath
);
796 start_address
= ARM_TEST_MEM_START
;
797 end_address
= ARM_TEST_MEM_END
;
799 g_assert_not_reached();
802 if (!getenv("QTEST_LOG") && args
->hide_stderr
) {
804 ignore_stderr
= "2>/dev/null";
807 * On Windows the QEMU executable is created via CreateProcess() and
808 * IO redirection does not work, so don't bother adding IO redirection
809 * to the command line.
817 if (args
->use_shmem
) {
818 shmem_path
= g_strdup_printf("/dev/shm/qemu-%d", getpid());
819 shmem_opts
= g_strdup_printf(
820 "-object memory-backend-file,id=mem0,size=%s"
821 ",mem-path=%s,share=on -numa node,memdev=mem0",
822 memory_size
, shmem_path
);
825 if (args
->use_dirty_ring
) {
826 kvm_opts
= ",dirty-ring-size=4096";
829 machine
= resolve_machine_version(machine_alias
, QEMU_ENV_SRC
,
832 g_test_message("Using machine type: %s", machine
);
834 cmd_source
= g_strdup_printf("-accel kvm%s -accel tcg "
836 "-name source,debug-threads=on "
838 "-serial file:%s/src_serial "
840 kvm_opts
? kvm_opts
: "",
841 machine
, machine_opts
,
843 arch_opts
? arch_opts
: "",
844 arch_source
? arch_source
: "",
845 shmem_opts
? shmem_opts
: "",
846 args
->opts_source
? args
->opts_source
: "",
848 if (!args
->only_target
) {
849 *from
= qtest_init_with_env(QEMU_ENV_SRC
, cmd_source
);
850 qtest_qmp_set_event_callback(*from
,
851 migrate_watch_for_stop
,
855 cmd_target
= g_strdup_printf("-accel kvm%s -accel tcg "
857 "-name target,debug-threads=on "
859 "-serial file:%s/dest_serial "
862 kvm_opts
? kvm_opts
: "",
863 machine
, machine_opts
,
864 memory_size
, tmpfs
, uri
,
865 arch_opts
? arch_opts
: "",
866 arch_target
? arch_target
: "",
867 shmem_opts
? shmem_opts
: "",
868 args
->opts_target
? args
->opts_target
: "",
870 *to
= qtest_init_with_env(QEMU_ENV_DST
, cmd_target
);
871 qtest_qmp_set_event_callback(*to
,
872 migrate_watch_for_resume
,
876 * Remove shmem file immediately to avoid memory leak in test failed case.
877 * It's valid because QEMU has already opened this file
879 if (args
->use_shmem
) {
886 static void test_migrate_end(QTestState
*from
, QTestState
*to
, bool test_dest
)
888 unsigned char dest_byte_a
, dest_byte_b
, dest_byte_c
, dest_byte_d
;
893 qtest_memread(to
, start_address
, &dest_byte_a
, 1);
895 /* Destination still running, wait for a byte to change */
897 qtest_memread(to
, start_address
, &dest_byte_b
, 1);
899 } while (dest_byte_a
== dest_byte_b
);
901 qtest_qmp_assert_success(to
, "{ 'execute' : 'stop'}");
903 /* With it stopped, check nothing changes */
904 qtest_memread(to
, start_address
, &dest_byte_c
, 1);
906 qtest_memread(to
, start_address
, &dest_byte_d
, 1);
907 g_assert_cmpint(dest_byte_c
, ==, dest_byte_d
);
909 check_guests_ram(to
);
914 cleanup("migsocket");
915 cleanup("src_serial");
916 cleanup("dest_serial");
917 cleanup(FILE_TEST_FILENAME
);
921 struct TestMigrateTLSPSKData
{
929 test_migrate_tls_psk_start_common(QTestState
*from
,
933 struct TestMigrateTLSPSKData
*data
=
934 g_new0(struct TestMigrateTLSPSKData
, 1);
936 data
->workdir
= g_strdup_printf("%s/tlscredspsk0", tmpfs
);
937 data
->pskfile
= g_strdup_printf("%s/%s", data
->workdir
,
938 QCRYPTO_TLS_CREDS_PSKFILE
);
939 g_mkdir_with_parents(data
->workdir
, 0700);
940 test_tls_psk_init(data
->pskfile
);
943 data
->workdiralt
= g_strdup_printf("%s/tlscredspskalt0", tmpfs
);
944 data
->pskfilealt
= g_strdup_printf("%s/%s", data
->workdiralt
,
945 QCRYPTO_TLS_CREDS_PSKFILE
);
946 g_mkdir_with_parents(data
->workdiralt
, 0700);
947 test_tls_psk_init_alt(data
->pskfilealt
);
950 qtest_qmp_assert_success(from
,
951 "{ 'execute': 'object-add',"
952 " 'arguments': { 'qom-type': 'tls-creds-psk',"
953 " 'id': 'tlscredspsk0',"
954 " 'endpoint': 'client',"
956 " 'username': 'qemu'} }",
959 qtest_qmp_assert_success(to
,
960 "{ 'execute': 'object-add',"
961 " 'arguments': { 'qom-type': 'tls-creds-psk',"
962 " 'id': 'tlscredspsk0',"
963 " 'endpoint': 'server',"
965 mismatch
? data
->workdiralt
: data
->workdir
);
967 migrate_set_parameter_str(from
, "tls-creds", "tlscredspsk0");
968 migrate_set_parameter_str(to
, "tls-creds", "tlscredspsk0");
974 test_migrate_tls_psk_start_match(QTestState
*from
,
977 return test_migrate_tls_psk_start_common(from
, to
, false);
981 test_migrate_tls_psk_start_mismatch(QTestState
*from
,
984 return test_migrate_tls_psk_start_common(from
, to
, true);
988 test_migrate_tls_psk_finish(QTestState
*from
,
992 struct TestMigrateTLSPSKData
*data
= opaque
;
994 test_tls_psk_cleanup(data
->pskfile
);
995 if (data
->pskfilealt
) {
996 test_tls_psk_cleanup(data
->pskfilealt
);
998 rmdir(data
->workdir
);
999 if (data
->workdiralt
) {
1000 rmdir(data
->workdiralt
);
1003 g_free(data
->workdiralt
);
1004 g_free(data
->pskfilealt
);
1005 g_free(data
->workdir
);
1006 g_free(data
->pskfile
);
1019 } TestMigrateTLSX509Data
;
1026 const char *certhostname
;
1027 const char *certipaddr
;
1028 } TestMigrateTLSX509
;
1031 test_migrate_tls_x509_start_common(QTestState
*from
,
1033 TestMigrateTLSX509
*args
)
1035 TestMigrateTLSX509Data
*data
= g_new0(TestMigrateTLSX509Data
, 1);
1037 data
->workdir
= g_strdup_printf("%s/tlscredsx5090", tmpfs
);
1038 data
->keyfile
= g_strdup_printf("%s/key.pem", data
->workdir
);
1040 data
->cacert
= g_strdup_printf("%s/ca-cert.pem", data
->workdir
);
1041 data
->serverkey
= g_strdup_printf("%s/server-key.pem", data
->workdir
);
1042 data
->servercert
= g_strdup_printf("%s/server-cert.pem", data
->workdir
);
1043 if (args
->clientcert
) {
1044 data
->clientkey
= g_strdup_printf("%s/client-key.pem", data
->workdir
);
1045 data
->clientcert
= g_strdup_printf("%s/client-cert.pem", data
->workdir
);
1048 g_mkdir_with_parents(data
->workdir
, 0700);
1050 test_tls_init(data
->keyfile
);
1052 g_assert(link(data
->keyfile
, data
->serverkey
) == 0);
1054 g_assert(CreateHardLink(data
->serverkey
, data
->keyfile
, NULL
) != 0);
1056 if (args
->clientcert
) {
1058 g_assert(link(data
->keyfile
, data
->clientkey
) == 0);
1060 g_assert(CreateHardLink(data
->clientkey
, data
->keyfile
, NULL
) != 0);
1064 TLS_ROOT_REQ_SIMPLE(cacertreq
, data
->cacert
);
1065 if (args
->clientcert
) {
1066 TLS_CERT_REQ_SIMPLE_CLIENT(servercertreq
, cacertreq
,
1067 args
->hostileclient
?
1068 QCRYPTO_TLS_TEST_CLIENT_HOSTILE_NAME
:
1069 QCRYPTO_TLS_TEST_CLIENT_NAME
,
1073 TLS_CERT_REQ_SIMPLE_SERVER(clientcertreq
, cacertreq
,
1078 qtest_qmp_assert_success(from
,
1079 "{ 'execute': 'object-add',"
1080 " 'arguments': { 'qom-type': 'tls-creds-x509',"
1081 " 'id': 'tlscredsx509client0',"
1082 " 'endpoint': 'client',"
1084 " 'sanity-check': true,"
1085 " 'verify-peer': true} }",
1087 migrate_set_parameter_str(from
, "tls-creds", "tlscredsx509client0");
1088 if (args
->certhostname
) {
1089 migrate_set_parameter_str(from
, "tls-hostname", args
->certhostname
);
1092 qtest_qmp_assert_success(to
,
1093 "{ 'execute': 'object-add',"
1094 " 'arguments': { 'qom-type': 'tls-creds-x509',"
1095 " 'id': 'tlscredsx509server0',"
1096 " 'endpoint': 'server',"
1098 " 'sanity-check': true,"
1099 " 'verify-peer': %i} }",
1100 data
->workdir
, args
->verifyclient
);
1101 migrate_set_parameter_str(to
, "tls-creds", "tlscredsx509server0");
1103 if (args
->authzclient
) {
1104 qtest_qmp_assert_success(to
,
1105 "{ 'execute': 'object-add',"
1106 " 'arguments': { 'qom-type': 'authz-simple',"
1107 " 'id': 'tlsauthz0',"
1108 " 'identity': %s} }",
1109 "CN=" QCRYPTO_TLS_TEST_CLIENT_NAME
);
1110 migrate_set_parameter_str(to
, "tls-authz", "tlsauthz0");
1117 * The normal case: match server's cert hostname against
1118 * whatever host we were telling QEMU to connect to (if any)
1121 test_migrate_tls_x509_start_default_host(QTestState
*from
,
1124 TestMigrateTLSX509 args
= {
1125 .verifyclient
= true,
1127 .certipaddr
= "127.0.0.1"
1129 return test_migrate_tls_x509_start_common(from
, to
, &args
);
1133 * The unusual case: the server's cert is different from
1134 * the address we're telling QEMU to connect to (if any),
1135 * so we must give QEMU an explicit hostname to validate
1138 test_migrate_tls_x509_start_override_host(QTestState
*from
,
1141 TestMigrateTLSX509 args
= {
1142 .verifyclient
= true,
1144 .certhostname
= "qemu.org",
1146 return test_migrate_tls_x509_start_common(from
, to
, &args
);
1150 * The unusual case: the server's cert is different from
1151 * the address we're telling QEMU to connect to, and so we
1152 * expect the client to reject the server
1155 test_migrate_tls_x509_start_mismatch_host(QTestState
*from
,
1158 TestMigrateTLSX509 args
= {
1159 .verifyclient
= true,
1161 .certipaddr
= "10.0.0.1",
1163 return test_migrate_tls_x509_start_common(from
, to
, &args
);
1167 test_migrate_tls_x509_start_friendly_client(QTestState
*from
,
1170 TestMigrateTLSX509 args
= {
1171 .verifyclient
= true,
1173 .authzclient
= true,
1174 .certipaddr
= "127.0.0.1",
1176 return test_migrate_tls_x509_start_common(from
, to
, &args
);
1180 test_migrate_tls_x509_start_hostile_client(QTestState
*from
,
1183 TestMigrateTLSX509 args
= {
1184 .verifyclient
= true,
1186 .hostileclient
= true,
1187 .authzclient
= true,
1188 .certipaddr
= "127.0.0.1",
1190 return test_migrate_tls_x509_start_common(from
, to
, &args
);
1194 * The case with no client certificate presented,
1195 * and no server verification
1198 test_migrate_tls_x509_start_allow_anon_client(QTestState
*from
,
1201 TestMigrateTLSX509 args
= {
1202 .certipaddr
= "127.0.0.1",
1204 return test_migrate_tls_x509_start_common(from
, to
, &args
);
1208 * The case with no client certificate presented,
1209 * and server verification rejecting
1212 test_migrate_tls_x509_start_reject_anon_client(QTestState
*from
,
1215 TestMigrateTLSX509 args
= {
1216 .verifyclient
= true,
1217 .certipaddr
= "127.0.0.1",
1219 return test_migrate_tls_x509_start_common(from
, to
, &args
);
1223 test_migrate_tls_x509_finish(QTestState
*from
,
1227 TestMigrateTLSX509Data
*data
= opaque
;
1229 test_tls_cleanup(data
->keyfile
);
1230 g_free(data
->keyfile
);
1232 unlink(data
->cacert
);
1233 g_free(data
->cacert
);
1234 unlink(data
->servercert
);
1235 g_free(data
->servercert
);
1236 unlink(data
->serverkey
);
1237 g_free(data
->serverkey
);
1239 if (data
->clientcert
) {
1240 unlink(data
->clientcert
);
1241 g_free(data
->clientcert
);
1243 if (data
->clientkey
) {
1244 unlink(data
->clientkey
);
1245 g_free(data
->clientkey
);
1248 rmdir(data
->workdir
);
1249 g_free(data
->workdir
);
1253 #endif /* CONFIG_TASN1 */
1254 #endif /* CONFIG_GNUTLS */
1257 test_migrate_compress_start(QTestState
*from
,
1260 migrate_set_parameter_int(from
, "compress-level", 1);
1261 migrate_set_parameter_int(from
, "compress-threads", 4);
1262 migrate_set_parameter_bool(from
, "compress-wait-thread", true);
1263 migrate_set_parameter_int(to
, "decompress-threads", 4);
1265 migrate_set_capability(from
, "compress", true);
1266 migrate_set_capability(to
, "compress", true);
1272 test_migrate_compress_nowait_start(QTestState
*from
,
1275 migrate_set_parameter_int(from
, "compress-level", 9);
1276 migrate_set_parameter_int(from
, "compress-threads", 1);
1277 migrate_set_parameter_bool(from
, "compress-wait-thread", false);
1278 migrate_set_parameter_int(to
, "decompress-threads", 1);
1280 migrate_set_capability(from
, "compress", true);
1281 migrate_set_capability(to
, "compress", true);
1286 static int migrate_postcopy_prepare(QTestState
**from_ptr
,
1287 QTestState
**to_ptr
,
1288 MigrateCommon
*args
)
1290 QTestState
*from
, *to
;
1292 if (test_migrate_start(&from
, &to
, "defer", &args
->start
)) {
1296 if (args
->start_hook
) {
1297 args
->postcopy_data
= args
->start_hook(from
, to
);
1300 migrate_set_capability(from
, "postcopy-ram", true);
1301 migrate_set_capability(to
, "postcopy-ram", true);
1302 migrate_set_capability(to
, "postcopy-blocktime", true);
1304 if (args
->postcopy_preempt
) {
1305 migrate_set_capability(from
, "postcopy-preempt", true);
1306 migrate_set_capability(to
, "postcopy-preempt", true);
1309 migrate_ensure_non_converge(from
);
1311 migrate_prepare_for_dirty_mem(from
);
1312 qtest_qmp_assert_success(to
, "{ 'execute': 'migrate-incoming',"
1313 " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}");
1315 /* Wait for the first serial output from the source */
1316 wait_for_serial("src_serial");
1318 g_autofree
char *uri
= migrate_get_socket_address(to
, "socket-address");
1319 migrate_qmp(from
, uri
, "{}");
1321 migrate_wait_for_dirty_mem(from
, to
);
1329 static void migrate_postcopy_complete(QTestState
*from
, QTestState
*to
,
1330 MigrateCommon
*args
)
1332 wait_for_migration_complete(from
);
1334 /* Make sure we get at least one "B" on destination */
1335 wait_for_serial("dest_serial");
1337 if (uffd_feature_thread_id
) {
1341 if (args
->finish_hook
) {
1342 args
->finish_hook(from
, to
, args
->postcopy_data
);
1343 args
->postcopy_data
= NULL
;
1346 test_migrate_end(from
, to
, true);
1349 static void test_postcopy_common(MigrateCommon
*args
)
1351 QTestState
*from
, *to
;
1353 if (migrate_postcopy_prepare(&from
, &to
, args
)) {
1356 migrate_postcopy_start(from
, to
);
1357 migrate_postcopy_complete(from
, to
, args
);
1360 static void test_postcopy(void)
1362 MigrateCommon args
= { };
1364 test_postcopy_common(&args
);
1367 static void test_postcopy_compress(void)
1369 MigrateCommon args
= {
1370 .start_hook
= test_migrate_compress_start
1373 test_postcopy_common(&args
);
1376 static void test_postcopy_preempt(void)
1378 MigrateCommon args
= {
1379 .postcopy_preempt
= true,
1382 test_postcopy_common(&args
);
1385 #ifdef CONFIG_GNUTLS
1386 static void test_postcopy_tls_psk(void)
1388 MigrateCommon args
= {
1389 .start_hook
= test_migrate_tls_psk_start_match
,
1390 .finish_hook
= test_migrate_tls_psk_finish
,
1393 test_postcopy_common(&args
);
1396 static void test_postcopy_preempt_tls_psk(void)
1398 MigrateCommon args
= {
1399 .postcopy_preempt
= true,
1400 .start_hook
= test_migrate_tls_psk_start_match
,
1401 .finish_hook
= test_migrate_tls_psk_finish
,
1404 test_postcopy_common(&args
);
1408 static void wait_for_postcopy_status(QTestState
*one
, const char *status
)
1410 wait_for_migration_status(one
, status
,
1411 (const char * []) { "failed", "active",
1412 "completed", NULL
});
1416 static void postcopy_recover_fail(QTestState
*from
, QTestState
*to
)
1418 int ret
, pair1
[2], pair2
[2];
1421 /* Create two unrelated socketpairs */
1422 ret
= qemu_socketpair(PF_LOCAL
, SOCK_STREAM
, 0, pair1
);
1423 g_assert_cmpint(ret
, ==, 0);
1425 ret
= qemu_socketpair(PF_LOCAL
, SOCK_STREAM
, 0, pair2
);
1426 g_assert_cmpint(ret
, ==, 0);
1429 * Give the guests unpaired ends of the sockets, so they'll all blocked
1430 * at reading. This mimics a wrong channel established.
1432 qtest_qmp_fds_assert_success(from
, &pair1
[0], 1,
1433 "{ 'execute': 'getfd',"
1434 " 'arguments': { 'fdname': 'fd-mig' }}");
1435 qtest_qmp_fds_assert_success(to
, &pair2
[0], 1,
1436 "{ 'execute': 'getfd',"
1437 " 'arguments': { 'fdname': 'fd-mig' }}");
1440 * Write the 1st byte as QEMU_VM_COMMAND (0x8) for the dest socket, to
1441 * emulate the 1st byte of a real recovery, but stops from there to
1442 * keep dest QEMU in RECOVER. This is needed so that we can kick off
1443 * the recover process on dest QEMU (by triggering the G_IO_IN event).
1445 * NOTE: this trick is not needed on src QEMUs, because src doesn't
1446 * rely on an pre-existing G_IO_IN event, so it will always trigger the
1447 * upcoming recovery anyway even if it can read nothing.
1449 #define QEMU_VM_COMMAND 0x08
1450 c
= QEMU_VM_COMMAND
;
1451 ret
= send(pair2
[1], &c
, 1, 0);
1452 g_assert_cmpint(ret
, ==, 1);
1454 migrate_recover(to
, "fd:fd-mig");
1455 migrate_qmp(from
, "fd:fd-mig", "{'resume': true}");
1458 * Make sure both QEMU instances will go into RECOVER stage, then test
1459 * kicking them out using migrate-pause.
1461 wait_for_postcopy_status(from
, "postcopy-recover");
1462 wait_for_postcopy_status(to
, "postcopy-recover");
1465 * This would be issued by the admin upon noticing the hang, we should
1466 * make sure we're able to kick this out.
1468 migrate_pause(from
);
1469 wait_for_postcopy_status(from
, "postcopy-paused");
1471 /* Do the same test on dest */
1473 wait_for_postcopy_status(to
, "postcopy-paused");
1482 static void test_postcopy_recovery_common(MigrateCommon
*args
)
1484 QTestState
*from
, *to
;
1485 g_autofree
char *uri
= NULL
;
1487 /* Always hide errors for postcopy recover tests since they're expected */
1488 args
->start
.hide_stderr
= true;
1490 if (migrate_postcopy_prepare(&from
, &to
, args
)) {
1494 /* Turn postcopy speed down, 4K/s is slow enough on any machines */
1495 migrate_set_parameter_int(from
, "max-postcopy-bandwidth", 4096);
1497 /* Now we start the postcopy */
1498 migrate_postcopy_start(from
, to
);
1501 * Wait until postcopy is really started; we can only run the
1502 * migrate-pause command during a postcopy
1504 wait_for_migration_status(from
, "postcopy-active", NULL
);
1507 * Manually stop the postcopy migration. This emulates a network
1508 * failure with the migration socket
1510 migrate_pause(from
);
1513 * Wait for destination side to reach postcopy-paused state. The
1514 * migrate-recover command can only succeed if destination machine
1515 * is in the paused state
1517 wait_for_postcopy_status(to
, "postcopy-paused");
1518 wait_for_postcopy_status(from
, "postcopy-paused");
1521 if (args
->postcopy_recovery_test_fail
) {
1523 * Test when a wrong socket specified for recover, and then the
1524 * ability to kick it out, and continue with a correct socket.
1526 postcopy_recover_fail(from
, to
);
1527 /* continue with a good recovery */
1532 * Create a new socket to emulate a new channel that is different
1533 * from the broken migration channel; tell the destination to
1534 * listen to the new port
1536 uri
= g_strdup_printf("unix:%s/migsocket-recover", tmpfs
);
1537 migrate_recover(to
, uri
);
1540 * Try to rebuild the migration channel using the resume flag and
1541 * the newly created channel
1543 migrate_qmp(from
, uri
, "{'resume': true}");
1545 /* Restore the postcopy bandwidth to unlimited */
1546 migrate_set_parameter_int(from
, "max-postcopy-bandwidth", 0);
1548 migrate_postcopy_complete(from
, to
, args
);
1551 static void test_postcopy_recovery(void)
1553 MigrateCommon args
= { };
1555 test_postcopy_recovery_common(&args
);
1558 static void test_postcopy_recovery_compress(void)
1560 MigrateCommon args
= {
1561 .start_hook
= test_migrate_compress_start
1564 test_postcopy_recovery_common(&args
);
1568 static void test_postcopy_recovery_double_fail(void)
1570 MigrateCommon args
= {
1571 .postcopy_recovery_test_fail
= true,
1574 test_postcopy_recovery_common(&args
);
1578 #ifdef CONFIG_GNUTLS
1579 static void test_postcopy_recovery_tls_psk(void)
1581 MigrateCommon args
= {
1582 .start_hook
= test_migrate_tls_psk_start_match
,
1583 .finish_hook
= test_migrate_tls_psk_finish
,
1586 test_postcopy_recovery_common(&args
);
1590 static void test_postcopy_preempt_recovery(void)
1592 MigrateCommon args
= {
1593 .postcopy_preempt
= true,
1596 test_postcopy_recovery_common(&args
);
1599 #ifdef CONFIG_GNUTLS
1600 /* This contains preempt+recovery+tls test altogether */
1601 static void test_postcopy_preempt_all(void)
1603 MigrateCommon args
= {
1604 .postcopy_preempt
= true,
1605 .start_hook
= test_migrate_tls_psk_start_match
,
1606 .finish_hook
= test_migrate_tls_psk_finish
,
1609 test_postcopy_recovery_common(&args
);
1614 static void test_baddest(void)
1616 MigrateStart args
= {
1619 QTestState
*from
, *to
;
1621 if (test_migrate_start(&from
, &to
, "tcp:127.0.0.1:0", &args
)) {
1624 migrate_qmp(from
, "tcp:127.0.0.1:0", "{}");
1625 wait_for_migration_fail(from
, false);
1626 test_migrate_end(from
, to
, false);
1630 static void test_analyze_script(void)
1632 MigrateStart args
= {
1633 .opts_source
= "-uuid 11111111-1111-1111-1111-111111111111",
1635 QTestState
*from
, *to
;
1636 g_autofree
char *uri
= NULL
;
1637 g_autofree
char *file
= NULL
;
1639 const char *python
= g_getenv("PYTHON");
1642 g_test_skip("PYTHON variable not set");
1647 if (test_migrate_start(&from
, &to
, "tcp:127.0.0.1:0", &args
)) {
1652 * Setting these two capabilities causes the "configuration"
1653 * vmstate to include subsections for them. The script needs to
1654 * parse those subsections properly.
1656 migrate_set_capability(from
, "validate-uuid", true);
1657 migrate_set_capability(from
, "x-ignore-shared", true);
1659 file
= g_strdup_printf("%s/migfile", tmpfs
);
1660 uri
= g_strdup_printf("exec:cat > %s", file
);
1662 migrate_ensure_converge(from
);
1663 migrate_qmp(from
, uri
, "{}");
1664 wait_for_migration_complete(from
);
1669 open("/dev/null", O_WRONLY
);
1670 execl(python
, python
, ANALYZE_SCRIPT
, "-f", file
, NULL
);
1671 g_assert_not_reached();
1674 g_assert(waitpid(pid
, &wstatus
, 0) == pid
);
1675 if (WIFEXITED(wstatus
) && WEXITSTATUS(wstatus
) != 0) {
1676 g_test_message("Failed to analyze the migration stream");
1679 test_migrate_end(from
, to
, false);
1684 static void test_precopy_common(MigrateCommon
*args
)
1686 QTestState
*from
, *to
;
1687 void *data_hook
= NULL
;
1688 g_autofree
char *connect_uri
= NULL
;
1690 if (test_migrate_start(&from
, &to
, args
->listen_uri
, &args
->start
)) {
1694 if (args
->start_hook
) {
1695 data_hook
= args
->start_hook(from
, to
);
1698 /* Wait for the first serial output from the source */
1699 if (args
->result
== MIG_TEST_SUCCEED
) {
1700 wait_for_serial("src_serial");
1704 migrate_ensure_non_converge(from
);
1705 migrate_prepare_for_dirty_mem(from
);
1708 * Testing non-live migration, we allow it to run at
1709 * full speed to ensure short test case duration.
1710 * For tests expected to fail, we don't need to
1713 if (args
->result
== MIG_TEST_SUCCEED
) {
1714 qtest_qmp_assert_success(from
, "{ 'execute' : 'stop'}");
1715 if (!got_src_stop
) {
1716 qtest_qmp_eventwait(from
, "STOP");
1718 migrate_ensure_converge(from
);
1722 if (!args
->connect_uri
) {
1723 connect_uri
= migrate_get_socket_address(to
, "socket-address");
1725 connect_uri
= g_strdup(args
->connect_uri
);
1728 if (args
->result
== MIG_TEST_QMP_ERROR
) {
1729 migrate_qmp_fail(from
, connect_uri
, "{}");
1733 migrate_qmp(from
, connect_uri
, "{}");
1735 if (args
->result
!= MIG_TEST_SUCCEED
) {
1736 bool allow_active
= args
->result
== MIG_TEST_FAIL
;
1737 wait_for_migration_fail(from
, allow_active
);
1739 if (args
->result
== MIG_TEST_FAIL_DEST_QUIT_ERR
) {
1740 qtest_set_expected_status(to
, EXIT_FAILURE
);
1745 * For initial iteration(s) we must do a full pass,
1746 * but for the final iteration, we need only wait
1747 * for some dirty mem before switching to converge
1749 while (args
->iterations
> 1) {
1750 wait_for_migration_pass(from
);
1753 migrate_wait_for_dirty_mem(from
, to
);
1755 migrate_ensure_converge(from
);
1758 * We do this first, as it has a timeout to stop us
1759 * hanging forever if migration didn't converge
1761 wait_for_migration_complete(from
);
1763 if (!got_src_stop
) {
1764 qtest_qmp_eventwait(from
, "STOP");
1767 wait_for_migration_complete(from
);
1769 * Must wait for dst to finish reading all incoming
1770 * data on the socket before issuing 'cont' otherwise
1773 wait_for_migration_complete(to
);
1775 qtest_qmp_assert_success(to
, "{ 'execute' : 'cont'}");
1778 if (!got_dst_resume
) {
1779 qtest_qmp_eventwait(to
, "RESUME");
1782 wait_for_serial("dest_serial");
1786 if (args
->finish_hook
) {
1787 args
->finish_hook(from
, to
, data_hook
);
1790 test_migrate_end(from
, to
, args
->result
== MIG_TEST_SUCCEED
);
1793 static void test_file_common(MigrateCommon
*args
, bool stop_src
)
1795 QTestState
*from
, *to
;
1796 void *data_hook
= NULL
;
1797 g_autofree
char *connect_uri
= g_strdup(args
->connect_uri
);
1799 if (test_migrate_start(&from
, &to
, args
->listen_uri
, &args
->start
)) {
1804 * File migration is never live. We can keep the source VM running
1805 * during migration, but the destination will not be running
1808 g_assert_false(args
->live
);
1810 if (args
->start_hook
) {
1811 data_hook
= args
->start_hook(from
, to
);
1814 migrate_ensure_converge(from
);
1815 wait_for_serial("src_serial");
1818 qtest_qmp_assert_success(from
, "{ 'execute' : 'stop'}");
1819 if (!got_src_stop
) {
1820 qtest_qmp_eventwait(from
, "STOP");
1824 if (args
->result
== MIG_TEST_QMP_ERROR
) {
1825 migrate_qmp_fail(from
, connect_uri
, "{}");
1829 migrate_qmp(from
, connect_uri
, "{}");
1830 wait_for_migration_complete(from
);
1833 * We need to wait for the source to finish before starting the
1836 migrate_incoming_qmp(to
, connect_uri
, "{}");
1837 wait_for_migration_complete(to
);
1840 qtest_qmp_assert_success(to
, "{ 'execute' : 'cont'}");
1843 if (!got_dst_resume
) {
1844 qtest_qmp_eventwait(to
, "RESUME");
1847 wait_for_serial("dest_serial");
1850 if (args
->finish_hook
) {
1851 args
->finish_hook(from
, to
, data_hook
);
1854 test_migrate_end(from
, to
, args
->result
== MIG_TEST_SUCCEED
);
1857 static void test_precopy_unix_plain(void)
1859 g_autofree
char *uri
= g_strdup_printf("unix:%s/migsocket", tmpfs
);
1860 MigrateCommon args
= {
1864 * The simplest use case of precopy, covering smoke tests of
1865 * get-dirty-log dirty tracking.
1870 test_precopy_common(&args
);
1874 static void test_precopy_unix_dirty_ring(void)
1876 g_autofree
char *uri
= g_strdup_printf("unix:%s/migsocket", tmpfs
);
1877 MigrateCommon args
= {
1879 .use_dirty_ring
= true,
1884 * Besides the precopy/unix basic test, cover dirty ring interface
1885 * rather than get-dirty-log.
1890 test_precopy_common(&args
);
1893 #ifdef CONFIG_GNUTLS
1894 static void test_precopy_unix_tls_psk(void)
1896 g_autofree
char *uri
= g_strdup_printf("unix:%s/migsocket", tmpfs
);
1897 MigrateCommon args
= {
1900 .start_hook
= test_migrate_tls_psk_start_match
,
1901 .finish_hook
= test_migrate_tls_psk_finish
,
1904 test_precopy_common(&args
);
1908 static void test_precopy_unix_tls_x509_default_host(void)
1910 g_autofree
char *uri
= g_strdup_printf("unix:%s/migsocket", tmpfs
);
1911 MigrateCommon args
= {
1913 .hide_stderr
= true,
1917 .start_hook
= test_migrate_tls_x509_start_default_host
,
1918 .finish_hook
= test_migrate_tls_x509_finish
,
1919 .result
= MIG_TEST_FAIL_DEST_QUIT_ERR
,
1922 test_precopy_common(&args
);
1925 static void test_precopy_unix_tls_x509_override_host(void)
1927 g_autofree
char *uri
= g_strdup_printf("unix:%s/migsocket", tmpfs
);
1928 MigrateCommon args
= {
1931 .start_hook
= test_migrate_tls_x509_start_override_host
,
1932 .finish_hook
= test_migrate_tls_x509_finish
,
1935 test_precopy_common(&args
);
1937 #endif /* CONFIG_TASN1 */
1938 #endif /* CONFIG_GNUTLS */
1941 /* Currently upset on aarch64 TCG */
1942 static void test_ignore_shared(void)
1944 g_autofree
char *uri
= g_strdup_printf("unix:%s/migsocket", tmpfs
);
1945 QTestState
*from
, *to
;
1947 if (test_migrate_start(&from
, &to
, uri
, false, true, NULL
, NULL
)) {
1951 migrate_ensure_non_converge(from
);
1952 migrate_prepare_for_dirty_mem(from
);
1954 migrate_set_capability(from
, "x-ignore-shared", true);
1955 migrate_set_capability(to
, "x-ignore-shared", true);
1957 /* Wait for the first serial output from the source */
1958 wait_for_serial("src_serial");
1960 migrate_qmp(from
, uri
, "{}");
1962 migrate_wait_for_dirty_mem(from
, to
);
1964 if (!got_src_stop
) {
1965 qtest_qmp_eventwait(from
, "STOP");
1968 qtest_qmp_eventwait(to
, "RESUME");
1970 wait_for_serial("dest_serial");
1971 wait_for_migration_complete(from
);
1973 /* Check whether shared RAM has been really skipped */
1974 g_assert_cmpint(read_ram_property_int(from
, "transferred"), <, 1024 * 1024);
1976 test_migrate_end(from
, to
, true);
1981 test_migrate_xbzrle_start(QTestState
*from
,
1984 migrate_set_parameter_int(from
, "xbzrle-cache-size", 33554432);
1986 migrate_set_capability(from
, "xbzrle", true);
1987 migrate_set_capability(to
, "xbzrle", true);
1992 static void test_precopy_unix_xbzrle(void)
1994 g_autofree
char *uri
= g_strdup_printf("unix:%s/migsocket", tmpfs
);
1995 MigrateCommon args
= {
1998 .start_hook
= test_migrate_xbzrle_start
,
2001 * XBZRLE needs pages to be modified when doing the 2nd+ round
2002 * iteration to have real data pushed to the stream.
2007 test_precopy_common(&args
);
2010 static void test_precopy_unix_compress(void)
2012 g_autofree
char *uri
= g_strdup_printf("unix:%s/migsocket", tmpfs
);
2013 MigrateCommon args
= {
2016 .start_hook
= test_migrate_compress_start
,
2018 * Test that no invalid thread state is left over from
2019 * the previous iteration.
2023 * We make sure the compressor can always work well even if guest
2024 * memory is changing. See commit 34ab9e9743 where we used to fix
2025 * a bug when only trigger-able with guest memory changing.
2030 test_precopy_common(&args
);
2033 static void test_precopy_unix_compress_nowait(void)
2035 g_autofree
char *uri
= g_strdup_printf("unix:%s/migsocket", tmpfs
);
2036 MigrateCommon args
= {
2039 .start_hook
= test_migrate_compress_nowait_start
,
2041 * Test that no invalid thread state is left over from
2042 * the previous iteration.
2045 /* Same reason for the wait version of precopy compress test */
2049 test_precopy_common(&args
);
2052 static void test_precopy_file(void)
2054 g_autofree
char *uri
= g_strdup_printf("file:%s/%s", tmpfs
,
2055 FILE_TEST_FILENAME
);
2056 MigrateCommon args
= {
2058 .listen_uri
= "defer",
2061 test_file_common(&args
, true);
2064 static void file_offset_finish_hook(QTestState
*from
, QTestState
*to
,
2067 #if defined(__linux__)
2068 g_autofree
char *path
= g_strdup_printf("%s/%s", tmpfs
, FILE_TEST_FILENAME
);
2069 size_t size
= FILE_TEST_OFFSET
+ sizeof(QEMU_VM_FILE_MAGIC
);
2070 uintptr_t *addr
, *p
;
2073 fd
= open(path
, O_RDONLY
);
2075 addr
= mmap(NULL
, size
, PROT_READ
, MAP_SHARED
, fd
, 0);
2076 g_assert(addr
!= MAP_FAILED
);
2079 * Ensure the skipped offset contains zeros and the migration
2080 * stream starts at the right place.
2083 while (p
< addr
+ FILE_TEST_OFFSET
/ sizeof(uintptr_t)) {
2087 g_assert_cmpint(cpu_to_be64(*p
) >> 32, ==, QEMU_VM_FILE_MAGIC
);
2094 static void test_precopy_file_offset(void)
2096 g_autofree
char *uri
= g_strdup_printf("file:%s/%s,offset=%d", tmpfs
,
2099 MigrateCommon args
= {
2101 .listen_uri
= "defer",
2102 .finish_hook
= file_offset_finish_hook
,
2105 test_file_common(&args
, false);
2108 static void test_precopy_file_offset_bad(void)
2110 /* using a value not supported by qemu_strtosz() */
2111 g_autofree
char *uri
= g_strdup_printf("file:%s/%s,offset=0x20M",
2112 tmpfs
, FILE_TEST_FILENAME
);
2113 MigrateCommon args
= {
2115 .listen_uri
= "defer",
2116 .result
= MIG_TEST_QMP_ERROR
,
2119 test_file_common(&args
, false);
2122 static void *test_mode_reboot_start(QTestState
*from
, QTestState
*to
)
2124 migrate_set_parameter_str(from
, "mode", "cpr-reboot");
2125 migrate_set_parameter_str(to
, "mode", "cpr-reboot");
2127 migrate_set_capability(from
, "x-ignore-shared", true);
2128 migrate_set_capability(to
, "x-ignore-shared", true);
2133 static void test_mode_reboot(void)
2135 g_autofree
char *uri
= g_strdup_printf("file:%s/%s", tmpfs
,
2136 FILE_TEST_FILENAME
);
2137 MigrateCommon args
= {
2138 .start
.use_shmem
= true,
2140 .listen_uri
= "defer",
2141 .start_hook
= test_mode_reboot_start
2144 test_file_common(&args
, true);
2147 static void test_precopy_tcp_plain(void)
2149 MigrateCommon args
= {
2150 .listen_uri
= "tcp:127.0.0.1:0",
2153 test_precopy_common(&args
);
2156 static void *test_migrate_switchover_ack_start(QTestState
*from
, QTestState
*to
)
2159 migrate_set_capability(from
, "return-path", true);
2160 migrate_set_capability(to
, "return-path", true);
2162 migrate_set_capability(from
, "switchover-ack", true);
2163 migrate_set_capability(to
, "switchover-ack", true);
2168 static void test_precopy_tcp_switchover_ack(void)
2170 MigrateCommon args
= {
2171 .listen_uri
= "tcp:127.0.0.1:0",
2172 .start_hook
= test_migrate_switchover_ack_start
,
2174 * Source VM must be running in order to consider the switchover ACK
2175 * when deciding to do switchover or not.
2180 test_precopy_common(&args
);
2183 #ifdef CONFIG_GNUTLS
2184 static void test_precopy_tcp_tls_psk_match(void)
2186 MigrateCommon args
= {
2187 .listen_uri
= "tcp:127.0.0.1:0",
2188 .start_hook
= test_migrate_tls_psk_start_match
,
2189 .finish_hook
= test_migrate_tls_psk_finish
,
2192 test_precopy_common(&args
);
2195 static void test_precopy_tcp_tls_psk_mismatch(void)
2197 MigrateCommon args
= {
2199 .hide_stderr
= true,
2201 .listen_uri
= "tcp:127.0.0.1:0",
2202 .start_hook
= test_migrate_tls_psk_start_mismatch
,
2203 .finish_hook
= test_migrate_tls_psk_finish
,
2204 .result
= MIG_TEST_FAIL
,
2207 test_precopy_common(&args
);
2211 static void test_precopy_tcp_tls_x509_default_host(void)
2213 MigrateCommon args
= {
2214 .listen_uri
= "tcp:127.0.0.1:0",
2215 .start_hook
= test_migrate_tls_x509_start_default_host
,
2216 .finish_hook
= test_migrate_tls_x509_finish
,
2219 test_precopy_common(&args
);
2222 static void test_precopy_tcp_tls_x509_override_host(void)
2224 MigrateCommon args
= {
2225 .listen_uri
= "tcp:127.0.0.1:0",
2226 .start_hook
= test_migrate_tls_x509_start_override_host
,
2227 .finish_hook
= test_migrate_tls_x509_finish
,
2230 test_precopy_common(&args
);
2233 static void test_precopy_tcp_tls_x509_mismatch_host(void)
2235 MigrateCommon args
= {
2237 .hide_stderr
= true,
2239 .listen_uri
= "tcp:127.0.0.1:0",
2240 .start_hook
= test_migrate_tls_x509_start_mismatch_host
,
2241 .finish_hook
= test_migrate_tls_x509_finish
,
2242 .result
= MIG_TEST_FAIL_DEST_QUIT_ERR
,
2245 test_precopy_common(&args
);
2248 static void test_precopy_tcp_tls_x509_friendly_client(void)
2250 MigrateCommon args
= {
2251 .listen_uri
= "tcp:127.0.0.1:0",
2252 .start_hook
= test_migrate_tls_x509_start_friendly_client
,
2253 .finish_hook
= test_migrate_tls_x509_finish
,
2256 test_precopy_common(&args
);
2259 static void test_precopy_tcp_tls_x509_hostile_client(void)
2261 MigrateCommon args
= {
2263 .hide_stderr
= true,
2265 .listen_uri
= "tcp:127.0.0.1:0",
2266 .start_hook
= test_migrate_tls_x509_start_hostile_client
,
2267 .finish_hook
= test_migrate_tls_x509_finish
,
2268 .result
= MIG_TEST_FAIL
,
2271 test_precopy_common(&args
);
2274 static void test_precopy_tcp_tls_x509_allow_anon_client(void)
2276 MigrateCommon args
= {
2277 .listen_uri
= "tcp:127.0.0.1:0",
2278 .start_hook
= test_migrate_tls_x509_start_allow_anon_client
,
2279 .finish_hook
= test_migrate_tls_x509_finish
,
2282 test_precopy_common(&args
);
2285 static void test_precopy_tcp_tls_x509_reject_anon_client(void)
2287 MigrateCommon args
= {
2289 .hide_stderr
= true,
2291 .listen_uri
= "tcp:127.0.0.1:0",
2292 .start_hook
= test_migrate_tls_x509_start_reject_anon_client
,
2293 .finish_hook
= test_migrate_tls_x509_finish
,
2294 .result
= MIG_TEST_FAIL
,
2297 test_precopy_common(&args
);
2299 #endif /* CONFIG_TASN1 */
2300 #endif /* CONFIG_GNUTLS */
2303 static void *test_migrate_fd_start_hook(QTestState
*from
,
2309 /* Create two connected sockets for migration */
2310 ret
= qemu_socketpair(PF_LOCAL
, SOCK_STREAM
, 0, pair
);
2311 g_assert_cmpint(ret
, ==, 0);
2313 /* Send the 1st socket to the target */
2314 qtest_qmp_fds_assert_success(to
, &pair
[0], 1,
2315 "{ 'execute': 'getfd',"
2316 " 'arguments': { 'fdname': 'fd-mig' }}");
2319 /* Start incoming migration from the 1st socket */
2320 migrate_incoming_qmp(to
, "fd:fd-mig", "{}");
2322 /* Send the 2nd socket to the target */
2323 qtest_qmp_fds_assert_success(from
, &pair
[1], 1,
2324 "{ 'execute': 'getfd',"
2325 " 'arguments': { 'fdname': 'fd-mig' }}");
2331 static void test_migrate_fd_finish_hook(QTestState
*from
,
2336 const char *error_desc
;
2338 /* Test closing fds */
2339 /* We assume, that QEMU removes named fd from its list,
2340 * so this should fail */
2341 rsp
= qtest_qmp(from
, "{ 'execute': 'closefd',"
2342 " 'arguments': { 'fdname': 'fd-mig' }}");
2343 g_assert_true(qdict_haskey(rsp
, "error"));
2344 error_desc
= qdict_get_str(qdict_get_qdict(rsp
, "error"), "desc");
2345 g_assert_cmpstr(error_desc
, ==, "File descriptor named 'fd-mig' not found");
2348 rsp
= qtest_qmp(to
, "{ 'execute': 'closefd',"
2349 " 'arguments': { 'fdname': 'fd-mig' }}");
2350 g_assert_true(qdict_haskey(rsp
, "error"));
2351 error_desc
= qdict_get_str(qdict_get_qdict(rsp
, "error"), "desc");
2352 g_assert_cmpstr(error_desc
, ==, "File descriptor named 'fd-mig' not found");
2356 static void test_migrate_fd_proto(void)
2358 MigrateCommon args
= {
2359 .listen_uri
= "defer",
2360 .connect_uri
= "fd:fd-mig",
2361 .start_hook
= test_migrate_fd_start_hook
,
2362 .finish_hook
= test_migrate_fd_finish_hook
2364 test_precopy_common(&args
);
2368 static void do_test_validate_uuid(MigrateStart
*args
, bool should_fail
)
2370 g_autofree
char *uri
= g_strdup_printf("unix:%s/migsocket", tmpfs
);
2371 QTestState
*from
, *to
;
2373 if (test_migrate_start(&from
, &to
, uri
, args
)) {
2378 * UUID validation is at the begin of migration. So, the main process of
2379 * migration is not interesting for us here. Thus, set huge downtime for
2380 * very fast migration.
2382 migrate_set_parameter_int(from
, "downtime-limit", 1000000);
2383 migrate_set_capability(from
, "validate-uuid", true);
2385 /* Wait for the first serial output from the source */
2386 wait_for_serial("src_serial");
2388 migrate_qmp(from
, uri
, "{}");
2391 qtest_set_expected_status(to
, EXIT_FAILURE
);
2392 wait_for_migration_fail(from
, true);
2394 wait_for_migration_complete(from
);
2397 test_migrate_end(from
, to
, false);
2400 static void test_validate_uuid(void)
2402 MigrateStart args
= {
2403 .opts_source
= "-uuid 11111111-1111-1111-1111-111111111111",
2404 .opts_target
= "-uuid 11111111-1111-1111-1111-111111111111",
2407 do_test_validate_uuid(&args
, false);
2410 static void test_validate_uuid_error(void)
2412 MigrateStart args
= {
2413 .opts_source
= "-uuid 11111111-1111-1111-1111-111111111111",
2414 .opts_target
= "-uuid 22222222-2222-2222-2222-222222222222",
2415 .hide_stderr
= true,
2418 do_test_validate_uuid(&args
, true);
2421 static void test_validate_uuid_src_not_set(void)
2423 MigrateStart args
= {
2424 .opts_target
= "-uuid 22222222-2222-2222-2222-222222222222",
2425 .hide_stderr
= true,
2428 do_test_validate_uuid(&args
, false);
2431 static void test_validate_uuid_dst_not_set(void)
2433 MigrateStart args
= {
2434 .opts_source
= "-uuid 11111111-1111-1111-1111-111111111111",
2435 .hide_stderr
= true,
2438 do_test_validate_uuid(&args
, false);
2442 * The way auto_converge works, we need to do too many passes to
2443 * run this test. Auto_converge logic is only run once every
2444 * three iterations, so:
2446 * - 3 iterations without auto_converge enabled
2447 * - 3 iterations with pct = 5
2448 * - 3 iterations with pct = 30
2449 * - 3 iterations with pct = 55
2450 * - 3 iterations with pct = 80
2451 * - 3 iterations with pct = 95 (max(95, 80 + 25))
2453 * To make things even worse, we need to run the initial stage at
2454 * 3MB/s so we enter autoconverge even when host is (over)loaded.
2456 static void test_migrate_auto_converge(void)
2458 g_autofree
char *uri
= g_strdup_printf("unix:%s/migsocket", tmpfs
);
2459 MigrateStart args
= {};
2460 QTestState
*from
, *to
;
2464 * We want the test to be stable and as fast as possible.
2465 * E.g., with 1Gb/s bandwidth migration may pass without throttling,
2466 * so we need to decrease a bandwidth.
2468 const int64_t init_pct
= 5, inc_pct
= 25, max_pct
= 95;
2470 if (test_migrate_start(&from
, &to
, uri
, &args
)) {
2474 migrate_set_capability(from
, "auto-converge", true);
2475 migrate_set_parameter_int(from
, "cpu-throttle-initial", init_pct
);
2476 migrate_set_parameter_int(from
, "cpu-throttle-increment", inc_pct
);
2477 migrate_set_parameter_int(from
, "max-cpu-throttle", max_pct
);
2480 * Set the initial parameters so that the migration could not converge
2481 * without throttling.
2483 migrate_ensure_non_converge(from
);
2485 /* To check remaining size after precopy */
2486 migrate_set_capability(from
, "pause-before-switchover", true);
2488 /* Wait for the first serial output from the source */
2489 wait_for_serial("src_serial");
2491 migrate_qmp(from
, uri
, "{}");
2493 /* Wait for throttling begins */
2496 percentage
= read_migrate_property_int(from
, "cpu-throttle-percentage");
2497 if (percentage
!= 0) {
2501 g_assert_false(got_src_stop
);
2503 /* The first percentage of throttling should be at least init_pct */
2504 g_assert_cmpint(percentage
, >=, init_pct
);
2505 /* Now, when we tested that throttling works, let it converge */
2506 migrate_ensure_converge(from
);
2509 * Wait for pre-switchover status to check last throttle percentage
2510 * and remaining. These values will be zeroed later
2512 wait_for_migration_status(from
, "pre-switchover", NULL
);
2514 /* The final percentage of throttling shouldn't be greater than max_pct */
2515 percentage
= read_migrate_property_int(from
, "cpu-throttle-percentage");
2516 g_assert_cmpint(percentage
, <=, max_pct
);
2517 migrate_continue(from
, "pre-switchover");
2519 qtest_qmp_eventwait(to
, "RESUME");
2521 wait_for_serial("dest_serial");
2522 wait_for_migration_complete(from
);
2524 test_migrate_end(from
, to
, true);
2528 test_migrate_precopy_tcp_multifd_start_common(QTestState
*from
,
2532 migrate_set_parameter_int(from
, "multifd-channels", 16);
2533 migrate_set_parameter_int(to
, "multifd-channels", 16);
2535 migrate_set_parameter_str(from
, "multifd-compression", method
);
2536 migrate_set_parameter_str(to
, "multifd-compression", method
);
2538 migrate_set_capability(from
, "multifd", true);
2539 migrate_set_capability(to
, "multifd", true);
2541 /* Start incoming migration from the 1st socket */
2542 migrate_incoming_qmp(to
, "tcp:127.0.0.1:0", "{}");
2548 test_migrate_precopy_tcp_multifd_start(QTestState
*from
,
2551 return test_migrate_precopy_tcp_multifd_start_common(from
, to
, "none");
2555 test_migrate_precopy_tcp_multifd_zlib_start(QTestState
*from
,
2558 return test_migrate_precopy_tcp_multifd_start_common(from
, to
, "zlib");
2563 test_migrate_precopy_tcp_multifd_zstd_start(QTestState
*from
,
2566 return test_migrate_precopy_tcp_multifd_start_common(from
, to
, "zstd");
2568 #endif /* CONFIG_ZSTD */
2570 static void test_multifd_tcp_none(void)
2572 MigrateCommon args
= {
2573 .listen_uri
= "defer",
2574 .start_hook
= test_migrate_precopy_tcp_multifd_start
,
2576 * Multifd is more complicated than most of the features, it
2577 * directly takes guest page buffers when sending, make sure
2578 * everything will work alright even if guest page is changing.
2582 test_precopy_common(&args
);
2585 static void test_multifd_tcp_zlib(void)
2587 MigrateCommon args
= {
2588 .listen_uri
= "defer",
2589 .start_hook
= test_migrate_precopy_tcp_multifd_zlib_start
,
2591 test_precopy_common(&args
);
2595 static void test_multifd_tcp_zstd(void)
2597 MigrateCommon args
= {
2598 .listen_uri
= "defer",
2599 .start_hook
= test_migrate_precopy_tcp_multifd_zstd_start
,
2601 test_precopy_common(&args
);
2605 #ifdef CONFIG_GNUTLS
2607 test_migrate_multifd_tcp_tls_psk_start_match(QTestState
*from
,
2610 test_migrate_precopy_tcp_multifd_start_common(from
, to
, "none");
2611 return test_migrate_tls_psk_start_match(from
, to
);
2615 test_migrate_multifd_tcp_tls_psk_start_mismatch(QTestState
*from
,
2618 test_migrate_precopy_tcp_multifd_start_common(from
, to
, "none");
2619 return test_migrate_tls_psk_start_mismatch(from
, to
);
2624 test_migrate_multifd_tls_x509_start_default_host(QTestState
*from
,
2627 test_migrate_precopy_tcp_multifd_start_common(from
, to
, "none");
2628 return test_migrate_tls_x509_start_default_host(from
, to
);
2632 test_migrate_multifd_tls_x509_start_override_host(QTestState
*from
,
2635 test_migrate_precopy_tcp_multifd_start_common(from
, to
, "none");
2636 return test_migrate_tls_x509_start_override_host(from
, to
);
2640 test_migrate_multifd_tls_x509_start_mismatch_host(QTestState
*from
,
2643 test_migrate_precopy_tcp_multifd_start_common(from
, to
, "none");
2644 return test_migrate_tls_x509_start_mismatch_host(from
, to
);
2648 test_migrate_multifd_tls_x509_start_allow_anon_client(QTestState
*from
,
2651 test_migrate_precopy_tcp_multifd_start_common(from
, to
, "none");
2652 return test_migrate_tls_x509_start_allow_anon_client(from
, to
);
2656 test_migrate_multifd_tls_x509_start_reject_anon_client(QTestState
*from
,
2659 test_migrate_precopy_tcp_multifd_start_common(from
, to
, "none");
2660 return test_migrate_tls_x509_start_reject_anon_client(from
, to
);
2662 #endif /* CONFIG_TASN1 */
2664 static void test_multifd_tcp_tls_psk_match(void)
2666 MigrateCommon args
= {
2667 .listen_uri
= "defer",
2668 .start_hook
= test_migrate_multifd_tcp_tls_psk_start_match
,
2669 .finish_hook
= test_migrate_tls_psk_finish
,
2671 test_precopy_common(&args
);
2674 static void test_multifd_tcp_tls_psk_mismatch(void)
2676 MigrateCommon args
= {
2678 .hide_stderr
= true,
2680 .listen_uri
= "defer",
2681 .start_hook
= test_migrate_multifd_tcp_tls_psk_start_mismatch
,
2682 .finish_hook
= test_migrate_tls_psk_finish
,
2683 .result
= MIG_TEST_FAIL
,
2685 test_precopy_common(&args
);
2689 static void test_multifd_tcp_tls_x509_default_host(void)
2691 MigrateCommon args
= {
2692 .listen_uri
= "defer",
2693 .start_hook
= test_migrate_multifd_tls_x509_start_default_host
,
2694 .finish_hook
= test_migrate_tls_x509_finish
,
2696 test_precopy_common(&args
);
2699 static void test_multifd_tcp_tls_x509_override_host(void)
2701 MigrateCommon args
= {
2702 .listen_uri
= "defer",
2703 .start_hook
= test_migrate_multifd_tls_x509_start_override_host
,
2704 .finish_hook
= test_migrate_tls_x509_finish
,
2706 test_precopy_common(&args
);
2709 static void test_multifd_tcp_tls_x509_mismatch_host(void)
2712 * This has different behaviour to the non-multifd case.
2714 * In non-multifd case when client aborts due to mismatched
2715 * cert host, the server has already started trying to load
2716 * migration state, and so it exits with I/O failure.
2718 * In multifd case when client aborts due to mismatched
2719 * cert host, the server is still waiting for the other
2720 * multifd connections to arrive so hasn't started trying
2721 * to load migration state, and thus just aborts the migration
2724 MigrateCommon args
= {
2726 .hide_stderr
= true,
2728 .listen_uri
= "defer",
2729 .start_hook
= test_migrate_multifd_tls_x509_start_mismatch_host
,
2730 .finish_hook
= test_migrate_tls_x509_finish
,
2731 .result
= MIG_TEST_FAIL
,
2733 test_precopy_common(&args
);
2736 static void test_multifd_tcp_tls_x509_allow_anon_client(void)
2738 MigrateCommon args
= {
2739 .listen_uri
= "defer",
2740 .start_hook
= test_migrate_multifd_tls_x509_start_allow_anon_client
,
2741 .finish_hook
= test_migrate_tls_x509_finish
,
2743 test_precopy_common(&args
);
2746 static void test_multifd_tcp_tls_x509_reject_anon_client(void)
2748 MigrateCommon args
= {
2750 .hide_stderr
= true,
2752 .listen_uri
= "defer",
2753 .start_hook
= test_migrate_multifd_tls_x509_start_reject_anon_client
,
2754 .finish_hook
= test_migrate_tls_x509_finish
,
2755 .result
= MIG_TEST_FAIL
,
2757 test_precopy_common(&args
);
2759 #endif /* CONFIG_TASN1 */
2760 #endif /* CONFIG_GNUTLS */
2768 * launch another target
2771 * And see that it works
2773 static void test_multifd_tcp_cancel(void)
2775 MigrateStart args
= {
2776 .hide_stderr
= true,
2778 QTestState
*from
, *to
, *to2
;
2779 g_autofree
char *uri
= NULL
;
2781 if (test_migrate_start(&from
, &to
, "defer", &args
)) {
2785 migrate_ensure_non_converge(from
);
2786 migrate_prepare_for_dirty_mem(from
);
2788 migrate_set_parameter_int(from
, "multifd-channels", 16);
2789 migrate_set_parameter_int(to
, "multifd-channels", 16);
2791 migrate_set_capability(from
, "multifd", true);
2792 migrate_set_capability(to
, "multifd", true);
2794 /* Start incoming migration from the 1st socket */
2795 migrate_incoming_qmp(to
, "tcp:127.0.0.1:0", "{}");
2797 /* Wait for the first serial output from the source */
2798 wait_for_serial("src_serial");
2800 uri
= migrate_get_socket_address(to
, "socket-address");
2802 migrate_qmp(from
, uri
, "{}");
2804 migrate_wait_for_dirty_mem(from
, to
);
2806 migrate_cancel(from
);
2808 /* Make sure QEMU process "to" exited */
2809 qtest_set_expected_status(to
, EXIT_FAILURE
);
2810 qtest_wait_qemu(to
);
2812 args
= (MigrateStart
){
2813 .only_target
= true,
2816 if (test_migrate_start(&from
, &to2
, "defer", &args
)) {
2820 migrate_set_parameter_int(to2
, "multifd-channels", 16);
2822 migrate_set_capability(to2
, "multifd", true);
2824 /* Start incoming migration from the 1st socket */
2825 migrate_incoming_qmp(to2
, "tcp:127.0.0.1:0", "{}");
2828 uri
= migrate_get_socket_address(to2
, "socket-address");
2830 wait_for_migration_status(from
, "cancelled", NULL
);
2832 migrate_ensure_non_converge(from
);
2834 migrate_qmp(from
, uri
, "{}");
2836 migrate_wait_for_dirty_mem(from
, to2
);
2838 migrate_ensure_converge(from
);
2840 if (!got_src_stop
) {
2841 qtest_qmp_eventwait(from
, "STOP");
2843 qtest_qmp_eventwait(to2
, "RESUME");
2845 wait_for_serial("dest_serial");
2846 wait_for_migration_complete(from
);
2847 test_migrate_end(from
, to2
, true);
2850 static void calc_dirty_rate(QTestState
*who
, uint64_t calc_time
)
2852 qtest_qmp_assert_success(who
,
2853 "{ 'execute': 'calc-dirty-rate',"
2855 "'calc-time': %" PRIu64
","
2856 "'mode': 'dirty-ring' }}",
2860 static QDict
*query_dirty_rate(QTestState
*who
)
2862 return qtest_qmp_assert_success_ref(who
,
2863 "{ 'execute': 'query-dirty-rate' }");
2866 static void dirtylimit_set_all(QTestState
*who
, uint64_t dirtyrate
)
2868 qtest_qmp_assert_success(who
,
2869 "{ 'execute': 'set-vcpu-dirty-limit',"
2871 "'dirty-rate': %" PRIu64
" } }",
2875 static void cancel_vcpu_dirty_limit(QTestState
*who
)
2877 qtest_qmp_assert_success(who
,
2878 "{ 'execute': 'cancel-vcpu-dirty-limit' }");
2881 static QDict
*query_vcpu_dirty_limit(QTestState
*who
)
2885 rsp
= qtest_qmp(who
, "{ 'execute': 'query-vcpu-dirty-limit' }");
2886 g_assert(!qdict_haskey(rsp
, "error"));
2887 g_assert(qdict_haskey(rsp
, "return"));
2892 static bool calc_dirtyrate_ready(QTestState
*who
)
2897 rsp_return
= query_dirty_rate(who
);
2898 g_assert(rsp_return
);
2900 status
= g_strdup(qdict_get_str(rsp_return
, "status"));
2903 return g_strcmp0(status
, "measuring");
2906 static void wait_for_calc_dirtyrate_complete(QTestState
*who
,
2909 int max_try_count
= 10000;
2910 usleep(time_s
* 1000000);
2912 while (!calc_dirtyrate_ready(who
) && max_try_count
--) {
2917 * Set the timeout with 10 s(max_try_count * 1000us),
2918 * if dirtyrate measurement not complete, fail test.
2920 g_assert_cmpint(max_try_count
, !=, 0);
2923 static int64_t get_dirty_rate(QTestState
*who
)
2928 const QListEntry
*entry
;
2932 rsp_return
= query_dirty_rate(who
);
2933 g_assert(rsp_return
);
2935 status
= g_strdup(qdict_get_str(rsp_return
, "status"));
2937 g_assert_cmpstr(status
, ==, "measured");
2939 rates
= qdict_get_qlist(rsp_return
, "vcpu-dirty-rate");
2940 g_assert(rates
&& !qlist_empty(rates
));
2942 entry
= qlist_first(rates
);
2945 rate
= qobject_to(QDict
, qlist_entry_obj(entry
));
2948 dirtyrate
= qdict_get_try_int(rate
, "dirty-rate", -1);
2950 qobject_unref(rsp_return
);
2954 static int64_t get_limit_rate(QTestState
*who
)
2958 const QListEntry
*entry
;
2962 rsp_return
= query_vcpu_dirty_limit(who
);
2963 g_assert(rsp_return
);
2965 rates
= qdict_get_qlist(rsp_return
, "return");
2966 g_assert(rates
&& !qlist_empty(rates
));
2968 entry
= qlist_first(rates
);
2971 rate
= qobject_to(QDict
, qlist_entry_obj(entry
));
2974 dirtyrate
= qdict_get_try_int(rate
, "limit-rate", -1);
2976 qobject_unref(rsp_return
);
2980 static QTestState
*dirtylimit_start_vm(void)
2982 QTestState
*vm
= NULL
;
2984 cmd
= g_strdup_printf("-accel kvm,dirty-ring-size=4096 "
2985 "-name dirtylimit-test,debug-threads=on "
2987 "-serial file:%s/vm_serial "
2988 "-drive file=%s,format=raw ",
2991 vm
= qtest_init(cmd
);
2995 static void dirtylimit_stop_vm(QTestState
*vm
)
2998 cleanup("vm_serial");
3001 static void test_vcpu_dirty_limit(void)
3004 int64_t origin_rate
;
3007 int max_try_count
= 20;
3010 /* Start vm for vcpu dirtylimit test */
3011 vm
= dirtylimit_start_vm();
3013 /* Wait for the first serial output from the vm*/
3014 wait_for_serial("vm_serial");
3016 /* Do dirtyrate measurement with calc time equals 1s */
3017 calc_dirty_rate(vm
, 1);
3019 /* Sleep calc time and wait for calc dirtyrate complete */
3020 wait_for_calc_dirtyrate_complete(vm
, 1);
3022 /* Query original dirty page rate */
3023 origin_rate
= get_dirty_rate(vm
);
3025 /* VM booted from bootsect should dirty memory steadily */
3026 assert(origin_rate
!= 0);
3028 /* Setup quota dirty page rate at half of origin */
3029 quota_rate
= origin_rate
/ 2;
3031 /* Set dirtylimit */
3032 dirtylimit_set_all(vm
, quota_rate
);
3035 * Check if set-vcpu-dirty-limit and query-vcpu-dirty-limit
3038 g_assert_cmpint(quota_rate
, ==, get_limit_rate(vm
));
3040 /* Sleep a bit to check if it take effect */
3044 * Check if dirtylimit take effect realistically, set the
3045 * timeout with 20 s(max_try_count * 1s), if dirtylimit
3046 * doesn't take effect, fail test.
3048 while (--max_try_count
) {
3049 calc_dirty_rate(vm
, 1);
3050 wait_for_calc_dirtyrate_complete(vm
, 1);
3051 rate
= get_dirty_rate(vm
);
3054 * Assume hitting if current rate is less
3055 * than quota rate (within accepting error)
3057 if (rate
< (quota_rate
+ DIRTYLIMIT_TOLERANCE_RANGE
)) {
3063 g_assert_cmpint(hit
, ==, 1);
3068 /* Check if dirtylimit cancellation take effect */
3069 cancel_vcpu_dirty_limit(vm
);
3070 while (--max_try_count
) {
3071 calc_dirty_rate(vm
, 1);
3072 wait_for_calc_dirtyrate_complete(vm
, 1);
3073 rate
= get_dirty_rate(vm
);
3076 * Assume dirtylimit be canceled if current rate is
3077 * greater than quota rate (within accepting error)
3079 if (rate
> (quota_rate
+ DIRTYLIMIT_TOLERANCE_RANGE
)) {
3085 g_assert_cmpint(hit
, ==, 1);
3086 dirtylimit_stop_vm(vm
);
3089 static bool kvm_dirty_ring_supported(void)
3091 #if defined(__linux__) && defined(HOST_X86_64)
3092 int ret
, kvm_fd
= open("/dev/kvm", O_RDONLY
);
3098 ret
= ioctl(kvm_fd
, KVM_CHECK_EXTENSION
, KVM_CAP_DIRTY_LOG_RING
);
3101 /* We test with 4096 slots */
3112 int main(int argc
, char **argv
)
3114 bool has_kvm
, has_tcg
;
3117 g_autoptr(GError
) err
= NULL
;
3118 const char *qemu_src
= getenv(QEMU_ENV_SRC
);
3119 const char *qemu_dst
= getenv(QEMU_ENV_DST
);
3122 g_test_init(&argc
, &argv
, NULL
);
3125 * The default QTEST_QEMU_BINARY must always be provided because
3126 * that is what helpers use to query the accel type and
3129 if (qemu_src
&& qemu_dst
) {
3130 g_test_message("Only one of %s, %s is allowed",
3131 QEMU_ENV_SRC
, QEMU_ENV_DST
);
3135 has_kvm
= qtest_has_accel("kvm");
3136 has_tcg
= qtest_has_accel("tcg");
3138 if (!has_tcg
&& !has_kvm
) {
3139 g_test_skip("No KVM or TCG accelerator available");
3143 has_uffd
= ufd_version_check();
3144 arch
= qtest_get_arch();
3147 * On ppc64, the test only works with kvm-hv, but not with kvm-pr and TCG
3148 * is touchy due to race conditions on dirty bits (especially on PPC for
3151 if (g_str_equal(arch
, "ppc64") &&
3152 (!has_kvm
|| access("/sys/module/kvm_hv", F_OK
))) {
3153 g_test_message("Skipping test: kvm_hv not available");
3154 return g_test_run();
3158 * Similar to ppc64, s390x seems to be touchy with TCG, so disable it
3159 * there until the problems are resolved
3161 if (g_str_equal(arch
, "s390x") && !has_kvm
) {
3162 g_test_message("Skipping test: s390x host with KVM is required");
3163 return g_test_run();
3166 tmpfs
= g_dir_make_tmp("migration-test-XXXXXX", &err
);
3168 g_test_message("Can't create temporary directory in %s: %s",
3169 g_get_tmp_dir(), err
->message
);
3172 bootfile_create(tmpfs
);
3174 module_call_init(MODULE_INIT_QOM
);
3177 qtest_add_func("/migration/postcopy/plain", test_postcopy
);
3178 qtest_add_func("/migration/postcopy/recovery/plain",
3179 test_postcopy_recovery
);
3180 qtest_add_func("/migration/postcopy/preempt/plain", test_postcopy_preempt
);
3181 qtest_add_func("/migration/postcopy/preempt/recovery/plain",
3182 test_postcopy_preempt_recovery
);
3183 if (getenv("QEMU_TEST_FLAKY_TESTS")) {
3184 qtest_add_func("/migration/postcopy/compress/plain",
3185 test_postcopy_compress
);
3186 qtest_add_func("/migration/postcopy/recovery/compress/plain",
3187 test_postcopy_recovery_compress
);
3190 qtest_add_func("/migration/postcopy/recovery/double-failures",
3191 test_postcopy_recovery_double_fail
);
3196 qtest_add_func("/migration/bad_dest", test_baddest
);
3198 if (!g_str_equal(arch
, "s390x")) {
3199 qtest_add_func("/migration/analyze-script", test_analyze_script
);
3202 qtest_add_func("/migration/precopy/unix/plain", test_precopy_unix_plain
);
3203 qtest_add_func("/migration/precopy/unix/xbzrle", test_precopy_unix_xbzrle
);
3205 * Compression fails from time to time.
3206 * Put test here but don't enable it until everything is fixed.
3208 if (getenv("QEMU_TEST_FLAKY_TESTS")) {
3209 qtest_add_func("/migration/precopy/unix/compress/wait",
3210 test_precopy_unix_compress
);
3211 qtest_add_func("/migration/precopy/unix/compress/nowait",
3212 test_precopy_unix_compress_nowait
);
3215 qtest_add_func("/migration/precopy/file",
3217 qtest_add_func("/migration/precopy/file/offset",
3218 test_precopy_file_offset
);
3219 qtest_add_func("/migration/precopy/file/offset/bad",
3220 test_precopy_file_offset_bad
);
3223 * Our CI system has problems with shared memory.
3224 * Don't run this test until we find a workaround.
3226 if (getenv("QEMU_TEST_FLAKY_TESTS")) {
3227 qtest_add_func("/migration/mode/reboot", test_mode_reboot
);
3230 #ifdef CONFIG_GNUTLS
3231 qtest_add_func("/migration/precopy/unix/tls/psk",
3232 test_precopy_unix_tls_psk
);
3236 * NOTE: psk test is enough for postcopy, as other types of TLS
3237 * channels are tested under precopy. Here what we want to test is the
3238 * general postcopy path that has TLS channel enabled.
3240 qtest_add_func("/migration/postcopy/tls/psk", test_postcopy_tls_psk
);
3241 qtest_add_func("/migration/postcopy/recovery/tls/psk",
3242 test_postcopy_recovery_tls_psk
);
3243 qtest_add_func("/migration/postcopy/preempt/tls/psk",
3244 test_postcopy_preempt_tls_psk
);
3245 qtest_add_func("/migration/postcopy/preempt/recovery/tls/psk",
3246 test_postcopy_preempt_all
);
3249 qtest_add_func("/migration/precopy/unix/tls/x509/default-host",
3250 test_precopy_unix_tls_x509_default_host
);
3251 qtest_add_func("/migration/precopy/unix/tls/x509/override-host",
3252 test_precopy_unix_tls_x509_override_host
);
3253 #endif /* CONFIG_TASN1 */
3254 #endif /* CONFIG_GNUTLS */
3256 qtest_add_func("/migration/precopy/tcp/plain", test_precopy_tcp_plain
);
3258 qtest_add_func("/migration/precopy/tcp/plain/switchover-ack",
3259 test_precopy_tcp_switchover_ack
);
3261 #ifdef CONFIG_GNUTLS
3262 qtest_add_func("/migration/precopy/tcp/tls/psk/match",
3263 test_precopy_tcp_tls_psk_match
);
3264 qtest_add_func("/migration/precopy/tcp/tls/psk/mismatch",
3265 test_precopy_tcp_tls_psk_mismatch
);
3267 qtest_add_func("/migration/precopy/tcp/tls/x509/default-host",
3268 test_precopy_tcp_tls_x509_default_host
);
3269 qtest_add_func("/migration/precopy/tcp/tls/x509/override-host",
3270 test_precopy_tcp_tls_x509_override_host
);
3271 qtest_add_func("/migration/precopy/tcp/tls/x509/mismatch-host",
3272 test_precopy_tcp_tls_x509_mismatch_host
);
3273 qtest_add_func("/migration/precopy/tcp/tls/x509/friendly-client",
3274 test_precopy_tcp_tls_x509_friendly_client
);
3275 qtest_add_func("/migration/precopy/tcp/tls/x509/hostile-client",
3276 test_precopy_tcp_tls_x509_hostile_client
);
3277 qtest_add_func("/migration/precopy/tcp/tls/x509/allow-anon-client",
3278 test_precopy_tcp_tls_x509_allow_anon_client
);
3279 qtest_add_func("/migration/precopy/tcp/tls/x509/reject-anon-client",
3280 test_precopy_tcp_tls_x509_reject_anon_client
);
3281 #endif /* CONFIG_TASN1 */
3282 #endif /* CONFIG_GNUTLS */
3284 /* qtest_add_func("/migration/ignore_shared", test_ignore_shared); */
3286 qtest_add_func("/migration/fd_proto", test_migrate_fd_proto
);
3288 qtest_add_func("/migration/validate_uuid", test_validate_uuid
);
3289 qtest_add_func("/migration/validate_uuid_error", test_validate_uuid_error
);
3290 qtest_add_func("/migration/validate_uuid_src_not_set",
3291 test_validate_uuid_src_not_set
);
3292 qtest_add_func("/migration/validate_uuid_dst_not_set",
3293 test_validate_uuid_dst_not_set
);
3295 * See explanation why this test is slow on function definition
3297 if (g_test_slow()) {
3298 qtest_add_func("/migration/auto_converge", test_migrate_auto_converge
);
3300 qtest_add_func("/migration/multifd/tcp/plain/none",
3301 test_multifd_tcp_none
);
3303 * This test is flaky and sometimes fails in CI and otherwise:
3304 * don't run unless user opts in via environment variable.
3306 if (getenv("QEMU_TEST_FLAKY_TESTS")) {
3307 qtest_add_func("/migration/multifd/tcp/plain/cancel",
3308 test_multifd_tcp_cancel
);
3310 qtest_add_func("/migration/multifd/tcp/plain/zlib",
3311 test_multifd_tcp_zlib
);
3313 qtest_add_func("/migration/multifd/tcp/plain/zstd",
3314 test_multifd_tcp_zstd
);
3316 #ifdef CONFIG_GNUTLS
3317 qtest_add_func("/migration/multifd/tcp/tls/psk/match",
3318 test_multifd_tcp_tls_psk_match
);
3319 qtest_add_func("/migration/multifd/tcp/tls/psk/mismatch",
3320 test_multifd_tcp_tls_psk_mismatch
);
3322 qtest_add_func("/migration/multifd/tcp/tls/x509/default-host",
3323 test_multifd_tcp_tls_x509_default_host
);
3324 qtest_add_func("/migration/multifd/tcp/tls/x509/override-host",
3325 test_multifd_tcp_tls_x509_override_host
);
3326 qtest_add_func("/migration/multifd/tcp/tls/x509/mismatch-host",
3327 test_multifd_tcp_tls_x509_mismatch_host
);
3328 qtest_add_func("/migration/multifd/tcp/tls/x509/allow-anon-client",
3329 test_multifd_tcp_tls_x509_allow_anon_client
);
3330 qtest_add_func("/migration/multifd/tcp/tls/x509/reject-anon-client",
3331 test_multifd_tcp_tls_x509_reject_anon_client
);
3332 #endif /* CONFIG_TASN1 */
3333 #endif /* CONFIG_GNUTLS */
3335 if (g_str_equal(arch
, "x86_64") && has_kvm
&& kvm_dirty_ring_supported()) {
3336 qtest_add_func("/migration/dirty_ring",
3337 test_precopy_unix_dirty_ring
);
3338 qtest_add_func("/migration/vcpu_dirty_limit",
3339 test_vcpu_dirty_limit
);
3344 g_assert_cmpint(ret
, ==, 0);
3349 g_test_message("unable to rmdir: path (%s): %s",
3350 tmpfs
, strerror(errno
));