Lines Matching +full:keep +full:- +full:a +full:- +full:live
2 * Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates
3 * based on the vhost-user-test.c that is:
7 * See the COPYING file in the top-level directory.
18 #include "migration/migration-qmp.h"
19 #include "migration/migration-util.h"
20 #include "ppc-util.h"
46 * A further 1k is added to ensure we're not a multiple
57 * we get an 'A' followed by an endless string of 'B's
58 * but on the destination we won't have the A (unless we enabled suspend/resume)
69 case 'A': in wait_for_serial()
97 * IOW, if we write to mem at a point which is NOT in migrate_prepare_for_dirty_mem()
98 * a multiple of TEST_MEM_PAGE_SIZE, our write won't in migrate_prepare_for_dirty_mem()
101 * We put in a marker here, that we'll use to determine in migrate_prepare_for_dirty_mem()
115 * indicator that a migration pass has made some known in migrate_wait_for_dirty_mem()
133 * as we'll eventually see a different value if we in migrate_wait_for_dirty_mem()
134 * keep watching in migrate_wait_for_dirty_mem()
146 * start_address to < end_address in order. This gives us a constraint in check_guests_ram()
187 fprintf(stderr, "and in another %d pages", bad - 10); in check_guests_ram()
203 if (args->oob) { in migrate_start_get_qmp_capabilities()
230 if (args->use_shmem) { in migrate_start()
233 return -1; in migrate_start()
239 bootpath = bootfile_create(arch, tmpfs, args->suspend_me); in migrate_start()
240 src_state.suspend_me = args->suspend_me; in migrate_start()
251 "-drive if=none,id=d0,file=%s,format=raw " in migrate_start()
252 "-device ide-hd,drive=d0,secs=1,cyls=1,heads=1", bootpath); in migrate_start()
257 machine_alias = "s390-ccw-virtio"; in migrate_start()
258 arch_opts = g_strdup_printf("-bios %s", bootpath); in migrate_start()
268 "-nodefaults -machine " PSERIES_DEFAULT_CAPABILITIES " " in migrate_start()
269 "-bios %s", bootpath); in migrate_start()
273 machine_opts = "gic-version=3"; in migrate_start()
274 arch_opts = g_strdup_printf("-cpu max -kernel %s", bootpath); in migrate_start()
281 if (!getenv("QTEST_LOG") && args->hide_stderr) { in migrate_start()
296 if (args->use_shmem) { in migrate_start()
297 shmem_path = g_strdup_printf("/dev/shm/qemu-%d", getpid()); in migrate_start()
299 "-object memory-backend-file,id=mem0,size=%s" in migrate_start()
300 ",mem-path=%s,share=on -numa node,memdev=mem0", in migrate_start()
304 if (args->memory_backend) { in migrate_start()
305 memory_backend = g_strdup_printf(args->memory_backend, memory_size); in migrate_start()
307 memory_backend = g_strdup_printf("-m %s ", memory_size); in migrate_start()
310 if (args->use_dirty_ring) { in migrate_start()
311 kvm_opts = ",dirty-ring-size=4096"; in migrate_start()
317 return -1; in migrate_start()
325 cmd_source = g_strdup_printf("-accel kvm%s -accel tcg " in migrate_start()
326 "-machine %s,%s " in migrate_start()
327 "-name source,debug-threads=on " in migrate_start()
329 "-serial file:%s/src_serial " in migrate_start()
336 args->opts_source ? args->opts_source : "", in migrate_start()
338 if (!args->only_target) { in migrate_start()
351 events = args->defer_target_connect ? "-global migration.x-events=on" : ""; in migrate_start()
353 cmd_target = g_strdup_printf("-accel kvm%s -accel tcg " in migrate_start()
354 "-machine %s,%s " in migrate_start()
355 "-name target,debug-threads=on " in migrate_start()
357 "-serial file:%s/dest_serial " in migrate_start()
358 "-incoming %s " in migrate_start()
366 args->opts_target ? args->opts_target : "", in migrate_start()
369 capabilities, !args->defer_target_connect); in migrate_start()
378 if (args->use_shmem) { in migrate_start()
387 if (!args->defer_target_connect) { in migrate_start()
403 /* Destination still running, wait for a byte to change */ in migrate_end()
435 if (migrate_start(&from, &to, "defer", &args->start)) { in migrate_postcopy_prepare()
436 return -1; in migrate_postcopy_prepare()
439 if (args->start_hook) { in migrate_postcopy_prepare()
440 args->postcopy_data = args->start_hook(from, to); in migrate_postcopy_prepare()
443 migrate_set_capability(from, "postcopy-ram", true); in migrate_postcopy_prepare()
444 migrate_set_capability(to, "postcopy-ram", true); in migrate_postcopy_prepare()
445 migrate_set_capability(to, "postcopy-blocktime", true); in migrate_postcopy_prepare()
447 if (args->postcopy_preempt) { in migrate_postcopy_prepare()
448 migrate_set_capability(from, "postcopy-preempt", true); in migrate_postcopy_prepare()
449 migrate_set_capability(to, "postcopy-preempt", true); in migrate_postcopy_prepare()
455 qtest_qmp_assert_success(to, "{ 'execute': 'migrate-incoming'," in migrate_postcopy_prepare()
457 " 'channels': [ { 'channel-type': 'main'," in migrate_postcopy_prepare()
484 if (args->start.suspend_me) { in migrate_postcopy_complete()
492 if (env->uffd_feature_thread_id) { in migrate_postcopy_complete()
496 if (args->end_hook) { in migrate_postcopy_complete()
497 args->end_hook(from, to, args->postcopy_data); in migrate_postcopy_complete()
498 args->postcopy_data = NULL; in migrate_postcopy_complete()
543 * at reading. This mimics a wrong channel established. in postcopy_recover_fail()
547 " 'arguments': { 'fdname': 'fd-mig' }}"); in postcopy_recover_fail()
550 " 'arguments': { 'fdname': 'fd-mig' }}"); in postcopy_recover_fail()
554 * emulate the 1st byte of a real recovery, but stops from there to in postcopy_recover_fail()
555 * keep dest QEMU in RECOVER. This is needed so that we can kick off in postcopy_recover_fail()
559 * rely on an pre-existing G_IO_IN event, so it will always trigger the in postcopy_recover_fail()
575 migrate_recover(to, "fd:fd-mig"); in postcopy_recover_fail()
576 migrate_qmp(from, to, "fd:fd-mig", NULL, "{'resume': true}"); in postcopy_recover_fail()
582 migration_event_wait(from, "postcopy-recover-setup"); in postcopy_recover_fail()
591 migration_event_wait(from, "postcopy-paused"); in postcopy_recover_fail()
596 * kicking them out using migrate-pause. in postcopy_recover_fail()
601 migration_event_wait(from, "postcopy-recover"); in postcopy_recover_fail()
602 wait_for_postcopy_status(from, "postcopy-recover"); in postcopy_recover_fail()
612 wait_for_postcopy_status(from, "postcopy-paused"); in postcopy_recover_fail()
613 wait_for_postcopy_status(to, "postcopy-recover"); in postcopy_recover_fail()
622 wait_for_postcopy_status(to, "postcopy-paused"); in postcopy_recover_fail()
640 * Always enable OOB QMP capability for recovery tests, migrate-recover is in test_postcopy_recovery_common()
641 * executed out-of-band in test_postcopy_recovery_common()
643 args->start.oob = true; in test_postcopy_recovery_common()
646 args->start.hide_stderr = true; in test_postcopy_recovery_common()
653 migrate_set_parameter_int(from, "max-postcopy-bandwidth", 4096); in test_postcopy_recovery_common()
660 * migrate-pause command during a postcopy in test_postcopy_recovery_common()
662 wait_for_migration_status(from, "postcopy-active", NULL); in test_postcopy_recovery_common()
665 * Manually stop the postcopy migration. This emulates a network in test_postcopy_recovery_common()
671 * Wait for destination side to reach postcopy-paused state. The in test_postcopy_recovery_common()
672 * migrate-recover command can only succeed if destination machine in test_postcopy_recovery_common()
675 wait_for_postcopy_status(to, "postcopy-paused"); in test_postcopy_recovery_common()
676 wait_for_postcopy_status(from, "postcopy-paused"); in test_postcopy_recovery_common()
678 if (args->postcopy_recovery_fail_stage) { in test_postcopy_recovery_common()
680 * Test when a wrong socket specified for recover, and then the in test_postcopy_recovery_common()
681 * ability to kick it out, and continue with a correct socket. in test_postcopy_recovery_common()
683 postcopy_recover_fail(from, to, args->postcopy_recovery_fail_stage); in test_postcopy_recovery_common()
684 /* continue with a good recovery */ in test_postcopy_recovery_common()
688 * Create a new socket to emulate a new channel that is different in test_postcopy_recovery_common()
692 uri = g_strdup_printf("unix:%s/migsocket-recover", tmpfs); in test_postcopy_recovery_common()
702 migrate_set_parameter_int(from, "max-postcopy-bandwidth", 0); in test_postcopy_recovery_common()
714 g_assert(!args->cpr_channel || args->connect_channels); in test_precopy_common()
716 if (migrate_start(&from, &to, args->listen_uri, &args->start)) { in test_precopy_common()
720 if (args->start_hook) { in test_precopy_common()
721 data_hook = args->start_hook(from, to); in test_precopy_common()
725 if (args->result == MIG_TEST_SUCCEED) { in test_precopy_common()
730 if (args->live) { in test_precopy_common()
735 * Testing non-live migration, we allow it to run at in test_precopy_common()
740 if (args->result == MIG_TEST_SUCCEED) { in test_precopy_common()
749 * migrate-incoming channels. in test_precopy_common()
751 if (args->connect_channels) { in test_precopy_common()
752 if (args->start.defer_target_connect && in test_precopy_common()
753 !strcmp(args->listen_uri, "defer")) { in test_precopy_common()
754 in_channels = qobject_from_json(args->connect_channels, in test_precopy_common()
757 out_channels = qobject_from_json(args->connect_channels, &error_abort); in test_precopy_common()
759 if (args->cpr_channel) { in test_precopy_common()
761 QObject *obj = migrate_str_to_channel(args->cpr_channel); in test_precopy_common()
767 if (args->result == MIG_TEST_QMP_ERROR) { in test_precopy_common()
768 migrate_qmp_fail(from, args->connect_uri, out_channels, "{}"); in test_precopy_common()
772 migrate_qmp(from, to, args->connect_uri, out_channels, "{}"); in test_precopy_common()
774 if (args->start.defer_target_connect) { in test_precopy_common()
777 if (!strcmp(args->listen_uri, "defer")) { in test_precopy_common()
778 migrate_incoming_qmp(to, args->connect_uri, in_channels, "{}"); in test_precopy_common()
782 if (args->result != MIG_TEST_SUCCEED) { in test_precopy_common()
783 bool allow_active = args->result == MIG_TEST_FAIL; in test_precopy_common()
786 if (args->result == MIG_TEST_FAIL_DEST_QUIT_ERR) { in test_precopy_common()
790 if (args->live) { in test_precopy_common()
792 * For initial iteration(s) we must do a full pass, in test_precopy_common()
796 while (args->iterations > 1) { in test_precopy_common()
798 args->iterations--; in test_precopy_common()
805 * We do this first, as it has a timeout to stop us in test_precopy_common()
826 if (args->start.suspend_me) { in test_precopy_common()
835 if (args->end_hook) { in test_precopy_common()
836 args->end_hook(from, to, data_hook); in test_precopy_common()
839 migrate_end(from, to, args->result == MIG_TEST_SUCCEED); in test_precopy_common()
880 if (migrate_start(&from, &to, args->listen_uri, &args->start)) { in test_file_common()
885 * File migration is never live. We can keep the source VM running in test_file_common()
889 g_assert_false(args->live); in test_file_common()
891 if (g_strrstr(args->connect_uri, "offset=")) { in test_file_common()
895 * a management application creating the file and writing to in test_file_common()
901 if (args->start_hook) { in test_file_common()
902 data_hook = args->start_hook(from, to); in test_file_common()
913 if (args->result == MIG_TEST_QMP_ERROR) { in test_file_common()
914 migrate_qmp_fail(from, args->connect_uri, NULL, "{}"); in test_file_common()
918 migrate_qmp(from, to, args->connect_uri, NULL, "{}"); in test_file_common()
925 migrate_incoming_qmp(to, args->connect_uri, NULL, "{}"); in test_file_common()
940 if (args->end_hook) { in test_file_common()
941 args->end_hook(from, to, data_hook); in test_file_common()
944 migrate_end(from, to, args->result == MIG_TEST_SUCCEED); in test_file_common()
951 migrate_set_parameter_int(from, "multifd-channels", 16); in migrate_hook_start_precopy_tcp_multifd_common()
952 migrate_set_parameter_int(to, "multifd-channels", 16); in migrate_hook_start_precopy_tcp_multifd_common()
954 migrate_set_parameter_str(from, "multifd-compression", method); in migrate_hook_start_precopy_tcp_multifd_common()
955 migrate_set_parameter_str(to, "multifd-compression", method); in migrate_hook_start_precopy_tcp_multifd_common()
981 env->qemu_src = getenv(QEMU_ENV_SRC); in migration_get_env()
982 env->qemu_dst = getenv(QEMU_ENV_DST); in migration_get_env()
989 if (env->qemu_src && env->qemu_dst) { in migration_get_env()
995 env->has_kvm = qtest_has_accel("kvm"); in migration_get_env()
996 env->has_tcg = qtest_has_accel("tcg"); in migration_get_env()
998 if (!env->has_tcg && !env->has_kvm) { in migration_get_env()
1003 env->has_dirty_ring = kvm_dirty_ring_supported(); in migration_get_env()
1004 env->has_uffd = ufd_version_check(&env->uffd_feature_thread_id); in migration_get_env()
1005 env->arch = qtest_get_arch(); in migration_get_env()
1006 env->is_x86 = !strcmp(env->arch, "i386") || !strcmp(env->arch, "x86_64"); in migration_get_env()
1008 env->tmpfs = g_dir_make_tmp("migration-test-XXXXXX", &err); in migration_get_env()
1009 if (!env->tmpfs) { in migration_get_env()
1011 g_get_tmp_dir(), err->message); in migration_get_env()
1013 g_assert(env->tmpfs); in migration_get_env()
1015 tmpfs = env->tmpfs; in migration_get_env()
1031 tmpfs = env->tmpfs; in migration_env_clean()