On Tue, Jan 05, 2021 at 09:17:55AM +0800, Liu Yinsi wrote:
before: support kvm for aarch64 after: support kvm for aarch64, x86_64, riscv64
[how] put public options like $kernel, $initrd, $smp together, list different options like $machine, $bios, $nic according to different qemu command, then merge all options.
test: /srv/result/host-info/2021-01-04/vm-2p8g/debian-sid-aarch64/z9.280302 /srv/result/host-info/2021-01-04/vm-2p8g/debian-sid-riscv64/z9.280305 /srv/result/host-info/2021-01-04/vm-2p8g/debian-sid-x86_64/z9.280303
for diff arch:
kvm-aarch64.sh kvm-x86_64.sh kvm-riscv64.sh
on qemu.sh source "$CCI_SRC/providers/$provider/${template}-$(arch).sh"
how about this?
Thanks, Shenwei
Signed-off-by: Liu Yinsi liuyinsi@163.com
providers/qemu/kvm.sh | 106 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 93 insertions(+), 13 deletions(-)
diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index c926d3d..8749568 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -18,12 +18,6 @@ check_logfile() } }
-qemu_command() -{
- qemu=qemu-system-aarch64
- command -v $qemu >/dev/null || qemu=qemu-kvm
-}
write_logfile() { ipxe_script=ipxe_script @@ -72,6 +66,50 @@ get_initrd() cat $initrds > $initrd }
+get_bios() +{
bios=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd
[ -f "$bios" ] || bios=/usr/share/ovmf/OVMF.fd
+}
+get_helper() +{
helper=/usr/libexec/qemu-bridge-helper
[ -f "$helper" ] || helper=/usr/lib/qemu/qemu-bridge-helper
+}
+get_nic() +{
nic="tap,model=virtio-net-pci,helper=$helper,br=br0,mac=${mac}"
+}
+get_device() +{
- device="virtio-net-device,netdev=net0,mac=${mac}"
+}
+get_netdev() +{
- netdev="bridge,br=br0,id=net0,helper=${helper}"
+}
+get_qemu() +{
- qemu=(
qemu-system-aarch64
qemu-kvm
qemu-system-x86_64
- )
- for qemu in "${qemu[@]}"
- do
[ -n "$(command -v ${qemu})" ] && break
- done
- # debian has both qemu-system-x86_64 and qemu-system-riscv64 command
- [[ $kernel =~ 'riscv64' ]] && qemu=qemu-system-riscv64
+}
print_message() { echo $SCHED_PORT @@ -83,36 +121,78 @@ print_message() sleep 5 }
-run_qemu() +public_option() { kvm=( $qemu
-kernel $kernel -initrd $initrd -smp $nr_cpu -m $memory-machine virt-4.0,accel=kvm,gic-version=3
-cpu Kunpeng-920
-bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd
-k en-us -no-reboot -nographic -serial file:${log_file} -monitor null )-nic tap,model=virtio-net-pci,helper=/usr/libexec/qemu-bridge-helper,br=br0,mac=${mac}
+}
- "${kvm[@]}" --append "${append}"
+run_qemu() +{
- case "$qemu" in
qemu-system-aarch64)
arch_option=(
-machine virt-4.0,accel=kvm,gic-version=3
-cpu Kunpeng-920
-bios $bios
-nic $nic
)
;;
qemu-kvm)
[ "$(arch)" == "aarch64" ] && arch_option=(
-machine virt-4.0,accel=kvm,gic-version=3
-cpu Kunpeng-920
-bios $bios
-nic $nic
)
[ "$(arch)" == "x86_64" ] && arch_option=(
-bios $bios
-nic $nic
)
;;
qemu-system-x86_64)
arch_option=(
-bios $bios
-nic $nic
)
;;
qemu-system-riscv64)
arch_option=(
-machine virt
-device virtio-net-device,netdev=net0,mac=${mac}
-netdev bridge,br=br0,id=net0,helper=${helper}
)
;;
- esac
- "${kvm[@]}" "${arch_option[@]}" --append "${append}"
}
check_logfile write_logfile
-qemu_command parse_ipxe_script check_option_value
get_initrd +get_bios +get_helper +get_nic +get_device +get_netdev +get_qemu
print_message
+public_option run_qemu -- 2.23.0