On Fri, Jan 15, 2021 at 05:59:19PM +0800, Yu Chuan wrote:
Signed-off-by: Yu Chuan 13186087857@163.com
providers/my-qemu.sh | 32 ++++++++++++++++++++++++++++++++ providers/qemu/kvm.sh | 5 +++-- providers/qemu/pxe.sh | 6 ++++-- 3 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/providers/my-qemu.sh b/providers/my-qemu.sh index 8845a346e195..a8f09a610d3f 100755 --- a/providers/my-qemu.sh +++ b/providers/my-qemu.sh @@ -2,6 +2,38 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+help() +{
- cat <<-'EOF'
- Usage: ./my-qemu.sh [OPTION]...
- Ask scheduer service whether there is a job, and start a local vm if there is a job.
- Scheduler api: http://$%7BSCHED_HOST%7D:$%7BSCHED_PORT%7D/boot.ipxe/mac/$%7Bmac%7D
- Mandatory arguments to long options are mandatory for short options too.
-h, --help display this help and exit
-d, --debug open the local vm serial port in the current shell
- EOF
- exit 0
+}
+while true +do
- [ $# -eq 0 ] && break
- case "$1" in
-h|--help)
help
shift;;
-d|--debug)
export DEBUG=true
shift;;
*)
echo "[ERROR] Unknown param: $1"
help
exit 1;;
- esac
perhaps above "shift" operation should locate here, not every "case" parts.
Thanks, Liushaofei
+done
[[ $tbox_group ]] || tbox_group=vm-2p8g export hostname=$tbox_group.$USER-$$ diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index f1d65272dbf9..a3cbe4248a3a 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -123,7 +123,7 @@ print_message() echo kernel: $kernel echo initrds: $initrds echo append: $append
- echo less $log_file
[ "$DEBUG" == "true" ] || echo less $log_file
sleep 5
} @@ -140,9 +140,10 @@ public_option() -k en-us -no-reboot -nographic
-monitor null )-serial file:${log_file}
- [ "$DEBUG" == "true" ] || kvm=("${kvm[@]}" -serial file:${log_file})
}
individual_option() diff --git a/providers/qemu/pxe.sh b/providers/qemu/pxe.sh index fa688331964a..2e205405c793 100755 --- a/providers/qemu/pxe.sh +++ b/providers/qemu/pxe.sh @@ -18,7 +18,7 @@ fi qemu=qemu-system-aarch64 command -v $qemu >/dev/null || qemu=qemu-kvm
-echo less $serial_log +[ "$DEBUG" == "true" ] || echo less $serial_log
kvm=( $qemu @@ -33,7 +33,9 @@ kvm=( -k en-us -no-reboot -nographic
- -serial file:${serial_log} -monitor null
)
+[ "$DEBUG" == "true" ] || kvm=("${kvm[@]}" -serial file:${serial_log})
"${kvm[@]}"
2.23.0