1 /* 2 * QTest testcases for CPR 3 * 4 * Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates 5 * based on the vhost-user-test.c that is: 6 * Copyright (c) 2014 Virtual Open Systems Sarl. 7 * 8 * This work is licensed under the terms of the GNU GPL, version 2 or later. 9 * See the COPYING file in the top-level directory. 10 * 11 */ 12 13 #include "qemu/osdep.h" 14 #include "libqtest.h" 15 #include "migration/framework.h" 16 #include "migration/migration-qmp.h" 17 #include "migration/migration-util.h" 18 19 20 static char *tmpfs; 21 22 static void *migrate_hook_start_mode_reboot(QTestState *from, QTestState *to) 23 { 24 migrate_set_parameter_str(from, "mode", "cpr-reboot"); 25 migrate_set_parameter_str(to, "mode", "cpr-reboot"); 26 27 migrate_set_capability(from, "x-ignore-shared", true); 28 migrate_set_capability(to, "x-ignore-shared", true); 29 30 return NULL; 31 } 32 33 static void test_mode_reboot(void) 34 { 35 g_autofree char *uri = g_strdup_printf("file:%s/%s", tmpfs, 36 FILE_TEST_FILENAME); 37 MigrateCommon args = { 38 .start.use_shmem = true, 39 .connect_uri = uri, 40 .listen_uri = "defer", 41 .start_hook = migrate_hook_start_mode_reboot, 42 }; 43 44 test_file_common(&args, true); 45 } 46 47 void migration_test_add_cpr(MigrationTestEnv *env) 48 { 49 tmpfs = env->tmpfs; 50 51 /* 52 * Our CI system has problems with shared memory. 53 * Don't run this test until we find a workaround. 54 */ 55 if (getenv("QEMU_TEST_FLAKY_TESTS")) { 56 migration_test_add("/migration/mode/reboot", test_mode_reboot); 57 } 58 } 59