-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_qemu.sh
executable file
·116 lines (94 loc) · 2.34 KB
/
run_qemu.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
QEMU=qemu-system-x86_64
which $QEMU
if test $? -ne 0
then
echo Please install qemu or alias qemu-system-x86_64
exit 1
fi
which brctl
if test $? -ne 0
then
echo Please install brctl command via bridge-utils package
exit 1
fi
nobrfilter(){
# Deactivate bridge filtering
sudo modprobe br_netfilter
sudo sysctl net.bridge.bridge-nf-call-arptables=0
sudo sysctl net.bridge.bridge-nf-call-iptables=0
sudo sysctl net.bridge.bridge-nf-call-ip6tables=0
}
# $1 name of the bridge to create
brcreate(){
sudo ip link add name $1 type bridge
sudo ip link set $1 up
}
# $1 name of the tap to create
tapcreate(){
echo create the interface $1 and add it to $2 bridge
sudo ip tuntap add mode tap user `whoami` name $1
sudo ip link set up dev $1
# Connect to a bridge if required
if test $# -eq 2
then
sudo brctl addif $2 $1
fi
}
# $1 is the name of the interface to check
# $2 is the name of the interface creation function
# $3 is the argument of the interface creation function
createif(){
echo does $1 exists already ?
ip a | grep ": $1:"
if test ! $? -eq 0
then
echo create the interface
$2 $1 $3
fi
}
# Create hypervisor tap interface
createif tap-hv tapcreate
# Deactivate bridge filtering
nobrfilter
# Set ip addresses
sudo ip addr add dev tap-hv 192.168.0.1/30
sudo ip link set tap-hv up
OVMF=./edk2/Build/Ovmf3264/DEBUG_GCC5/FV/OVMF_CODE.fd
VARS=./edk2/Build/Ovmf3264/DEBUG_GCC5/FV/OVMF_VARS.fd
# -serial mon:stdio \
# -nographic \
#BIOS="-bios /usr/share/ovmf/x64/OVMF_CODE.fd"
BIOS=" \
-global driver=cfi.pflash01,property=secure,value=on \
-drive file=$OVMF,if=pflash,format=raw,unit=0,readonly=on \
-drive file=$VARS,if=pflash,format=raw,unit=1"
#MACHINE=
MACHINE="-cpu host -enable-kvm"
#MACHINE="-machine q35,smm=on,accel=tcg"
NET="\
-netdev tap,id=net0,ifname=tap-hv,script=no,downscript=no \
-device e1000,netdev=net0 \
"
#NET="\
# -netdev user,id=net0 \
# -device e1000,netdev=net0 \
# "
#CDROM=" \
# -cdrom img-arch/arch.iso
# "
CROM=""
$QEMU \
$MACHINE \
-m 4G \
-smp 1,sockets=1,cores=1,threads=1 \
-chardev pty,id=charserial1 \
-device isa-serial,chardev=charserial1,id=serial1 \
$NET \
$CDROM \
-drive file=fat:rw:img/hda-contents,format=raw \
-drive file=img-arch/vdisk.qcow2 \
$BIOS \
-debugcon file:debug.log \
-global isa-debugcon.iobase=0x402 \
-s -S