3 testdir
=$
(readlink
-f $
(dirname $0))
4 rootdir
=$
(readlink
-f $testdir/..
/..
)
5 source $rootdir/test
/common
/autotest_common.sh
7 if [ -z "${DEPENDENCY_DIR}" ]; then
8 echo DEPENDENCY_DIR not defined
!
14 sshpass
-p "$password" ssh -o PubkeyAuthentication
=no \
15 -o StrictHostKeyChecking
=no
-o UserKnownHostsFile
=/dev
/null
-p 10022 root@localhost
"$@"
19 function monitor_cmd
() {
20 echo "$@" | nc localhost
4444 |
tail --lines=+2 |
(grep -v '^(qemu) ' || true
)
23 function get_online_devices_count
() {
24 ssh_vm
"lspci | grep -c NVM"
27 function wait_for_devices_ready
() {
28 count
=$
(get_online_devices_count
)
30 while [ $count -ne 4 ]; do
31 echo "waitting for all devices online"
32 count
=$
(get_online_devices_count
)
36 function insert_devices
() {
38 monitor_cmd
"device_add nvme,drive=drive$i,id=nvme$i,serial=nvme$i"
40 wait_for_devices_ready
41 ssh_vm
"scripts/setup.sh"
44 function remove_devices
() {
46 monitor_cmd
"device_del nvme$i"
50 function devices_delete
() {
52 rm "$SPDK_TEST_STORAGE/nvme$i.img"
57 base_img
=${DEPENDENCY_DIR}/fedora-hotplug.qcow2
58 test_img
=${DEPENDENCY_DIR}/fedora-hotplug-test.qcow2
59 qemu_pidfile
=${DEPENDENCY_DIR}/qemupid
61 if [ ! -e "$base_img" ]; then
62 echo "Hotplug VM image not found; skipping test"
66 timing_enter start_qemu
68 qemu-img create
-b "$base_img" -f qcow2
"$test_img"
71 dd if=/dev
/zero of
="$SPDK_TEST_STORAGE/nvme$i.img" bs
=1M count
=1024
75 -daemonize -display none
-m 8192 \
76 -pidfile "$qemu_pidfile" \
78 -net user
,hostfwd
=tcp
::10022-:22 \
81 -smp cores
=16,sockets
=1 \
83 -chardev socket
,id
=mon0
,host=localhost
,port
=4444,server
,nowait \
84 -mon chardev
=mon0
,mode
=readline \
85 -drive format
=raw
,file="$SPDK_TEST_STORAGE/nvme0.img",if=none
,id
=drive0 \
86 -drive format
=raw
,file="$SPDK_TEST_STORAGE/nvme1.img",if=none
,id
=drive1 \
87 -drive format
=raw
,file="$SPDK_TEST_STORAGE/nvme2.img",if=none
,id
=drive2 \
88 -drive format
=raw
,file="$SPDK_TEST_STORAGE/nvme3.img",if=none
,id
=drive3
90 timing_exit start_qemu
92 timing_enter wait_for_vm
94 timing_exit wait_for_vm
96 timing_enter copy_repo
97 files_to_copy
="scripts "
98 files_to_copy
+="include/spdk/pci_ids.h "
99 files_to_copy
+="build/examples/hotplug "
100 files_to_copy
+="build/lib "
101 files_to_copy
+="dpdk/build/lib "
104 tar -cf - $files_to_copy
105 ) |
(ssh_vm
"tar -xf -")
106 timing_exit copy_repo
110 timing_enter hotplug_test
112 ssh_vm
"LD_LIBRARY_PATH=/root//build/lib:/root/dpdk/build/lib:$LD_LIBRARY_PATH build/examples/hotplug -i 0 -t 25 -n 4 -r 8" &
123 timing_enter wait_for_example
125 timing_exit wait_for_example
127 trap - SIGINT SIGTERM EXIT
129 qemupid
=$
(awk '{printf $0}' "$qemu_pidfile")
134 timing_exit hotplug_test