From 80c9e8f8f0adb25c1a33ff09cb51e7df5b1cdd99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E9=93=AD=E6=B6=9B?= <114841534+1037827920@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:26:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(tools):=E6=94=AF=E6=8C=81=E5=9C=A8=E6=97=A0?= =?UTF-8?q?kvm=E6=94=AF=E6=8C=81=E4=B8=8B=E8=BF=90=E8=A1=8CDragonOS=20(#10?= =?UTF-8?q?10)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(tools):支持在无kvm支持下运行DragonOS * fix: 修正问题:在非Linux上面加速选项选择的不正确 --------- Co-authored-by: jinlong --- tools/run-qemu.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/run-qemu.sh b/tools/run-qemu.sh index 8f201c8de..ba2d3ce1a 100644 --- a/tools/run-qemu.sh +++ b/tools/run-qemu.sh @@ -48,10 +48,16 @@ qemu_trace_usb=trace:usb_xhci_reset,trace:usb_xhci_run,trace:usb_xhci_stop,trace # 根据架构设置qemu的加速方式 if [ ${ARCH} == "i386" ] || [ ${ARCH} == "x86_64" ]; then - qemu_accel="kvm" - if [ $(uname) == Darwin ]; then - qemu_accel=hvf + qemu_accel="kvm" + if [ $(uname) == Darwin ]; then + qemu_accel=hvf + else + # 判断系统kvm模块是否加载 + if [ ! -e /dev/kvm ]; then + # kvm模块未加载,使用tcg加速 + qemu_accel="tcg" fi + fi fi # uboot版本 @@ -82,7 +88,10 @@ BIOS_TYPE="" VIRTIO_BLK_DEVICE=false # 如果qemu_accel不为空 if [ -n "${qemu_accel}" ]; then - QEMU_ACCELARATE="-machine accel=${qemu_accel} -enable-kvm " + QEMU_ACCELARATE=" -machine accel=${qemu_accel} " + if [ "${qemu_accel}" == "kvm" ]; then + QEMU_ACCELARATE+=" -enable-kvm " + fi fi if [ ${ARCH} == "i386" ] || [ ${ARCH} == "x86_64" ]; then