]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | # Set -m option is needed to be able to use "suspend" command |
2 | # as we are usin non-interactive session to connect to remote. | |
3 | # Without -m it would be not possible to suspend the process. | |
4 | set -m | |
9f95a23c | 5 | source $testdir/autotest.config |
11fdf7f2 TL |
6 | |
7 | incoming_vm=1 | |
8 | target_vm=2 | |
9 | target_vm_ctrl=naa.VhostScsi0.$target_vm | |
9f95a23c | 10 | rpc="$rootdir/scripts/rpc.py -s $(get_vhost_dir 1)/rpc.sock" |
f67539c2 | 11 | share_dir=$VHOST_DIR/share |
11fdf7f2 | 12 | |
f67539c2 | 13 | function host_2_cleanup_vhost() { |
11fdf7f2 TL |
14 | notice "Shutting down VM $target_vm" |
15 | vm_kill $target_vm | |
16 | ||
17 | notice "Removing bdev & controller from vhost 1 on remote server" | |
f67539c2 TL |
18 | $rpc bdev_nvme_detach_controller Nvme0 |
19 | $rpc vhost_delete_controller $target_vm_ctrl | |
11fdf7f2 TL |
20 | |
21 | notice "Shutting down vhost app" | |
9f95a23c | 22 | vhost_kill 1 |
11fdf7f2 TL |
23 | sleep 1 |
24 | } | |
25 | ||
f67539c2 TL |
26 | function host_2_start_vhost() { |
27 | echo "BASE DIR $VHOST_DIR" | |
28 | vhost_work_dir=$VHOST_DIR/vhost1 | |
11fdf7f2 TL |
29 | mkdir -p $vhost_work_dir |
30 | rm -f $vhost_work_dir/* | |
31 | ||
32 | notice "Starting vhost 1 instance on remote server" | |
33 | trap 'host_2_cleanup_vhost; error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT | |
f67539c2 | 34 | vhost_run 1 "-u" |
11fdf7f2 | 35 | |
f67539c2 TL |
36 | $rpc bdev_nvme_attach_controller -b Nvme0 -t rdma -f ipv4 -a $RDMA_TARGET_IP -s 4420 -n "nqn.2018-02.io.spdk:cnode1" |
37 | $rpc vhost_create_scsi_controller $target_vm_ctrl | |
38 | $rpc vhost_scsi_controller_add_target $target_vm_ctrl 0 Nvme0n1 | |
11fdf7f2 TL |
39 | |
40 | vm_setup --os="$os_image" --force=$target_vm --disk-type=spdk_vhost_scsi --disks=VhostScsi0 \ | |
f67539c2 | 41 | --memory=512 --vhost-name=1 --incoming=$incoming_vm |
11fdf7f2 TL |
42 | vm_run $target_vm |
43 | sleep 1 | |
44 | ||
45 | # Use this file as a flag to notify main script | |
46 | # that setup on remote server is done | |
47 | echo "DONE" > $share_dir/DONE | |
48 | } | |
49 | ||
f67539c2 | 50 | echo $$ > $VHOST_DIR/tc3b.pid |
11fdf7f2 TL |
51 | host_2_start_vhost |
52 | suspend -f | |
53 | ||
54 | if ! vm_os_booted $target_vm; then | |
55 | fail "VM$target_vm is not running!" | |
56 | fi | |
57 | ||
58 | if ! is_fio_running $target_vm; then | |
f67539c2 | 59 | vm_exec $target_vm "cat /root/migration-tc3.log" |
11fdf7f2 TL |
60 | error "FIO is not running on remote server after migration!" |
61 | fi | |
62 | ||
63 | notice "Waiting for FIO to finish on remote server VM" | |
64 | timeout=40 | |
65 | while is_fio_running $target_vm; do | |
66 | sleep 1 | |
67 | echo -n "." | |
f67539c2 | 68 | if ((timeout-- == 0)); then |
11fdf7f2 TL |
69 | error "timeout while waiting for FIO!" |
70 | fi | |
71 | done | |
72 | ||
73 | notice "FIO result after migration:" | |
f67539c2 | 74 | vm_exec $target_vm "cat /root/migration-tc3.log" |
11fdf7f2 TL |
75 | |
76 | host_2_cleanup_vhost | |
77 | echo "DONE" > $share_dir/DONE |