-
Notifications
You must be signed in to change notification settings - Fork 3
/
qemu-template-run-ssq
executable file
·78 lines (66 loc) · 3.21 KB
/
qemu-template-run-ssq
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
NAME=$1
HOMEDATA=$4
RUNDIR=$5
MAC=
SWAPDEV=
KERNEL=$2
INITRD=$3
DISTRO=${DISTRO:-"centos7"}
EXPORT="/exports/${DISTRO}-base"
NFSSERVER=
STORAGEPOOL=zstorage
MLOCK=${MLOCK:-"-realtime mlock=on"}
if [ ! -f "$HOMEDATA" -o -z "$NAME" -o ! -f "$KERNEL" -o ! -f "$INITRD" ] ; then
echo "Usage $0 VMNAME kernel initrd lustrebuild.tar.xz LOGDIR"
exit 1
fi
if [ -z "${EXPORT}" ] ; then
echo "Export ${EXPORT} for distro ${DISTRO} does not exist"
exit 1
fi
if [ -f vmcfg/"${NAME}".env ] ; then
. vmcfg/"${NAME}".env
else
. vmcfg/generic.env
fi
EXTRADEV=
if [ -e "$MDT1DEV" ] ; then
blkdiscard "${MDT1DEV}"
EXTRADEV+="-drive file=${MDT1DEV},format=raw,if=none,id=drive-virtio-disk2,cache=unsafe -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x7,drive=drive-virtio-disk2,id=virtio-disk2,write-cache=on "
fi
if [ -e "$MDT2DEV" ] ; then
blkdiscard "${MDT2DEV}"
EXTRADEV+="-drive file=${MDT2DEV},format=raw,if=none,id=drive-virtio-disk3,cache=unsafe -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x8,drive=drive-virtio-disk3,id=virtio-disk3,write-cache=on "
fi
if [ -e "$OST1DEV" ] ; then
blkdiscard "${OST1DEV}"
EXTRADEV+="-drive file=${OST1DEV},format=raw,if=none,id=drive-virtio-disk4,cache=unsafe -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x9,drive=drive-virtio-disk4,id=virtio-disk4,write-cache=on "
fi
if [ -e "$OST2DEV" ] ; then
blkdiscard "${OST2DEV}"
EXTRADEV+="-drive file=${OST2DEV},format=raw,if=none,id=drive-virtio-disk5,cache=unsafe -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0xa,drive=drive-virtio-disk5,id=virtio-disk5,write-cache=on "
fi
if [ ! -e "$SWAPDEV" ] ; then
echo "SWAPDEV must be present for all VMs"
exit 1
fi
if [ -z "$NFSSERVER" -o -z "$EXPORT" ] ; then
echo "NFSSERVER and EXPORT must be present for all VMs"
exit 1
fi
if [ ! -f "$KERNEL" -o ! -f "$INITRD" ] ; then
echo "KERNEL and INITRD must be present for all VMs"
exit 1
fi
if [ ! -d "$RUNDIR" ] ; then
echo "RUNDIR must be a directory and exist for all test runs"
exit 1
fi
blkdiscard "${SWAPDEV}"
mkswap -f -L SWAP "${SWAPDEV}" || exit 3
MEM=${MEM:-4078}
#EXTRAKERNELARGS="kmemleak=on"
EXTRAKERNELARGS=${EXTRAKERNELARGS:-"audit=0"}
echo "Starting Qemu for $NAME"
exec qemu-system-x86_64 -nographic -no-reboot ${MLOCK} -nodefaults -nic bridge,model=virtio,mac=${MAC},br=br1 -name guest=${NAME},debug-threads=on -machine pc-i440fx-1.6,accel=kvm,usb=off,dump-guest-core=off -m ${MEM} -realtime mlock=off -smp 4,sockets=1,cores=2,threads=2 -rtc base=utc -chardev stdio,mux=on,id=char0 -mon chardev=char0,mode=readline -serial chardev:char0 -serial file:"${RUNDIR}"/"${NAME}"-console.txt -drive file="${HOMEDATA}",format=file,locking=off,if=none,id=drive-virtio-disk0 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,write-cache=on -drive file="${SWAPDEV}",format=raw,if=none,id=drive-virtio-disk1,cache=unsafe ${EXTRADEV} -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk1,id=virtio-disk1,write-cache=on $EXTRADEVS -msg timestamp=on -kernel "${KERNEL}" -initrd "${INITRD}" -append "rd.shell root=nfs:${NFSSERVER}:${EXPORT} ro crashkernel=128M panic=1 nomodeset ipmtu=9000 noibrs noibpb pti=off spectre_v2=off l1tf=off nospec_store_bypass_disable console=ttyS1,115200 ${EXTRAKERNELARGS}"