blob: 5d15852b61972ec26c40668fe95ec63553e7c540 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/bin/bash
# vmrestart.sh - stop QEMU, reload open-iov-vfio.ko from the tree, fresh mdev,
# relaunch the vGPU VM. Everything bounded so a stuck step cannot hang the
# caller.
set -u
cd "$(dirname "$(readlink -f "$0")")/../.."
sudo pkill -f qemu-system-x86_64 2>/dev/null
# Reap host-side watchers too: a pin_gr_stream/semfix pair left over from the
# previous boot holds the vsock port and the single QMP socket slot and will
# silently corrupt the next run (two QMP clients).
pkill -f "guest-diag/pin_gr_stream.py" 2>/dev/null
pkill -f "guest-diag/semfix_uvmt.py" 2>/dev/null
sleep 4
sudo rm -f /tmp/qemu-guest-agent.sock /tmp/qemu-qmp.sock
for m in /sys/bus/mdev/devices/*; do
[ -d "$m" ] || continue
timeout 20 sudo sh -c "echo 1 > $m/remove" || echo "WARN: mdev remove timeout"
done
timeout 30 sudo rmmod open_iov_vfio || { echo "ERROR: rmmod failed"; exit 1; }
sudo insmod kernel/open-iov-vfio.ko || { echo "ERROR: insmod failed"; exit 1; }
U=$(uuidgen)
echo "$U" | sudo tee /sys/class/mdev_bus/0000:01:00.0/mdev_supported_types/nvidia-nvidia-vgpu-turing/create >/dev/null
sed -i "s|/sys/bus/mdev/devices/[0-9a-f-]*|/sys/bus/mdev/devices/$U|" tools/guest-diag/launch_qemu_rootport.run.sh
mkdir -p /tmp/sockets/e726ba0b-204f-4ec9-91da-983ed7f41d06
(setsid nohup tools/guest-diag/launch_qemu_rootport.run.sh > tools/guest-diag/run/qemu.log 2>&1 &)
sleep 6
if pgrep -f qemu-system-x86_64 >/dev/null; then
echo "VM up (mdev $U)"
else
echo "VM FAILED"; tail -5 tools/guest-diag/run/qemu.log; exit 1
fi
|