aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-01-04 10:29:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-01-04 10:29:21 +0200
commit021ba6a47856a96bf44cb3d8bf39f6f73ec741da (patch)
treeff9988a22309b38a0e3be3886040a472fbc3d3e2
parent4f2e96fd345da16d01dd6f4d6d9d0bca0d0aec78 (diff)
Add ability to specify existing tap interface in test-machine
Also, create new tap as tap9 instead of tap0.
-rwxr-xr-xtest-machine39
-rwxr-xr-xupload-machine3
2 files changed, 29 insertions, 13 deletions
diff --git a/test-machine b/test-machine
index 933a52e..3d55d94 100755
--- a/test-machine
+++ b/test-machine
@@ -6,6 +6,9 @@
# Network adapter to use, for example, virtio-net-pci (default), e1000,
# or vmxnet3.
#
+# -t <tap>
+# Existing tap interface to use instead of creating a new one (as tap9).
+#
usage="usage: $0 [-n <nic>] <machine-dir> [<qemu-option>...]"
owd="$(pwd)"
@@ -15,7 +18,13 @@ set -o errtrace # Trap in functions.
function info () { echo "$*" 1>&2; }
function error () { info "$*"; exit 1; }
+br=br0
+mac="de:ad:be:ef:b8:da"
+
+kvm=(qemu-system-x86_64 -enable-kvm)
+
nic=virtio-net-pci
+etap=
while [ "$#" -gt 0 ]; do
case "$1" in
@@ -24,6 +33,11 @@ while [ "$#" -gt 0 ]; do
nic="$1"
shift
;;
+ -t)
+ shift
+ etap="$1"
+ shift
+ ;;
*)
break
;;
@@ -38,17 +52,16 @@ if [ -z "$dir" ]; then
error "missing machine directory"
fi
-br=br0
-mac="de:ad:be:ef:b8:da"
-kvm=(qemu-system-x86_64 -enable-kvm)
-
-tap=tap0
-
-sudo ip tuntap delete "$tap" mode tap || true
-sudo ip tuntap add "$tap" mode tap user "$(whoami)"
-sudo ip link set "$tap" up
-#sleep 0.5s
-sudo ip link set "$tap" master "$br"
+if [ -z "$etap" ]; then
+ tap=tap9
+ sudo ip tuntap delete "$tap" mode tap || true
+ sudo ip tuntap add "$tap" mode tap user "$(whoami)"
+ sudo ip link set "$tap" up
+ #sleep 0.5s
+ sudo ip link set "$tap" master "$br"
+else
+ tap="$etap"
+fi
"${kvm[@]}" \
-m 8G \
@@ -84,7 +97,9 @@ sudo ip link set "$tap" master "$br"
#-vnc "unix:$dir/vnc" \
#-monitor "unix:$dir/monitor,server,nowait"
-sudo ip tuntap delete "$tap" mode tap
+if [ -z "$etap" ]; then
+ sudo ip tuntap delete "$tap" mode tap
+fi
exit 0
diff --git a/upload-machine b/upload-machine
index cffcd7b..8d6e730 100755
--- a/upload-machine
+++ b/upload-machine
@@ -14,7 +14,8 @@ usage="usage: $0 [<options>] <host> <new-subvol> [<old-subvol>]"
owd="$(pwd)"
trap "{ cd '$owd'; exit 1; }" ERR
-set -o errtrace # Trap in functions.
+set -o errtrace -o pipefail # Trap in functions.
+ # Fail if any pipe command fails.
function info () { echo "$*" 1>&2; }
function error () { info "$*"; exit 1; }