使用qemu-system-loongarch64在x86上起loongarch64虚拟机

2023-12-29 13:34:55

一、下载Qemu 源码

wget https://download.qemu.org/qemu-8.2.0.tar.xz

二、安装编译依赖

sudo apt update
sudo apt install clang
sudo apt-get install git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev ninja-build
sudo apt-get install git-email
sudo apt-get install libaio-dev libbluetooth-dev libcapstone-dev libbrlapi-dev libbz2-dev
sudo apt-get install libcap-ng-dev libcurl4-gnutls-dev libgtk-3-dev
sudo apt-get install libibverbs-dev libjpeg8-dev libncurses5-dev libnuma-dev
sudo apt-get install librbd-dev librdmacm-dev
sudo apt-get install libsasl2-dev libsdl2-dev libseccomp-dev libsnappy-dev libssh-dev
sudo apt-get install libvde-dev libvdeplug-dev libvte-2.91-dev libxen-dev liblzo2-dev
sudo apt-get install valgrind xfslibs-dev
sudo apt-get install libnfs-dev libiscsi-dev
sudo apt-get install libslirp-dev

三、编译

$ tar xf qemu-8.2.0.tar.gz
$ cd qemu-8.2.0
$ mkdir build
$ cd build/
$ …/configure --enable-slirp --target-list=loongarch64-softmmu --prefix=/usr
$ make -j8
$ make install

四、运行

下载固件
$ wget https://mirrors.wsyu.edu.cn/loongarch/archlinux/images/QEMU_EFI_8.1.fd

下载系统
$wget https://mirrors.wsyu.edu.cn/loongarch/archlinux/images/archlinux-mate-2023.12.13-loong64.qcow2.zst
$ zstd -d archlinux-mate-2023.12.13-loong64.qcow2.zst
运行qemu
$qemu-system-loongarch64
-m 4G
-cpu la464-loongarch-cpu
-machine virt
-smp 4
-bios ./QEMU_EFI_7.2.fd
-serial stdio
-net nic -net user
-device virtio-vga
-device nec-usb-xhci,id=xhci,addr=0x1b
-device usb-tablet,id=tablet,bus=xhci.0,port=1
-device usb-kbd,id=keyboard,bus=xhci.0,port=2
-hda archlinux-mate-2023.12.13-loong64.qcow2
系统的默认账号密码都是:loongarch

添加网桥
brctl addbr br0 && ifconfig br0 up && brctl addif br0 eth0(本地上网的网卡的名称)
使用桥接的方式起虚拟机
qemu-system-loongarch64 -nographic -machine virt -smp 4 -bios ./archives/edk2-loongarch64-code.fd -serial mon:stdio -net nic,model=virtio -net bridge,br=br0,helper=/usr/lib/qemu/qemu-bridge-helper -drive file=generic.qcow2

文章来源:https://blog.csdn.net/qq_25650463/article/details/135286539
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。