diff options
author | Helmut Grohne <helmut@subdivi.de> | 2023-06-07 09:31:54 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2023-06-07 09:31:54 +0200 |
commit | 460dbb513d953e7864c88ae831e6431792c306e0 (patch) | |
tree | 9e2414337fc8d84cd50255d83aaa830f78b24f89 /bin | |
parent | d47385b96f77db9015e1fa3b79e13116c6e0daae (diff) | |
download | debvm-460dbb513d953e7864c88ae831e6431792c306e0.tar.gz |
debvm-run: add an --append option
Unlike qemu's -append, it has append semantics both to repeated use and
to internal defaults.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/debvm-run | 16 |
1 files changed, 13 insertions, 3 deletions
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<cmdline> + +While the kernel command line can be modified by passing B<-append> to B<qemu> directly, doing that always replaces the entire command line and thus removes important values passed by B<debvm-run>. +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<qemu> 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" \ "$@" |