diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2020-03-25 11:06:52 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2020-03-25 11:06:52 +0200 |
commit | 875fe9627fcb705bc66cb3b0b31c7ef6111ab1f5 (patch) | |
tree | 17fd131bcd2a7af4b75758bd91ca911ffcff91d7 | |
parent | b45a331dbaeae9ad15a5723341a159492d9f17c3 (diff) |
Add ability to specify alternative nic in test-machine
-rwxr-xr-x | test-machine | 26 |
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" \ |