From 460dbb513d953e7864c88ae831e6431792c306e0 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Wed, 7 Jun 2023 09:31:54 +0200 Subject: debvm-run: add an --append option Unlike qemu's -append, it has append semantics both to repeated use and to internal defaults. --- bin/debvm-run | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'bin/debvm-run') diff --git a/bin/debvm-run b/bin/debvm-run index f1cde97..53e2ba3 100755 --- a/bin/debvm-run +++ b/bin/debvm-run @@ -24,6 +24,12 @@ A net interface configured for user mode is added automatically. =over 8 +=item B<--append>=I + +While the kernel command line can be modified by passing B<-append> to B directly, doing that always replaces the entire command line and thus removes important values passed by B. +This variant instead appends given command line arguments to the automatic ones. +Repeated use also causes appending rather than replacement. + =item B<-g>, B<--graphical> By default, the option B<-nographic> is passed to B and one interacts with the serial console of the machine. @@ -96,6 +102,7 @@ set -u IMAGE=rootfs.ext4 SSHPORT= GRAPHICAL= +CMDLINE_APPEND= nth_arg() { shift "$1" @@ -122,6 +129,9 @@ usage_error() { usage } +opt_append() { + CMDLINE_APPEND="${CMDLINE_APPEND:+$CMDLINE_APPEND }$1" +} opt_graphical() { GRAPHICAL=1 } @@ -145,12 +155,12 @@ while getopts :gi:s:-: OPTCHAR; do graphical) "opt_$OPTARG" ;; - image|sshport) + append|image|sshport) test "$OPTIND" -gt "$#" && usage_error "missing argument for --$OPTARG" "opt_$OPTARG" "$(nth_arg "$OPTIND" "$@")" OPTIND=$((OPTIND+1)) ;; - image=*|sshport=*) + append=|image=*|sshport=*) "opt_${OPTARG%%=*}" "${OPTARG#*=}" ;; *) @@ -385,7 +395,7 @@ if test -n "$DNSSEARCH"; then NETDEV="$NETDEV,domainname=$DNSSEARCH" fi set -- \ - -append "$KERNEL_CMDLINE" \ + -append "$KERNEL_CMDLINE${CMDLINE_APPEND:+ $CMDLINE_APPEND}" \ -netdev "$NETDEV" \ -device "$NIC_DEV" \ "$@" -- cgit v1.2.3