use function better.
test: /srv/result/host-info/2020-12-29/vm-2p8g/openeuler-20.09-aarch64/z9.273758
ssssss-off-by: Liu Yinsi liuyinsi@163.com --- providers/qemu/kvm.sh | 163 ++++++++++++++++++++++++++---------------- 1 file changed, 100 insertions(+), 63 deletions(-)
diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index fd921dc..6c4ad00 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -7,78 +7,115 @@ : ${nr_cpu:=1} : ${memory:=1G}
-log_file=/srv/cci/serial/logs/${hostname} -if [ ! -f "$log_file" ]; then - touch $log_file - # fluentd refresh time is 1s - # let fluentd to monitor this file first - sleep 2 -fi +check_logfile() +{ + log_file=/srv/cci/serial/logs/${hostname} + if [ ! -f "$log_file" ]; then + touch $log_file + # fluentd refresh time is 1s + # let fluentd to monitor this file first + sleep 2 + fi +}
-qemu=qemu-system-aarch64 -command -v $qemu >/dev/null || qemu=qemu-kvm +qemu_command() +{ + qemu=qemu-system-aarch64 + command -v $qemu >/dev/null || qemu=qemu-kvm +}
-ipxe_script=ipxe_script -curl http://$%7BSCHED_HOST:-172.17.0.1%7D:$%7BSCHED_PORT:-3000%7D/boot.ipxe/mac/$... > $ipxe_script -cat $ipxe_script >> ${log_file} +write_logfile() +{ + ipxe_script=ipxe_script + curl http://$%7BSCHED_HOST:-172.17.0.1%7D:$%7BSCHED_PORT:-3000%7D/boot.ipxe/mac/$... > $ipxe_script + cat $ipxe_script >> ${log_file} +} + +option_value() +{ + append= + initrds= + while read a b c + do + case "$a" in + '#') + ;; + initrd) + file=$(basename "$b") + wget --timestamping -a ${log_file} --progress=bar:force $b + initrds+="$file " + ;; + kernel) + kernel=$(basename "$b") + wget --timestamping -a ${log_file} --progress=bar:force $b + append=$(echo "$c" | sed -r "s/ initrd=[^ ]+//g") + ;; + *) + ;; + esac + done < $ipxe_script +}
-append= -initrds= -while read a b c -do - case "$a" in - '#') - ;; - initrd) - file=$(basename "$b") - wget --timestamping -a ${log_file} --progress=bar:force $b - initrds+="$file " - ;; - kernel) - kernel=$(basename "$b") - wget --timestamping -a ${log_file} --progress=bar:force $b - append=$(echo "$c" | sed -r "s/ initrd=[^ ]+//g") - ;; - *) - ;; - esac -done < $ipxe_script +check_option_value() +{ + [ -s "$kernel" ] || { + echo "can't get kernel or kernel size is 0" + exit + } + + [ -n "$initrds" ] || { + exit + } + + initrd=initrd + cat $initrds > $initrd +} + +print_message() +{ + echo $SCHED_PORT + echo kernel: $kernel + echo initrds: $initrds + echo append: $append + echo less $log_file + + sleep 5 +}
-[ -s "$kernel" ] || { - echo "can't get kernel or kernel size is 0" - exit +qemu_options() +{ + kvm=( + $qemu + -machine virt-4.0,accel=kvm,gic-version=3 + -kernel $kernel + -initrd $initrd + -smp $nr_cpu + -m $memory + -cpu Kunpeng-920 + -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd + -nic tap,model=virtio-net-pci,helper=/usr/libexec/qemu-bridge-helper,br=br0,mac=${mac} + -k en-us + -no-reboot + -nographic + -serial file:${log_file} + -monitor null + ) }
-[ -n "$initrds" ] || { - exit +run_qemu() +{ + "${kvm[@]}" --append "${append}" }
-initrd=initrd -cat $initrds > $initrd +check_logfile +write_logfile
-echo $SCHED_PORT -echo kernel: $kernel -echo initrds: $initrds -echo append: $append -echo less $log_file +qemu_command +option_value +check_option_value
-sleep 5 +print_message
-kvm=( - $qemu - -machine virt-4.0,accel=kvm,gic-version=3 - -kernel $kernel - -initrd $initrd - -smp $nr_cpu - -m $memory - -cpu Kunpeng-920 - -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd - -nic tap,model=virtio-net-pci,helper=/usr/libexec/qemu-bridge-helper,br=br0,mac=${mac} - -k en-us - -no-reboot - -nographic - -serial file:${log_file} - -monitor null -) +qemu_options
-"${kvm[@]}" --append "${append}" +run_qemu
On Tue, Dec 29, 2020 at 11:55:10AM +0800, Liu Yinsi wrote:
use function better.
test: /srv/result/host-info/2020-12-29/vm-2p8g/openeuler-20.09-aarch64/z9.273758
ssssss-off-by: Liu Yinsi liuyinsi@163.com
providers/qemu/kvm.sh | 163 ++++++++++++++++++++++++++---------------- 1 file changed, 100 insertions(+), 63 deletions(-)
diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index fd921dc..6c4ad00 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -7,78 +7,115 @@ : ${nr_cpu:=1} : ${memory:=1G}
-log_file=/srv/cci/serial/logs/${hostname} -if [ ! -f "$log_file" ]; then
- touch $log_file
- # fluentd refresh time is 1s
- # let fluentd to monitor this file first
- sleep 2
-fi +check_logfile() +{
- log_file=/srv/cci/serial/logs/${hostname}
- if [ ! -f "$log_file" ]; then
touch $log_file
# fluentd refresh time is 1s
# let fluentd to monitor this file first
sleep 2
- fi
+}
-qemu=qemu-system-aarch64 -command -v $qemu >/dev/null || qemu=qemu-kvm +qemu_command() +{
- qemu=qemu-system-aarch64
- command -v $qemu >/dev/null || qemu=qemu-kvm
+}
-ipxe_script=ipxe_script -curl http://$%7BSCHED_HOST:-172.17.0.1%7D:$%7BSCHED_PORT:-3000%7D/boot.ipxe/mac/$... > $ipxe_script -cat $ipxe_script >> ${log_file} +write_logfile() +{
- ipxe_script=ipxe_script
- curl http://$%7BSCHED_HOST:-172.17.0.1%7D:$%7BSCHED_PORT:-3000%7D/boot.ipxe/mac/$... > $ipxe_script
- cat $ipxe_script >> ${log_file}
+}
+option_value() +{
- append=
- initrds=
- while read a b c
- do
case "$a" in
'#')
;;
this case is useless, just delete it
Thanks, Luan Shengde
initrd)
file=$(basename "$b")
wget --timestamping -a ${log_file} --progress=bar:force $b
initrds+="$file "
;;
kernel)
kernel=$(basename "$b")
wget --timestamping -a ${log_file} --progress=bar:force $b
append=$(echo "$c" | sed -r "s/ initrd=[^ ]+//g")
;;
*)
;;
esac
- done < $ipxe_script
+}
-append= -initrds= -while read a b c -do
- case "$a" in
'#')
;;
initrd)
file=$(basename "$b")
wget --timestamping -a ${log_file} --progress=bar:force $b
initrds+="$file "
;;
kernel)
kernel=$(basename "$b")
wget --timestamping -a ${log_file} --progress=bar:force $b
append=$(echo "$c" | sed -r "s/ initrd=[^ ]+//g")
;;
*)
;;
- esac
-done < $ipxe_script +check_option_value() +{
- [ -s "$kernel" ] || {
echo "can't get kernel or kernel size is 0"
exit
- }
- [ -n "$initrds" ] || {
exit
- }
- initrd=initrd
- cat $initrds > $initrd
+}
+print_message() +{
- echo $SCHED_PORT
- echo kernel: $kernel
- echo initrds: $initrds
- echo append: $append
- echo less $log_file
- sleep 5
+}
-[ -s "$kernel" ] || {
- echo "can't get kernel or kernel size is 0"
- exit
+qemu_options() +{
- kvm=(
$qemu
-machine virt-4.0,accel=kvm,gic-version=3
-kernel $kernel
-initrd $initrd
-smp $nr_cpu
-m $memory
-cpu Kunpeng-920
-bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd
-nic tap,model=virtio-net-pci,helper=/usr/libexec/qemu-bridge-helper,br=br0,mac=${mac}
-k en-us
-no-reboot
-nographic
-serial file:${log_file}
-monitor null
- )
}
-[ -n "$initrds" ] || {
- exit
+run_qemu() +{
- "${kvm[@]}" --append "${append}"
}
-initrd=initrd -cat $initrds > $initrd +check_logfile +write_logfile
-echo $SCHED_PORT -echo kernel: $kernel -echo initrds: $initrds -echo append: $append -echo less $log_file +qemu_command +option_value +check_option_value
-sleep 5 +print_message
-kvm=(
- $qemu
- -machine virt-4.0,accel=kvm,gic-version=3
- -kernel $kernel
- -initrd $initrd
- -smp $nr_cpu
- -m $memory
- -cpu Kunpeng-920
- -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd
- -nic tap,model=virtio-net-pci,helper=/usr/libexec/qemu-bridge-helper,br=br0,mac=${mac}
- -k en-us
- -no-reboot
- -nographic
- -serial file:${log_file}
- -monitor null
-) +qemu_options
-"${kvm[@]}" --append "${append}"
+run_qemu
2.23.0
- do
case "$a" in
'#')
;;
this case is useless, just delete it
maybe useful, keep it.
Thanks, Yinsi
Thanks, Luan Shengde
initrd)
file=$(basename "$b")
wget --timestamping -a ${log_file} --progress=bar:force $b
initrds+="$file "
;;
kernel)
kernel=$(basename "$b")
wget --timestamping -a ${log_file} --progress=bar:force $b
append=$(echo "$c" | sed -r "s/ initrd=[^ ]+//g")
;;
*)
;;
esac
- done < $ipxe_script
+}
-append= -initrds= -while read a b c -do
- case "$a" in
'#')
;;
initrd)
file=$(basename "$b")
wget --timestamping -a ${log_file} --progress=bar:force $b
initrds+="$file "
;;
kernel)
kernel=$(basename "$b")
wget --timestamping -a ${log_file} --progress=bar:force $b
append=$(echo "$c" | sed -r "s/ initrd=[^ ]+//g")
;;
*)
;;
- esac
-done < $ipxe_script +check_option_value() +{
- [ -s "$kernel" ] || {
echo "can't get kernel or kernel size is 0"
exit
- }
- [ -n "$initrds" ] || {
exit
- }
- initrd=initrd
- cat $initrds > $initrd
+}
+print_message() +{
- echo $SCHED_PORT
- echo kernel: $kernel
- echo initrds: $initrds
- echo append: $append
- echo less $log_file
- sleep 5
+}
-[ -s "$kernel" ] || {
- echo "can't get kernel or kernel size is 0"
- exit
+qemu_options() +{
- kvm=(
$qemu
-machine virt-4.0,accel=kvm,gic-version=3
-kernel $kernel
-initrd $initrd
-smp $nr_cpu
-m $memory
-cpu Kunpeng-920
-bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd
-nic tap,model=virtio-net-pci,helper=/usr/libexec/qemu-bridge-helper,br=br0,mac=${mac}
-k en-us
-no-reboot
-nographic
-serial file:${log_file}
-monitor null
- )
}
-[ -n "$initrds" ] || {
- exit
+run_qemu() +{
- "${kvm[@]}" --append "${append}"
}
-initrd=initrd -cat $initrds > $initrd +check_logfile +write_logfile
-echo $SCHED_PORT -echo kernel: $kernel -echo initrds: $initrds -echo append: $append -echo less $log_file +qemu_command +option_value +check_option_value
-sleep 5 +print_message
-kvm=(
- $qemu
- -machine virt-4.0,accel=kvm,gic-version=3
- -kernel $kernel
- -initrd $initrd
- -smp $nr_cpu
- -m $memory
- -cpu Kunpeng-920
- -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd
- -nic tap,model=virtio-net-pci,helper=/usr/libexec/qemu-bridge-helper,br=br0,mac=${mac}
- -k en-us
- -no-reboot
- -nographic
- -serial file:${log_file}
- -monitor null
-) +qemu_options
-"${kvm[@]}" --append "${append}"
+run_qemu
2.23.0
On Tue, Dec 29, 2020 at 11:55:10AM +0800, Liu Yinsi wrote:
use function better.
test: /srv/result/host-info/2020-12-29/vm-2p8g/openeuler-20.09-aarch64/z9.273758
ssssss-off-by: Liu Yinsi liuyinsi@163.com
providers/qemu/kvm.sh | 163 ++++++++++++++++++++++++++---------------- 1 file changed, 100 insertions(+), 63 deletions(-)
diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index fd921dc..6c4ad00 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -7,78 +7,115 @@ : ${nr_cpu:=1} : ${memory:=1G}
-log_file=/srv/cci/serial/logs/${hostname} -if [ ! -f "$log_file" ]; then
- touch $log_file
- # fluentd refresh time is 1s
- # let fluentd to monitor this file first
- sleep 2
-fi +check_logfile() +{
- log_file=/srv/cci/serial/logs/${hostname}
- if [ ! -f "$log_file" ]; then
touch $log_file
# fluentd refresh time is 1s
# let fluentd to monitor this file first
sleep 2
- fi
+}
-qemu=qemu-system-aarch64 -command -v $qemu >/dev/null || qemu=qemu-kvm +qemu_command() +{
- qemu=qemu-system-aarch64
- command -v $qemu >/dev/null || qemu=qemu-kvm
+}
-ipxe_script=ipxe_script -curl http://$%7BSCHED_HOST:-172.17.0.1%7D:$%7BSCHED_PORT:-3000%7D/boot.ipxe/mac/$... > $ipxe_script -cat $ipxe_script >> ${log_file} +write_logfile() +{
- ipxe_script=ipxe_script
- curl http://$%7BSCHED_HOST:-172.17.0.1%7D:$%7BSCHED_PORT:-3000%7D/boot.ipxe/mac/$... > $ipxe_script
- cat $ipxe_script >> ${log_file}
+}
+option_value() +{
- append=
- initrds=
- while read a b c
- do
case "$a" in
'#')
;;
initrd)
file=$(basename "$b")
wget --timestamping -a ${log_file} --progress=bar:force $b
initrds+="$file "
;;
kernel)
kernel=$(basename "$b")
wget --timestamping -a ${log_file} --progress=bar:force $b
append=$(echo "$c" | sed -r "s/ initrd=[^ ]+//g")
;;
*)
;;
esac
- done < $ipxe_script
+}
-append= -initrds= -while read a b c -do
- case "$a" in
'#')
;;
initrd)
file=$(basename "$b")
wget --timestamping -a ${log_file} --progress=bar:force $b
initrds+="$file "
;;
kernel)
kernel=$(basename "$b")
wget --timestamping -a ${log_file} --progress=bar:force $b
append=$(echo "$c" | sed -r "s/ initrd=[^ ]+//g")
;;
*)
;;
- esac
-done < $ipxe_script +check_option_value() +{
- [ -s "$kernel" ] || {
echo "can't get kernel or kernel size is 0"
exit
- }
- [ -n "$initrds" ] || {
exit
- }
- initrd=initrd
- cat $initrds > $initrd
+}
+print_message() +{
- echo $SCHED_PORT
- echo kernel: $kernel
- echo initrds: $initrds
- echo append: $append
- echo less $log_file
- sleep 5
+}
-[ -s "$kernel" ] || {
- echo "can't get kernel or kernel size is 0"
- exit
+qemu_options() +{
- kvm=(
$qemu
-machine virt-4.0,accel=kvm,gic-version=3
-kernel $kernel
-initrd $initrd
-smp $nr_cpu
-m $memory
-cpu Kunpeng-920
-bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd
-nic tap,model=virtio-net-pci,helper=/usr/libexec/qemu-bridge-helper,br=br0,mac=${mac}
-k en-us
-no-reboot
-nographic
-serial file:${log_file}
-monitor null
- )
}
-[ -n "$initrds" ] || {
- exit
+run_qemu() +{
- "${kvm[@]}" --append "${append}"
}
Can the two methods of run_qemu and qemu_options be merged?
Thanks, Yale
-initrd=initrd -cat $initrds > $initrd +check_logfile +write_logfile
-echo $SCHED_PORT -echo kernel: $kernel -echo initrds: $initrds -echo append: $append -echo less $log_file +qemu_command +option_value +check_option_value
-sleep 5 +print_message
-kvm=(
- $qemu
- -machine virt-4.0,accel=kvm,gic-version=3
- -kernel $kernel
- -initrd $initrd
- -smp $nr_cpu
- -m $memory
- -cpu Kunpeng-920
- -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd
- -nic tap,model=virtio-net-pci,helper=/usr/libexec/qemu-bridge-helper,br=br0,mac=${mac}
- -k en-us
- -no-reboot
- -nographic
- -serial file:${log_file}
- -monitor null
-) +qemu_options
-"${kvm[@]}" --append "${append}"
+run_qemu
2.23.0
-serial file:${log_file}
-monitor null
- )
}
-[ -n "$initrds" ] || {
- exit
+run_qemu() +{
- "${kvm[@]}" --append "${append}"
}
Can the two methods of run_qemu and qemu_options be merged?
good
Thanks, Yinsi
Thanks, Yale
-initrd=initrd -cat $initrds > $initrd +check_logfile +write_logfile
-echo $SCHED_PORT -echo kernel: $kernel -echo initrds: $initrds -echo append: $append -echo less $log_file +qemu_command +option_value +check_option_value
-sleep 5 +print_message
-kvm=(
- $qemu
- -machine virt-4.0,accel=kvm,gic-version=3
- -kernel $kernel
- -initrd $initrd
- -smp $nr_cpu
- -m $memory
- -cpu Kunpeng-920
- -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd
- -nic tap,model=virtio-net-pci,helper=/usr/libexec/qemu-bridge-helper,br=br0,mac=${mac}
- -k en-us
- -no-reboot
- -nographic
- -serial file:${log_file}
- -monitor null
-) +qemu_options
-"${kvm[@]}" --append "${append}"
+run_qemu
2.23.0