aboutsummaryrefslogtreecommitdiff
path: root/test-machine
diff options
context:
space:
mode:
Diffstat (limited to 'test-machine')
-rwxr-xr-xtest-machine26
1 files changed, 23 insertions, 3 deletions
diff --git a/test-machine b/test-machine
index 56c08e2..933a52e 100755
--- a/test-machine
+++ b/test-machine
@@ -2,7 +2,11 @@
# Test a virtual machine with KVM.
#
-usage="usage: $0 <machine-dir> [<qemu-option>...]"
+# -n <nic>
+# Network adapter to use, for example, virtio-net-pci (default), e1000,
+# or vmxnet3.
+#
+usage="usage: $0 [-n <nic>] <machine-dir> [<qemu-option>...]"
owd="$(pwd)"
trap "{ cd '$owd'; exit 1; }" ERR
@@ -11,6 +15,22 @@ set -o errtrace # Trap in functions.
function info () { echo "$*" 1>&2; }
function error () { info "$*"; exit 1; }
+nic=virtio-net-pci
+
+while [ "$#" -gt 0 ]; do
+ case "$1" in
+ -n)
+ shift
+ nic="$1"
+ shift
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+
dir="${1%/}"
shift
@@ -35,7 +55,7 @@ sudo ip link set "$tap" master "$br"
-cpu host -smp "8,sockets=1,cores=4,threads=2" \
\
-netdev "tap,id=net0,ifname=$tap,script=no" \
- -device "virtio-net-pci,netdev=net0,mac=$mac" \
+ -device "$nic,netdev=net0,mac=$mac" \
\
-drive "if=none,id=disk0,file=$dir/disk.img,format=raw" \
-device "virtio-blk-pci,scsi=off,drive=disk0" \
@@ -71,7 +91,7 @@ exit 0
sudo "${kvm[@]}" \
-m 8G \
-cpu host -smp "sockets=1,cores=4,threads=2" \
- -device "virtio-net-pci,netdev=net0,mac=$mac" \
+ -device "$nic,netdev=net0,mac=$mac" \
-netdev "tap,id=net0,script=./qemu-ifup" \
-device "virtio-scsi-pci,id=scsi" \
-device "scsi-hd,drive=disk1" \