@@ -107,6 +107,176 @@ function ep_host_testpmd_stop()
107
107
echo " Stopped testpmd on Host"
108
108
}
109
109
110
+ EP_SCP_CMD=${EP_SCP_CMD:- " scp -o LogLevel=ERROR -o ServerAliveInterval=30 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" }
111
+ EP_GUEST_DIR=" /root/hostshare"
112
+ EP_GUEST_SHARE_DIR=$EP_HOST_DIR /guest
113
+
114
+ function ep_host_launch_guest()
115
+ {
116
+ local unbuffer=" stdbuf -o0"
117
+ local pfx=$1
118
+ local in=guest.in.$pfx
119
+ local out=guest.out.$pfx
120
+
121
+ $EP_SCP_CMD ci@10.28.34.13:/home/ci/dao_host/qemu-system-x86_64 $EP_HOST_DIR /
122
+ $EP_SCP_CMD ci@10.28.34.13:/home/ci/dao_host/noble-server-cloudimg-amd64.img $EP_HOST_DIR /
123
+ $EP_SCP_CMD ci@10.28.34.13:/home/ci/dao_host/bios-256k.bin /usr/share/qemu
124
+ $EP_SCP_CMD ci@10.28.34.13:/home/ci/dao_host/vgabios-stdvga.bin /usr/share/qemu
125
+ $EP_SCP_CMD ci@10.28.34.13:/home/ci/dao_host/efi-virtio.rom /usr/share/qemu
126
+
127
+ # Folder to be shared with the guest
128
+ rm -rf $EP_GUEST_SHARE_DIR
129
+ mkdir $EP_GUEST_SHARE_DIR
130
+
131
+ cp $EP_HOST_DIR /ci/test/dao-test/common/utils.sh $EP_GUEST_SHARE_DIR
132
+ cp $EP_HOST_DIR /ci/test/dao-test/common/testpmd.sh $EP_GUEST_SHARE_DIR
133
+ cp $EP_HOST_DIR /ci/test/dao-test/common/ep_guest_utils.sh $EP_GUEST_SHARE_DIR
134
+
135
+ if [[ -f $EP_HOST_DIR /qemu-system-x86_64 ]]; then
136
+ QEMU_BIN=$EP_HOST_DIR /qemu-system-x86_64
137
+ else
138
+ echo " qemu-system-x86_64 not found !!"
139
+ return 1
140
+ fi
141
+
142
+ if [[ -f $EP_HOST_DIR /noble-server-cloudimg-amd64.img ]]; then
143
+ VM_IMAGE=$EP_HOST_DIR /noble-server-cloudimg-amd64.img
144
+ else
145
+ echo " x86 QEMU cloud image not found !!"
146
+ return 1
147
+ fi
148
+
149
+ ulimit -l unlimited
150
+ rm -f $out
151
+ rm -f $in
152
+ touch $in
153
+ tail -f $in | ($unbuffer $QEMU_BIN -hda " $VM_IMAGE " -name vm1 \
154
+ -netdev type=vhost-vdpa,vhostdev=" /dev/vhost-vdpa-0" ,id=vhost-vdpa1 \
155
+ -device virtio-net-pci,netdev=vhost-vdpa1,disable-modern=off,page-per-vq=on,packed=on,mrg_rxbuf=on,mq=on,rss=on,rx_queue_size=1024,tx_queue_size=1024,disable-legacy=on -fsdev local,path=$EP_GUEST_SHARE_DIR ,security_model=passthrough,id=hostshare -device virtio-9p-pci,id=fs0,fsdev=hostshare,mount_tag=host_tag \
156
+ -enable-kvm -nographic -m 4G -cpu host -smp 8 -L /usr/share/qemu & > $out ) &
157
+
158
+ # Wait for guest to be up
159
+ local itr=0
160
+ while ! (tail -n15 $out | grep -q " ubuntu login:" ); do
161
+ sleep 10
162
+ itr=$(( itr + 1 ))
163
+ if [[ itr -eq 20 ]]; then
164
+ echo " Timeout waiting for Guest" ;
165
+ cat $out
166
+ return 1;
167
+ fi
168
+ echo " Waiting for guest to be up"
169
+ done
170
+ echo " Guest is launched"
171
+ echo " root" >> $in
172
+ sleep 1;
173
+ echo " a" >> $in
174
+ sleep 1;
175
+ echo " rm -rf $EP_GUEST_DIR ; mkdir $EP_GUEST_DIR " >> $in
176
+ echo " cp /home/dpdk-testpmd /bin" >> $in
177
+ echo " mount -t 9p -o trans=virtio host_tag $EP_GUEST_DIR " >> $in
178
+ echo " $EP_GUEST_DIR /ep_guest_utils.sh setup" >> $in
179
+ echo " cd $EP_GUEST_DIR " >> $in
180
+ }
181
+
182
+ function guest_testpmd_prompt()
183
+ {
184
+ local pfx=$1
185
+ local refresh=${2:- }
186
+ local skip_bytes=${3:- }
187
+ local in=$EP_GUEST_SHARE_DIR /testpmd.in.$pfx
188
+ local out=$EP_GUEST_SHARE_DIR /testpmd.out.$pfx
189
+
190
+ local cmd=" tail -n1 $out "
191
+
192
+ if [[ " $skip_bytes " != " " ]]
193
+ then
194
+ cmd=" tail -c +$skip_bytes $out "
195
+ fi
196
+
197
+ while ! ($cmd | grep -q " ^testpmd> $" ); do
198
+ if [ " $refresh " == " yes" ]
199
+ then
200
+ sleep 1
201
+ echo " " >> $in
202
+ fi
203
+ continue ;
204
+ done
205
+ }
206
+
207
+ function ep_host_start_guest_traffic()
208
+ {
209
+ local unbuffer=" stdbuf -o0"
210
+ local pfx=$1
211
+ local in=guest.in.$pfx
212
+ local out=guest.out.$pfx
213
+ local testpmd_out=" $EP_GUEST_SHARE_DIR /testpmd.out.$pfx "
214
+ local args=${@: 2}
215
+
216
+ echo " Starting Traffic on Guest"
217
+ echo " ./ep_guest_utils.sh testpmd_launch $pfx $args " >> $in
218
+ # Wait till out file is created
219
+ local itr=0
220
+ while [[ ! -f $testpmd_out ]]; do
221
+ itr=$(( itr + 1 ))
222
+ sleep 1
223
+ if [[ itr -eq 20 ]]; then
224
+ echo " Timeout waiting for Guest testpmd" ;
225
+ cat $out
226
+ return 1;
227
+ fi
228
+ echo " Waiting for guest testpmd to be up"
229
+ continue
230
+ done
231
+ # Wait till testpmd prompt comes up
232
+ guest_testpmd_prompt $pfx
233
+ echo " ./ep_guest_utils.sh testpmd_start $pfx " >> $in
234
+ echo " Started Traffic on Guest"
235
+ }
236
+
237
+ function ep_host_guest_testpmd_pps()
238
+ {
239
+ local pfx=$1
240
+ local in=guest.in.$pfx
241
+ local testpmd_pps=" $EP_GUEST_SHARE_DIR /testpmd.pps.$pfx "
242
+ local rx_pps
243
+
244
+ echo " ./ep_guest_utils.sh testpmd_pps $pfx " >> $in
245
+ while [[ ! -f $testpmd_pps ]]; do
246
+ sleep 1
247
+ echo " Waiting for $testpmd_pps to be created"
248
+ done
249
+ rx_pps=$( cat $testpmd_pps )
250
+ if [[ $rx_pps -eq 0 ]]; then
251
+ echo " Low PPS for ${pfx} ($rx_pps == 0)"
252
+ return 1
253
+ else
254
+ echo " Rx PPS $rx_pps as expected"
255
+ return 0
256
+ fi
257
+ }
258
+
259
+ function ep_host_stop_guest_traffic()
260
+ {
261
+ local pfx=$1
262
+ local in=guest.in.$pfx
263
+ local testpmd_out=$EP_GUEST_SHARE_DIR /testpmd.out.$pfx
264
+
265
+ cat $testpmd_out
266
+ echo " ./ep_guest_utils.sh testpmd_stop $pfx " >> $in
267
+ }
268
+
269
+ function ep_host_shutdown_guest()
270
+ {
271
+ local pfx=$1
272
+ local in=guest.in.$pfx
273
+
274
+ echo " cd /home" >> $in
275
+ echo " umount $EP_GUEST_DIR " >> $in
276
+ echo " shutdown now" >> $in
277
+ sleep 10;
278
+ }
279
+
110
280
# If this script is directly invoked from the shell execute the
111
281
# op specified
112
282
if [[ ${BASH_SOURCE[0]} == ${0} ]]; then
0 commit comments