Fix disk creation bug.
[rrq/tiniest.git] / vm.sh
1 #!/bin/bash
2 #
3 # QEMU setup for trial VM
4
5 if [ -z "$ISO" ] ; then
6     if [ -z "$EFI" ] ; then
7         BOOT="-boot menu=on"
8         DISK2="-drive index=1,id=boot,media=disk,format=raw,file=bootimage.raw"
9     else
10         BOOT="-bios /usr/share/OVMF/OVMF_CODE.fd"
11         DISK2="-drive index=1,id=boot,media=disk,format=raw,file=bootimage.raw"
12     fi
13 else
14     if [ -z "$EFI" ] ; then
15         BOOT="-boot menu=on"
16         DISK2="-drive index=1,id=boot,media=cdrom,format=raw,file=tiniest.iso"
17     else
18         BOOT="-bios /usr/share/OVMF/OVMF_CODE.fd"
19         DISK2="-drive index=1,id=boot,media=disk,format=raw,file=tiniest.iso"
20     fi
21 fi 
22
23 case "$NET" in
24     vde)
25         #NET="-net nic,macaddr=06:7f:57:5e:c8:92 -net vde,sock=/run/vde.ctl"
26         NET="-net nic,model=e1000 -net vde,sock=/run/vde.ctl"
27         ;;
28     *)
29         NET=
30         ;;
31 esac
32
33 [ -e disk.raw ] || dd if=/dev/zero of=disk.raw bs=1G count=0 seek=8
34
35 ARGS=(
36     -m 2G -M pc,accel=kvm -cpu host -vga qxl
37     -serial mon:stdio -echr 0x1c # Using ^\ as meta character
38     $BOOT
39     -drive index=0,id=disk,media=disk,format=raw,file=disk.raw
40     $DISK2
41     $NET
42 )
43
44 exec qemu-system-x86_64 ${ARGS[@]}