]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/vhost/migration/migration-tc3b.sh
68d86930172fcdf82fd26edda2375740a50be89f
[ceph.git] / ceph / src / spdk / test / vhost / migration / migration-tc3b.sh
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
5 source $testdir/autotest.config
6
7 incoming_vm=1
8 target_vm=2
9 target_vm_ctrl=naa.VhostScsi0.$target_vm
10 rpc="$rootdir/scripts/rpc.py -s $(get_vhost_dir 1)/rpc.sock"
11 share_dir=$TEST_DIR/share
12
13 function host_2_cleanup_vhost()
14 {
15 notice "Shutting down VM $target_vm"
16 vm_kill $target_vm
17
18 notice "Removing bdev & controller from vhost 1 on remote server"
19 $rpc delete_nvme_controller Nvme0
20 $rpc remove_vhost_controller $target_vm_ctrl
21
22 notice "Shutting down vhost app"
23 vhost_kill 1
24 sleep 1
25 }
26
27 function host_2_start_vhost()
28 {
29 echo "BASE DIR $TEST_DIR"
30 vhost_work_dir=$TEST_DIR/vhost1
31 mkdir -p $vhost_work_dir
32 rm -f $vhost_work_dir/*
33
34 notice "Starting vhost 1 instance on remote server"
35 trap 'host_2_cleanup_vhost; error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT
36 vhost_run --vhost-num=1 --no-pci
37
38 $rpc construct_nvme_bdev -b Nvme0 -t rdma -f ipv4 -a $RDMA_TARGET_IP -s 4420 -n "nqn.2018-02.io.spdk:cnode1"
39 $rpc construct_vhost_scsi_controller $target_vm_ctrl
40 $rpc add_vhost_scsi_lun $target_vm_ctrl 0 Nvme0n1
41
42 vm_setup --os="$os_image" --force=$target_vm --disk-type=spdk_vhost_scsi --disks=VhostScsi0 \
43 --memory=512 --vhost-num=1 --incoming=$incoming_vm
44 vm_run $target_vm
45 sleep 1
46
47 # Use this file as a flag to notify main script
48 # that setup on remote server is done
49 echo "DONE" > $share_dir/DONE
50 }
51
52 echo $$ > $TEST_DIR/tc3b.pid
53 host_2_start_vhost
54 suspend -f
55
56 if ! vm_os_booted $target_vm; then
57 fail "VM$target_vm is not running!"
58 fi
59
60 if ! is_fio_running $target_vm; then
61 vm_ssh $target_vm "cat /root/migration-tc3.job.out"
62 error "FIO is not running on remote server after migration!"
63 fi
64
65 notice "Waiting for FIO to finish on remote server VM"
66 timeout=40
67 while is_fio_running $target_vm; do
68 sleep 1
69 echo -n "."
70 if (( timeout-- == 0 )); then
71 error "timeout while waiting for FIO!"
72 fi
73 done
74
75 notice "FIO result after migration:"
76 vm_ssh $target_vm "cat /root/migration-tc3.job.out"
77
78 host_2_cleanup_vhost
79 echo "DONE" > $share_dir/DONE