1. yum安装
TODO
CentOS8使用yum安装的qemu版本为4.2.0
,如果需要最新版本,需要从https://www.qemu.org/download/下载最新源码,编译安装。
2. 源码安装
2.1. 下载
Qemu最新源码下载链接:https://www.qemu.org/download/
CentOS8使用yum安装的qemu版本为4.2.0
,如果需要最新版本,需要从https://www.qemu.org/download/下载最新源码,编译安装。
2.2. 编译
wget https://download.qemu.org/qemu-6.1.0.tar.xz
tar xvJf qemu-6.1.0.tar.xz
cd qemu-6.1.0
./configure
make
如果使用GitLab上的master分支,可以:
git clone https://gitlab.com/qemu-project/qemu.git
cd qemu
git submodule init
git submodule update --recursive
./configure
make
当执行./configure
会产生如下错误:
[rongtao@bogon qemu-6.1.0]$ ./configure
Using './build' as the directory for build output
ERROR: Cannot find Ninja
为了确保体系结构、KVM支持、调试功能,可以在配置阶段指令选项:
./configure '--target-list=x86_64-softmmu' '--enable-kvm' '--enable-debug'
安装Ninja
见附录。安装Ninja之后,再次./configure
,提示仍旧有错误:
$ ./configure
Using './build' as the directory for build output
The Meson build system
Version: 0.55.3
Source dir: /home/rongtao/qemu-6.1.0
Build dir: /home/rongtao/qemu-6.1.0/build
Build type: native build
Project name: qemu
Project version: 6.1.0
C compiler for the host machine: cc (gcc 8.4.1 "cc (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1)")
C linker for the host machine: cc ld.bfd 2.30-93
Host machine cpu family: x86_64
Host machine cpu: x86_64
../meson.build:10: WARNING: Module unstable-keyval has no backwards or forwards compatibility and might not exist in future releases.
Program sh found: YES
Program python3 found: YES (/usr/bin/python3)
Program bzip2 found: YES
C++ compiler for the host machine: c++ (gcc 8.4.1 "c++ (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1)")
C++ linker for the host machine: c++ ld.bfd 2.30-93
Program cgcc found: NO
Library m found: YES
Run-time dependency threads found: YES
Library util found: YES
Run-time dependency appleframeworks found: NO (tried framework)
Found pkg-config: /usr/bin/pkg-config (1.4.2)
Run-time dependency pixman-1 found: NO (tried pkgconfig)
../meson.build:328:2: ERROR: Dependency "pixman-1" not found, tried pkgconfig
A full log can be found at /home/rongtao/qemu-6.1.0/build/meson-logs/meson-log.txt
ERROR: meson setup failed
我们一个一个看。为了清晰,给出截图:
安装pixman
即可,参见附录。接着再次./configure
,即可成功。然后进行编译:
$ make
[...]此处省略很多行
[9524/9527] Compiling C object tests/qtest/fdc-test.p/fdc-test.c.o
[9525/9527] Linking target tests/qtest/fdc-test
[9526/9527] Compiling C object tests/qtest/tpm-crb-swtpm-test.p/tpm-tests.c.o
[9527/9527] Linking target tests/qtest/tpm-crb-swtpm-test
AS multiboot.o
BUILD multiboot.img
BUILD multiboot.raw
SIGN multiboot.bin
AS linuxboot.o
BUILD linuxboot.img
BUILD linuxboot.raw
SIGN linuxboot.bin
CC linuxboot_dma.o
BUILD linuxboot_dma.img
BUILD linuxboot_dma.raw
SIGN linuxboot_dma.bin
AS kvmvapic.o
BUILD kvmvapic.img
BUILD kvmvapic.raw
SIGN kvmvapic.bin
AS pvh.o
CC pvh_main.o
BUILD pvh.img
BUILD pvh.raw
SIGN pvh.bin
make[1]: Leaving directory '/home/rongtao/qemu-6.1.0/build'
changing dir to build for make ""...
make[1]: Entering directory '/home/rongtao/qemu-6.1.0/build'
[1/177] Generating qemu-version.h with a meson_exe.py custom command
[2/35] Generating QAPI test (include) with a custom command
make[1]: Leaving directory '/home/rongtao/qemu-6.1.0/build'
$
2.3. 安装
$ sudo make install
[...]
changing dir to build for make "install"...
make[1]: Entering directory '/home/rongtao/qemu-6.1.0/build'
[1/144] Generating qemu-version.h with a meson_exe.py custom command
[1/2] Installing files.
Installing subdir /home/rongtao/qemu-6.1.0/qga/run to /usr/local/var/run
Installing trace/trace-events-all to /usr/local/share/qemu
Installing qemu-system-aarch64 to /usr/local/bin
Stripping target 'qemu-system-aarch64' using strip.
Installing qemu-system-alpha to /usr/local/bin
Stripping target 'qemu-system-alpha' using strip.
Installing qemu-system-arm to /usr/local/bin
Stripping target 'qemu-system-arm' using strip.
Installing qemu-system-avr to /usr/local/bin
Stripping target 'qemu-system-avr' using strip.
[...]
Installing /home/rongtao/qemu-6.1.0/build/pc-bios/descriptors/60-edk2-i386.json to /usr/local/share/qemu/firmware
Installing /home/rongtao/qemu-6.1.0/build/pc-bios/descriptors/60-edk2-x86_64.json to /usr/local/share/qemu/firmware
Installing /home/rongtao/qemu-6.1.0/pc-bios/keymaps/sl to /usr/local/share/qemu/keymaps
Installing /home/rongtao/qemu-6.1.0/pc-bios/keymaps/sv to /usr/local/share/qemu/keymaps
make[1]: Leaving directory '/home/rongtao/qemu-6.1.0/build'
查看Qemu版本:
$ qemu-img --version
qemu-img version 6.1.0
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
安装成功。
3. 参考链接
4. 附录
4.1. 安装Ninja
参考链接:How to Install Invoice Ninja on CentOS 7
Ninja下载:RPM包
这里使用RPM包安装,但是安装过程会提示需要Python2.7,正如centos.pkgs.org所说,ninja的依赖为:
emacs-filesystem -
libc.so.6(GLIBC_2.15)(64bit) -
libgcc_s.so.1()(64bit) -
libgcc_s.so.1(GCC_3.0)(64bit) -
libm.so.6()(64bit) -
libstdc++.so.6()(64bit) -
libstdc++.so.6(CXXABI_1.3)(64bit) -
libstdc++.so.6(GLIBCXX_3.4)(64bit) -
python(abi) = 2.7
rtld(GNU_HASH) -
vim-filesystem -
直接使用yum安装python2.7就可以了:
$ sudo yum install python2
Last metadata expiration check: 0:47:34 ago on Thu 23 Sep 2021 08:41:15 AM CST.
Dependencies resolved.
=============================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================
Installing:
python2 x86_64 2.7.18-4.module_el8.4.0+668+03e3490a appstream 109 k
Installing dependencies:
python2-libs x86_64 2.7.18-4.module_el8.4.0+668+03e3490a appstream 6.0 M
python2-pip-wheel noarch 9.0.3-18.module_el8.4.0+642+1dc4fb01 appstream 1.0 M
python2-setuptools-wheel noarch 39.0.1-13.module_el8.4.0+642+1dc4fb01 appstream 287 k
Installing weak dependencies:
python2-pip noarch 9.0.3-18.module_el8.4.0+642+1dc4fb01 appstream 1.7 M
python2-setuptools noarch 39.0.1-13.module_el8.4.0+642+1dc4fb01 appstream 642 k
Enabling module streams:
python27 2.7
Transaction Summary
=============================================================================================================================
Install 6 Packages
Total download size: 9.7 M
Installed size: 37 M
Is this ok [y/N]: y
然后再次安装ninja:
$ sudo rpm -i ninja-build-1.10.2-3.el7.x86_64.rpm
成功。
4.2. 安装pixman
很简单
$ sudo yum install -y pixman pixman-devel
Copyright (C) CESTC Com.