添加了qemu使用VNC作为图像输出的选项 (#222)

* 添加了qemu使用VNC作为图像输出的选项

* 设置vnc端口为5900

---------

Co-authored-by: longjin <longjin@RinGoTek.cn>
This commit is contained in:
HoshuChiu 2023-04-02 15:55:24 +08:00 committed by GitHub
parent 2b771e32f5
commit 6d345b7742
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 12 deletions

View File

@ -79,10 +79,16 @@ write_diskimage-uefi:
bash -c "cd tools && bash grub_auto_install.sh && sudo bash $(ROOT_PATH)/tools/write_disk_image.sh --bios=uefi && cd .." bash -c "cd tools && bash grub_auto_install.sh && sudo bash $(ROOT_PATH)/tools/write_disk_image.sh --bios=uefi && cd .."
# 不编译直接启动QEMU # 不编译直接启动QEMU
qemu: qemu:
sh -c "cd tools && bash run-qemu.sh --bios=legacy && cd .." sh -c "cd tools && bash run-qemu.sh --bios=legacy --display=window && cd .."
# 不编译直接启动QEMU(UEFI) # 不编译直接启动QEMU(UEFI)
qemu-uefi: qemu-uefi:
sh -c "cd tools && bash run-qemu.sh --bios=uefi && cd .." sh -c "cd tools && bash run-qemu.sh --bios=uefi --display=window && cd .."
# 不编译直接启动QEMU,使用VNC Display作为图像输出
qemu-vnc:
sh -c "cd tools && bash run-qemu.sh --bios=legacy --display=vnc && cd .."
# 不编译直接启动QEMU(UEFI),使用VNC Display作为图像输出
qemu-uefi-vnc:
sh -c "cd tools && bash run-qemu.sh --bios=uefi --display=vnc && cd .."
# 编译并写入磁盘镜像 # 编译并写入磁盘镜像
build: build:
@ -107,6 +113,18 @@ run:
$(MAKE) write_diskimage || exit 1 $(MAKE) write_diskimage || exit 1
$(MAKE) qemu $(MAKE) qemu
# uefi方式启动使用VNC Display作为图像输出
run-uefi-vnc:
$(MAKE) all -j $(NPROCS)
$(MAKE) write_diskimage-uefi || exit 1
$(MAKE) qemu-uefi-vnc
# 编译并启动QEMU使用VNC Display作为图像输出
run-vnc:
$(MAKE) all -j $(NPROCS)
$(MAKE) write_diskimage || exit 1
$(MAKE) qemu-vnc
# 在docker中编译并启动QEMU # 在docker中编译并启动QEMU
run-docker: run-docker:
@echo "使用docker构建并运行" @echo "使用docker构建并运行"

View File

@ -1,6 +1,6 @@
# 进行启动前检查 # 进行启动前检查
flag_can_run=1 flag_can_run=1
ARGS=`getopt -o p -l bios: -- "$@"` ARGS=`getopt -o p -l bios:,display: -- "$@"`
eval set -- "${ARGS}" eval set -- "${ARGS}"
echo "$@" echo "$@"
allflags=$(qemu-system-x86_64 -cpu help | awk '/flags/ {y=1; getline}; y {print}' | tr ' ' '\n' | grep -Ev "^$" | sed -r 's|^|+|' | tr '\n' ',' | sed -r "s|,$||") allflags=$(qemu-system-x86_64 -cpu help | awk '/flags/ {y=1; getline}; y {print}' | tr ' ' '\n' | grep -Ev "^$" | sed -r 's|^|+|' | tr '\n' ',' | sed -r "s|,$||")
@ -36,22 +36,39 @@ QEMU_ARGUMENT="-d ${QEMU_DISK_IMAGE} -m ${QEMU_MEMORY} -smp ${QEMU_SMP} -boot or
QEMU_ARGUMENT+="-s -S -cpu ${QEMU_CPU_FEATURES} -rtc ${QEMU_RTC_CLOCK} -serial ${QEMU_SERIAL} -drive ${QEMU_DRIVE} ${QEMU_DEVICES}" QEMU_ARGUMENT+="-s -S -cpu ${QEMU_CPU_FEATURES} -rtc ${QEMU_RTC_CLOCK} -serial ${QEMU_SERIAL} -drive ${QEMU_DRIVE} ${QEMU_DEVICES}"
if [ $flag_can_run -eq 1 ]; then if [ $flag_can_run -eq 1 ]; then
while true;do
case "$1" in case "$1" in
--bios) --bios)
case "$2" in case "$2" in
uefi) #uefi启动新增ovmf.fd固件 uefi) #uefi启动新增ovmf.fd固件
if [ ${ARCH} == x86_64 ] ;then BIOS_TYPE=uefi
sudo ${QEMU} -bios arch/x86_64/efi/OVMF-pure-efi.fd ${QEMU_ARGUMENT}
elif [ ${ARCH} == i386 ] ;then
sudo ${QEMU} -bios arch/i386/efi/OVMF-pure-efi.fd ${QEMU_ARGUMENT}
fi
;; ;;
legacy) legacy)
sudo ${QEMU} ${QEMU_ARGUMENT} BIOS_TYPE=lagacy
;; ;;
esac esac;shift 2;;
--display)
case "$2" in
vnc)
QEMU_ARGUMENT+=" -display vnc=:5900"
;;
window)
;;
esac;shift 2;;
*) break
esac
done
if [ ${BIOS_TYPE} == uefi ] ;then
if [ ${ARCH} == x86_64 ] ;then
sudo ${QEMU} -bios arch/x86_64/efi/OVMF-pure-efi.fd ${QEMU_ARGUMENT}
elif [ ${ARCH} == i386 ] ;then
sudo ${QEMU} -bios arch/i386/efi/OVMF-pure-efi.fd ${QEMU_ARGUMENT}
fi
else
sudo ${QEMU} ${QEMU_ARGUMENT}
fi
esac
else else
echo "不满足运行条件" echo "不满足运行条件"
fi fi