summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2024-03-05 20:41:41 +0100
committerHelmut Grohne <helmut@subdivi.de>2024-03-05 20:41:41 +0100
commitd927a5e0cee2a725a1b2380ec2022b3564fc26de (patch)
tree78b5a400c3d002cac63857315a98428c6dc44cc0
parent8fca4b8b94319e663f0d71d199bfe7bfd0fab596 (diff)
downloaddebvm-d927a5e0cee2a725a1b2380ec2022b3564fc26de.tar.gz
debvm-run: add --transport option
What was named bus earlier is called transport in qemu and we should name it the same way when exposing it.
-rwxr-xr-xbin/debvm-run31
1 files changed, 21 insertions, 10 deletions
diff --git a/bin/debvm-run b/bin/debvm-run
index 4dc35d3..352f176 100755
--- a/bin/debvm-run
+++ b/bin/debvm-run
@@ -56,6 +56,11 @@ The option may be specified multiple times or list multiple tasks to be skipped
By default, no tasks are skipped.
The following tasks may be skipped.
+=item B<--transport>=I<transport>
+
+When B<debvm> adds devices to B<qemu>, it has to select a transport and it most often guesses B<pci>.
+When specifying a different machine such as B<-machine microvm>, a different transport such as B<device> may be needed.
+
=over 4
=item B<network>
@@ -155,6 +160,7 @@ CMDLINE_APPEND=
NETOPTS=
SKIP=,
SSHPORT=
+TRANSPORT=
nth_arg() {
shift "$1"
@@ -199,6 +205,9 @@ opt_skip() {
opt_sshport() {
SSHPORT=$1
}
+opt_transport() {
+ TRANSPORT=$1
+}
while getopts :gi:s:-: OPTCHAR; do
case "$OPTCHAR" in
@@ -213,12 +222,12 @@ while getopts :gi:s:-: OPTCHAR; do
graphical)
"opt_$OPTARG"
;;
- append|image|netopt|skip|sshport)
+ append|image|netopt|skip|sshport|transport)
test "$OPTIND" -gt "$#" && usage_error "missing argument for --$OPTARG"
"opt_$OPTARG" "$(nth_arg "$OPTIND" "$@")"
OPTIND=$((OPTIND+1))
;;
- append=*|image=*|netopt=*|skip=*|sshport=*)
+ append=*|image=*|netopt=*|skip=*|sshport=*|transport=*)
"opt_${OPTARG%%=*}" "${OPTARG#*=}"
;;
*)
@@ -362,7 +371,6 @@ KERNELARCHCPU="$(dpkg-architecture --force --host-arch "$KERNELARCH" --query DEB
QEMU="qemu-system-$KERNELARCHCPU"
CPU=
MACHINE=
-BUS=pci
MAX_SMP=
case "$KERNELARCHCPU" in
@@ -381,7 +389,7 @@ case "$KERNELARCHCPU" in
m68k)
MACHINE="type=virt"
MAX_SMP=1
- BUS=device
+ : "${TRANSPORT:=device}"
;;
mips64el)
CPU=5KEc
@@ -402,6 +410,9 @@ case "$KERNELARCHCPU" in
;;
esac
+# Assign the default late to allow both cli and arch-specific overrides.
+: "${TRANSPORT:=pci}"
+
# If the image filename contains a comma, then that comma must be escaped by
# prefixing it with another comma or otherwise output filenames are able to
# inject drive options to qemu (and load the wrong file).
@@ -410,7 +421,7 @@ IMAGE_ESCAPED="$(printf "%s" "$IMAGE" | sed 's/,/,,/g')"
if ! check_skip root/dev; then
set -- \
-drive "id=root,media=disk,format=raw,discard=unmap,file=$IMAGE_ESCAPED,if=none,cache=unsafe" \
- -device "virtio-blk-$BUS,drive=root,serial=root" \
+ -device "virtio-blk-$TRANSPORT,drive=root,serial=root" \
"$@"
fi
@@ -456,7 +467,7 @@ if test -z "$MAX_SMP" || test "$MAX_SMP" -gt 1; then
fi
if ! check_skip rngdev; then
set -- \
- -device "virtio-rng-$BUS,rng=rng0" \
+ -device "virtio-rng-$TRANSPORT,rng=rng0" \
-object rng-random,filename=/dev/urandom,id=rng0 \
"$@"
fi
@@ -478,14 +489,14 @@ else
;;
*)
set -- \
- -device "virtio-gpu-gl-$BUS" \
+ -device "virtio-gpu-gl-$TRANSPORT" \
-display gtk,gl=on \
"$@"
;;
esac
set -- \
- -device "virtio-keyboard-$BUS" \
- -device "virtio-tablet-$BUS" \
+ -device "virtio-keyboard-$TRANSPORT" \
+ -device "virtio-tablet-$TRANSPORT" \
"$@"
fi
@@ -504,7 +515,7 @@ fi
if ! check_skip network; then
set -- \
-netdev "user,id=net0$NETOPTS" \
- -device "virtio-net-$BUS,netdev=net0" \
+ -device "virtio-net-$TRANSPORT,netdev=net0" \
"$@"
fi