run qemu in different arch have different options, put same options in $kvm, different options in options_$arch.
Signed-off-by: Liu Yinsi liuyinsi@163.com --- providers/qemu/kvm.sh | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index b9f5716..56cf8c0 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -16,7 +16,7 @@ if [ ! -f "$log_file" ]; then fi
qemu=qemu-system-aarch64 -command -v $qemu >/dev/null || qemu=qemu-kvm +command -v $qemu >/dev/null || qemu=qemu-kvm || qemu=qemu-system-riscv64
echo $SCHED_PORT ipxe_script=ipxe_script @@ -67,15 +67,10 @@ sleep 5
kvm=( $qemu - -machine virt-4.0,accel=kvm,gic-version=3 -kernel $kernel -initrd $initrd -smp $nr_cpu -m $memory - -cpu Kunpeng-920 - -device virtio-gpu-pci - -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 @@ -83,4 +78,38 @@ kvm=( -monitor null )
+options_aarch64=( + -machine virt-4.0,accel=kvm,gic-version=3 + -cpu Kunpeng-920 + -device virtio-gpu-pci + -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} +) + +options_x86_64=( + -device virtio-gpu-pci + -bios /usr/share/ovmf/OVMF.fd + -nic tap,model=virtio-net-pci,helper=/usr/libexec/qemu-bridge-helper,br=br0,mac=${mac} +) + +options_riscv64=( + -machine virt + -device virtio-net-device,netdev=net1,mac=${mac} + -netdev bridge,br=br0,id=net1,helper=/usr/lib/qemu/qemu-bridge-helper + -nic tap,model=virtio-net-pci,helper=/usr/libexec/qemu-bridge-helper,br=br0,mac=${mac} +) + +case $qemu in + qemu-system-aarch64) + kvm=(${kvm[@]} ${args_aarch64[@]}) + ;; + qemu-kvm) + [ $(arch) == "x86_64" ] && kvm=(${kvm[@]} ${args_x86_64[@]}) + [ $(arch) == "aarch64" ] && kvm=(${kvm[@]} ${args_aarch64[@]}) + ;; + qemu-system-riscv) + kvm=(${kvm[@]} ${args_riscv64[@]}) + ;; +esac + "${kvm[@]}" --append "${append}"
please ignore it
Thanks, Shenwei
On Fri, Dec 25, 2020 at 03:45:12PM +0800, Liu Yinsi wrote:
run qemu in different arch have different options, put same options in $kvm, different options in options_$arch.
Signed-off-by: Liu Yinsi liuyinsi@163.com
providers/qemu/kvm.sh | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/providers/qemu/kvm.sh b/providers/qemu/kvm.sh index b9f5716..56cf8c0 100755 --- a/providers/qemu/kvm.sh +++ b/providers/qemu/kvm.sh @@ -16,7 +16,7 @@ if [ ! -f "$log_file" ]; then fi
qemu=qemu-system-aarch64 -command -v $qemu >/dev/null || qemu=qemu-kvm +command -v $qemu >/dev/null || qemu=qemu-kvm || qemu=qemu-system-riscv64
echo $SCHED_PORT ipxe_script=ipxe_script @@ -67,15 +67,10 @@ sleep 5
kvm=( $qemu
- -machine virt-4.0,accel=kvm,gic-version=3 -kernel $kernel -initrd $initrd -smp $nr_cpu -m $memory
- -cpu Kunpeng-920
- -device virtio-gpu-pci
- -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
@@ -83,4 +78,38 @@ kvm=( -monitor null )
+options_aarch64=(
- -machine virt-4.0,accel=kvm,gic-version=3
- -cpu Kunpeng-920
- -device virtio-gpu-pci
- -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}
+)
+options_x86_64=(
- -device virtio-gpu-pci
- -bios /usr/share/ovmf/OVMF.fd
- -nic tap,model=virtio-net-pci,helper=/usr/libexec/qemu-bridge-helper,br=br0,mac=${mac}
+)
+options_riscv64=(
- -machine virt
- -device virtio-net-device,netdev=net1,mac=${mac}
- -netdev bridge,br=br0,id=net1,helper=/usr/lib/qemu/qemu-bridge-helper
- -nic tap,model=virtio-net-pci,helper=/usr/libexec/qemu-bridge-helper,br=br0,mac=${mac}
+)
+case $qemu in
- qemu-system-aarch64)
kvm=(${kvm[@]} ${args_aarch64[@]})
;;
- qemu-kvm)
[ $(arch) == "x86_64" ] && kvm=(${kvm[@]} ${args_x86_64[@]})
[ $(arch) == "aarch64" ] && kvm=(${kvm[@]} ${args_aarch64[@]})
;;
- qemu-system-riscv)
kvm=(${kvm[@]} ${args_riscv64[@]})
;;
+esac
"${kvm[@]}" --append "${append}"
2.23.0