LXR | KVM | PM | Time | Interrupt | Systems Performance | Bootup Optimization

QEMU搭建虚拟化开发环境(QEMU 5.2.0)

 关键词:qemu、ninja等等。

 

环境:Ubuntu 20.04 + QEMU 5.2.0。

1. 安装qemu

1.1 通过工具安装

Ubuntu:
apt-get install qemu

RHEL/CentOS:
yum install qemu-kvm

1.2 从源码安装

安装依赖包:

apt install make gcc g++ pkg-config libglib2.0-dev libmount-dev python3 python3-pip python3-dev git libssl-dev libffi-dev build-essential autoconf automake libfreetype6-dev libtheora-dev libtool libvorbis-dev pkg-config texinfo zlib1g-dev unzip cmake yasm libx264-dev libmp3lame-dev libopus-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo wget zlib1g-dev libpixman-1-dev

通过源码可以安装指定版本qemu,但是需要安装依赖软件Ninja。

apt install re2c
git clone git://github.com/ninja-build/ninja.git && cd ninja
./configure.py --bootstrap
cp ninja /usr/bin/

系统默认的版本可能不满足要求,就需要从官网下载源码进行编译。

wget https://download.qemu.org/qemu-5.2.0.tar.xz
tar xvJf qemu-5.2.0.tar.xz
cd qemu-5.2.0
./configure
sudo make install

从git仓库下载:

git clone https://git.qemu.org/git/qemu.git
cd qemu
git submodule init
git submodule update --recursive

 Linux下详细安装介绍:《https://wiki.qemu.org/Hosts/Linux》。

2. QEMU使用

qemu-system-arm -machine mps2-an505 -cpu cortex-m33 -m 16 -nographic -serial mon:stdio -kernel FreeRTOSDemo_ns.axf

-machine:当前待启动的机器型号。查看当前版本支持的机器列表:qemu-system-arm -machine help。 

Supported machines are:
akita                Sharp SL-C1000 (Akita) PDA (PXA270)
borzoi               Sharp SL-C3100 (Borzoi) PDA (PXA270)
canon-a1100          Canon PowerShot A1100 IS
...
xilinx-zynq-a9       Xilinx Zynq Platform Baseboard for Cortex-A9
xlnx-ep108           Xilinx ZynqMP EP108 board
z2                   Zipit Z2 (PXA27x)

-cpu:当前待启动的CPU型号。通过qemu-system-arm -cpu help查看当前qemu-system-arm支持的cpu型号。

Available CPUs:
...
  cortex-m3
  cortex-m33
...

-m:设置机器配置RAM大小,单位为MB。

-nographic:没有图形界面,只显示命令行。

-serial:重定向虚拟串口到指定设备。

-kernel:指定内核镜像。

posted on 2021-01-12 00:00  ArnoldLu  阅读(3986)  评论(0编辑  收藏  举报

导航