-
Notifications
You must be signed in to change notification settings - Fork 0
/
fedora.sh
executable file
·74 lines (68 loc) · 2.82 KB
/
fedora.sh
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
#!/bin/bash
BOOT_BIN=/usr/bin/qemu-system-x86_64
NETNAME=fedora
MAC=$(grep -e "${NETNAME}=" macs.txt |cut -d"=" -f 2)
HOSTNAME=${NETNAME}
MEM=4G
DP=sdl,gl=on
MTYPE=pc-q35-6.2,accel=kvm,dump-guest-core=off,mem-merge=on,smm=on,vmport=off,nvdimm=off,hmat=on,memory-backend=mem1
ACCEL=accel=kvm,kvm-shadow-mem=256000000,kernel_irqchip=on
UUID="$(uuidgen)"
CPU=2,maxcpus=2,cores=2,sockets=1,threads=1
BIOS=/usr/share/OVMF/OVMF_CODE.fd
ISODIR=/applications/OS/isos
VMDIR=/virtualisation
VARS=${VMDIR}/ovmf/OVMF_VARS-${NETNAME}.fd
args=(
-uuid ${UUID}
-name ${NETNAME},process=${NETNAME}
-pidfile "/tmp/${NETNAME}/${NETNAME}.pid"
-no-user-config
-cpu host,vmx=on,hypervisor=on,hv-time=on,hv-relaxed=on,hv-vapic=on,hv-spinlocks=0x1fff,hv-vendor-id=1234567890,kvm=on
-smp ${CPU}
-m ${MEM}
-smbios type=2,manufacturer="oliver",product="${NETNAME}starter",version="0.1",serial="0xDEADBEEF",location="github.com",asset="${NETNAME}"
-mem-prealloc
-rtc base=localtime
-drive file=${VMDIR}/${NETNAME}.qcow2,index=0,media=disk,if=virtio,format=qcow2,cache=writeback,aio=io_uring
-chardev socket,id=chrtpm,path=/tmp/${NETNAME}/swtpm-sock-${NETNAME}
-tpmdev emulator,id=tpm0,chardev=chrtpm
-device tpm-crb,tpmdev=tpm0
-enable-kvm
-object memory-backend-memfd,id=mem1,share=on,size=${MEM}
-machine ${MTYPE},${ACCEL}
-overcommit mem-lock=off
-device virtio-balloon-pci,id=balloon0,deflate-on-oom=on
-object rng-random,id=objrng0,filename=/dev/urandom
-device virtio-rng-pci,rng=objrng0,id=rng0
-device virtio-serial-pci
-chardev socket,id=agent0,path="/tmp/${NETNAME}/${NETNAME}-agent.sock",server=on,wait=off
-device virtserialport,chardev=agent0,name=org.qemu.guest_agent.0
-chardev spicevmc,id=vdagent0,name=vdagent
-device virtserialport,chardev=vdagent0,name=com.redhat.spice.0
-device virtio-vga-gl,xres=1920,yres=1080
-vga none
-display ${DP}
-device virtio-net-pci,mq=on,packed=on,netdev=net0,mac=${MAC}
-netdev tap,ifname=tap0-${NETNAME},script=no,downscript=no,id=net0
-device ich9-intel-hda -device hda-duplex
-usb
-device usb-ehci,id=usb
-device usb-tablet
-monitor stdio
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny
-k de
)
# check if the bridge is up, if not, dont let us pass here
if [[ $(ip -br l | awk '$1 !~ "lo|vir|wl" { print $1 }') != *tap0-${NETNAME}* ]]; then
echo "bridge is not running, please start bridge interface"
exit 1
fi
#create tmp dir if not exists
if [ ! -d "/tmp/${NETNAME}" ]; then
mkdir /tmp/${NETNAME}
fi
# get tpm going
exec swtpm socket --tpm2 --tpmstate dir=/tmp/${NETNAME} --terminate --ctrl type=unixio,path=/tmp/${NETNAME}/swtpm-sock-${NETNAME} --daemon &
GTK_BACKEND=x11 GDK_BACKEND=x11 QT_BACKEND=x11 VDPAU_DRIVER="nvidia" ${BOOT_BIN} "${args[@]}"
exit 0