aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kernel-test/run-qemu.sh
blob: 1873af4aad2b77db566bb6ccb55d03cefaa248d4 (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/sh -ex
# Arguments are appended to the kernel cmdline

random_mac() {
	printf "52:54:"
	date "+%c %N" | sha1sum | sed 's/\(.\{2\}\)/\1:/g' | cut -d: -f 1-4
}

KERNEL_CMDLINE="
	root=/dev/ram0
	console=ttyS0
	panic=-1
	$@
"

if [ -e /dev/kvm ]; then
	MACHINE_ARG="-machine pc,accel=kvm"
else
	MACHINE_ARG="-machine pc"
fi

qemu-system-x86_64 \
	$MACHINE_ARG \
	-smp 1 \
	-m 512M \
	-nodefconfig -no-user-config -nodefaults -display none \
	-gdb unix:/cache/kernel-test/gdb.pipe,server,nowait \
	-no-reboot \
	-kernel /cache/kernel-test/linux \
	-initrd /cache/kernel-test/initrd \
	-append "${KERNEL_CMDLINE}" \
	-serial stdio \
	-chardev socket,id=charserial1,path=/cache/kernel-test/gdb-serial.pipe,server,nowait \
	-device isa-serial,chardev=charserial1,id=serial1 \
	-netdev tap,id=nettest,script=/kernel-test/qemu-ifup.sh,downscript=/kernel-test/qemu-ifdown.sh \
	-device virtio-net-pci,netdev=nettest,mac="$(random_mac)"