#!/usr/bin/bash PXE=0 while true; do case $1 in --pxe) PXE=1 ; shift ;; *) break ;; esac done SMP=${SMP:-2} echo "SMP = $SMP" SSHPORT=${SSHPORT:-2222} echo "SSHPORT = $SSHPORT" VNCPORT=${VNCPORT:-0} echo "VNCPORT = $VNCPORT" CPFWD="" if [ -n "$COCKPIT" ]; then CPFWD=",hostfwd=tcp::$COCKPIT-:9090" echo "COCKPIT = $COCKPIT" fi if [ -n "$HTTP" ]; then HTTPFWD=",hostfwd=tcp::$HTTP-:8080" echo "HTTP= $HTTP" fi PORTS="-netdev user,id=net0,net=192.168.103.0/24,hostfwd=tcp::$SSHPORT-:22$CPFWD$HTTPFWD" if [ -n "$PXE" ]; then PORTS+=",tftp=$HOME/tmp/pxe/tftp,bootfile=/pxelinux.0" fi # Setup the VM on 192.168.103.0/24 and forward port 2222 to its ssh server on port 22, forward 9999 to port 80 qemu-kvm -vnc 127.0.0.1:$VNCPORT -cpu host -accel kvm -smp $SMP \ $PORTS \ -device virtio-net-pci,netdev=net0 \ -object rng-random,id=virtio-rng0,filename=/dev/urandom \ -device virtio-rng,rng=virtio-rng0 \ -serial stdio $@