QEMU 2.10.1 编译安装

来源:互联网 发布:sip服务器 linux 编辑:程序博客网 时间:2024/05/17 23:20

QEMU 2.10.1 编译安装

原本在 Ubuntu 上可以直接通过apt install qemu-km可以直接安装 QEMU,但是这样安装的版本太低。想用官方的最新版本还得自己编译源码安装。

本文记录了我在新安装的 Ubuntu 17.10 desktop 安装 QEMU 的过程。

源码包安装

下载源码包

$ wget https://download.qemu.org/qemu-2.10.1.tar.xz
  • 1

安装编译工具

由于我是新安装的系统,所以编译和构建工具都没有

$ sudo apt install gcc$ sudo apt install build-essential
  • 1
  • 2

我还安装了automake,不知需不需要。

$ sudo apt install automake
  • 1

安装编译依赖库

这些库是我后面运行./configure时提示缺失的。

$ sudo apt install -y pkg-config$ sudo apt install -y libpixman-1-dev$ sudo apt install -y libfdt-dev
  • 1
  • 2
  • 3

编译

$ cd qemu-2.10.1$ ./configure
  • 1
  • 2

这条命令很快,只是检测环境生成配置文件。

$ make
  • 1

这才是真正的编译过程,花了大概二十分钟。感觉时间挺长的,所以我用这段时间写下这篇文章用于记录。

编译完后可以在当前目录看可以执行文件qemu-img,在子目录x86_64-softmm看到qemu-system-x86_64可执行文件,在子目录i386-softmmu看到可执行文件qemu-system-i386。其实名称为*-softmmu的子目录下都有一个对应的qemu-system-*可执行文件,应该是对应不同架构和平台。

$ ls -d *-softmmuaarch64-softmmu       microblaze-softmmu  ppc64-softmmu    tricore-softmmualpha-softmmu         mips64el-softmmu    ppcemb-softmmu   unicore32-softmmuarm-softmmu           mips64-softmmu      ppc-softmmu      x86_64-softmmucris-softmmu          mipsel-softmmu      s390x-softmmu    xtensaeb-softmmui386-softmmu          mips-softmmu        sh4eb-softmmu    xtensa-softmmulm32-softmmu          moxie-softmmu       sh4-softmmum68k-softmmu          nios2-softmmu       sparc64-softmmumicroblazeel-softmmu  or1k-softmmu        sparc-softmmu
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

之前编译这么慢应该也是因为要生成支持这么多平台的可执行文件。下次能不能在configure中指定参数,让其只生成 x86 平台的版本,这样应该会快点。

安装

虽然前面得到了 QMEU 相关的可执行文件,但是要使用起来不方便。

$ sudo make install
  • 1

这样就把相应的可执行文件放到系统标准的程序目录下了。

验证一下

$ qemu-x86_64 --versionqemu-x86_64 version 2.10.1Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers$ qemu-system-i386 --versionQEMU emulator version 2.10.1Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers1$ qemu-img --versionqemu-img version 2.10.1Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

用 git clone 源码仓库安装

这种方式我没试过,不知道能不能自动解决依赖问题。

clone 源码仓库

官方的 git 代码仓库

$ git clone git://git.qemu.org/qemu.git
  • 1

或者 GitHub 上的镜像源:

$ git clone git@github.com:qemu/qemu.git
  • 1

解决依赖子项目

$ git submodule init$ git submodule update --recursive
  • 1
  • 2

编译安装

$ ./configure$ make宁波艺星整形http://www.lyxcl.org/ 
  • 1
  • 2
原创粉丝点击