diff options
author | Helmut Grohne <helmut@subdivi.de> | 2024-03-25 10:58:59 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2024-03-25 10:58:59 +0100 |
commit | e5766ed0136f532ac7876936d3a2ab5ac0b2f820 (patch) | |
tree | 30eb87b53a82c4ed6a09e9f1c782cb54175ca874 | |
parent | 4db215b6edba4b9d79c5439f3c9c4596915069b2 (diff) | |
parent | d927a5e0cee2a725a1b2380ec2022b3564fc26de (diff) | |
download | debvm-e5766ed0136f532ac7876936d3a2ab5ac0b2f820.tar.gz |
Merge feature-virtio-bus into main
-rwxr-xr-x | bin/debvm-run | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/bin/debvm-run b/bin/debvm-run index aaf870a..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#*=}" ;; *) @@ -354,17 +363,6 @@ set -- \ -initrd "/proc/self/fd/$INITRDFD" \ "$@" -# 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). -IMAGE_ESCAPED="$(printf "%s" "$IMAGE" | sed 's/,/,,/g')" - -if ! check_skip root/dev; then - set -- \ - -drive "media=disk,format=raw,discard=unmap,file=$IMAGE_ESCAPED,if=virtio,cache=unsafe" \ - "$@" -fi - # Translate KERNELARCH (a Debian architecture) to a Debian CPU name. # This utilizes the QEMU Debian package symlink mapping that ensures that # calling qemu-system-${DEB_HOST_ARCH_CPU} will run the QEMU binary providing @@ -374,8 +372,6 @@ QEMU="qemu-system-$KERNELARCHCPU" CPU= MACHINE= MAX_SMP= -NIC_DEV=virtio-net-pci,netdev=net0 -RNG_DEV=virtio-rng-pci,rng=rng0 case "$KERNELARCHCPU" in amd64) @@ -393,8 +389,7 @@ case "$KERNELARCHCPU" in m68k) MACHINE="type=virt" MAX_SMP=1 - NIC_DEV=virtio-net-device,netdev=net0 - RNG_DEV=virtio-rng-device,rng=rng0 + : "${TRANSPORT:=device}" ;; mips64el) CPU=5KEc @@ -411,10 +406,25 @@ case "$KERNELARCHCPU" in ;; sparc64) MAX_SMP=1 - RNG_DEV= + opt_skip rngdev ;; 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). +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-$TRANSPORT,drive=root,serial=root" \ + "$@" +fi + ENABLE_KVM=no if test "$ARCHITECTURE" = "$KERNELARCH"; then ENABLE_KVM=yes @@ -455,9 +465,9 @@ if test -z "$MAX_SMP" || test "$MAX_SMP" -gt 1; then set -- -smp "$NPROC" "$@" fi fi -if test -n "$RNG_DEV" && ! check_skip rngdev; then +if ! check_skip rngdev; then set -- \ - -device "$RNG_DEV" \ + -device "virtio-rng-$TRANSPORT,rng=rng0" \ -object rng-random,filename=/dev/urandom,id=rng0 \ "$@" fi @@ -479,14 +489,14 @@ else ;; *) set -- \ - -device virtio-gpu-gl-pci \ + -device "virtio-gpu-gl-$TRANSPORT" \ -display gtk,gl=on \ "$@" ;; esac set -- \ - -device virtio-keyboard-pci \ - -device virtio-tablet-pci \ + -device "virtio-keyboard-$TRANSPORT" \ + -device "virtio-tablet-$TRANSPORT" \ "$@" fi @@ -503,7 +513,10 @@ if test -n "$KERNEL_CMDLINE"; then fi if ! check_skip network; then - set -- -netdev "user,id=net0$NETOPTS" -device "$NIC_DEV" "$@" + set -- \ + -netdev "user,id=net0$NETOPTS" \ + -device "virtio-net-$TRANSPORT,netdev=net0" \ + "$@" fi echo "+ $QEMU $*" 1>&2 |