added timeout and sysappend
[rrq/tiniest.git] / vm.sh
diff --git a/vm.sh b/vm.sh
index 74274e606fbc6839c9a64d08fae61fbc332e806d..41f024dae052cdbfd702b031fe4ce3b828ce893f 100755 (executable)
--- a/vm.sh
+++ b/vm.sh
@@ -1,19 +1,44 @@
 #!/bin/bash
 #
-# QEMU setup for trial3 VM
+# QEMU setup for trial VM
 
-if [ -n "$EFI" ] ; then
-   BOOT="-bios /usr/share/OVMF/OVMF_CODE.fd"
+if [ -z "$ISO" ] ; then
+    if [ -z "$EFI" ] ; then
+       BOOT="-boot menu=on"
+       DISK2="-drive index=1,id=boot,media=disk,format=raw,file=bootimage.raw"
+    else
+       BOOT="-bios /usr/share/OVMF/OVMF_CODE.fd"
+       DISK2="-drive index=1,id=boot,media=disk,format=raw,file=bootimage.raw"
+    fi
 else
-    BOOT="-boot menu=on"
-fi
+    if [ -z "$EFI" ] ; then
+       BOOT="-boot menu=on"
+       DISK2="-drive index=1,id=boot,media=cdrom,format=raw,file=tiniest.iso"
+    else
+       BOOT="-bios /usr/share/OVMF/OVMF_CODE.fd"
+       DISK2="-drive index=1,id=boot,media=disk,format=raw,file=tiniest.iso"
+    fi
+fi 
+
+case "$NET" in
+    vde)
+       #NET="-net nic,macaddr=06:7f:57:5e:c8:92 -net vde,sock=/run/vde.ctl"
+       NET="-net nic,model=e1000 -net vde,sock=/run/vde.ctl"
+       ;;
+    *)
+       NET=
+       ;;
+esac
+
+[ -e disk.raw ] || dd if=/dev/zero of=disk.raw bs=1G count=0 seek=8
+
 ARGS=(
-    -m 2G -M pc,accel=kvm -cpu host
-    -serial mon:stdio -echr 0x1c
-    -vga qxl
+    -m 2G -M pc,accel=kvm -cpu host -vga qxl
+    -serial mon:stdio -echr 0x1c # Using ^\ as meta character
     $BOOT
     -drive index=0,id=disk,media=disk,format=raw,file=disk.raw
-    -drive index=1,id=boot,media=disk,format=raw,file=bootimage.raw
+    $DISK2
+    $NET
 )
 
-qemu-system-x86_64 ${ARGS[@]}
+exec qemu-system-x86_64 ${ARGS[@]}