【转】How to Start Intel Hardware-assisted Virtualization (hypervisor) on Linux to Speed-up Intel Android x86 Emulator

The Intel Hardware Accelerated Execution Manager (Intel® HAXM) is a hardware-assisted virtualization engine (hypervisor) that uses Intel Virtualization Technology (VT) to speed up Android app emulation on a host machine. In combination with Android x86 emulator images provided by Intel and the official Android SDK Manager, HAXM allows for faster Android emulation on Intel VT enabled systems. HAXM for both Windows and OS X are available now.

Since Google mainly supports Android build on Linux platform (with Ubuntu 64-bit OS as top Linux platform, and OS X as 2nd), and a lot of Android Developers are using AVD on Eclipse or Android Studio hosted by a Linux system, it is very critical that Android developers take advantage of Intel hardware-assisted KVM virtualization for Linux just like HAXM for Windows and OS X.

Below are the quick step-by-step's on how to install, enable KVM  on Ubuntu host platform and start Intel Android x86 emulator with Intel hardware-assisted virtualization (hypervisor). The result is very pleasing and AVD runs significantly faster and smoother than without hypervisor.

KVM Installation

I referred the instructions from Ubuntu community documentation page.to get KVM installed.To see if your processor supports hardware virtualization, you can review the output from this command:

$ egrep -c '(vmx|svm)' /proc/cpuinfo

If the output is 0 it means that your CPU doesn't support hardware virtualization.

Next is to install CPU checker:

$ sudo apt-get install cpu-checker

Now you can check if your cpu supports kvm:

$sudo kvm-ok

and insert root password

If you see:
"INFO: Your CPU supports KVM extensions
KVM acceleration can be used"

It means you can  run your virtual machine faster with the KVM extensions.

If you see:
"INFO: KVM is disabled by your BIOS
HINT: Enter your BIOS setup and enable Virtualization Technology (VT),
and then hard poweroff/poweron your system
KVM acceleration can NOT be used"

You need to go to BIOS setup and enable the VT.

Use a 64 bit kernel

Running a 64bit kernel on the host operating system is recommended since Google no longer offers support for 32bit kernel..
This allows the serving of more than 2GB of RAM for your VMs.
Also, a 64-bit system can host both 32-bit and 64-bit guests. A 32-bit system can only host 32-bit guests.
To see if your processor is 64-bit, you can run this command:

$ egrep -c ' lm ' /proc/cpuinfo

If 0 is printed, it means that your CPU is not 64-bit.
If 1 or higher, it is. Note: lm stands for Long Mode which equates to a 64-bit CPU.
Now see if your running kernel is 64-bit, just issue the following command:

$ uname -m

x86_64 indicates a running 64-bit kernel. If you see i386, i486, i586 or i686, you're running a 32-bit kernel.

Install KVM

For Ubuntu Lucid (12.04 LTS Precise) or later:

$ sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils ia32-libs-multiarch

If it is displayed, you may ignore the Postfix Configuration below by selecting "No Configuration"

Next is to add your <username> account to the group kvm and libvirtd

$ sudo adduser your_user_name kvm
$ sudo adduser your_user_name libvirtd

After the installation, you need to relogin so that your user account becomes an effective member of kvm and libvirtd user groups. The members of this group can run virtual machines.

Verify Installation
You can test if your install has been successful with the following command:
$ sudo virsh -c qemu:///system list
Your screen will paint the following below if successful:
Id Name                 State
----------------------------------

Install Java

Please referred to the instructions from Ubuntu community documentation pageto get Java installed. There are four implementations of Java. Oracle java 7 has to be installed in order to run Android emulator x86 system Images.

Start the AVD from Android SDK Directly from Terminal

Documented information on how to install Android sdk or Android Sudio can be found on android developers website.

After installing Android SDK a new virtual machine can be created using virtual device manager. Make sure that after installation OS system variable LD_LIBRARY_PATH point to <SDK directory>/tools/lib64

Type in a terminal:

$android avd

Android Virtual device manager is started. Click on the create button and fallow the wizard remembering the virtual machine name and selecting x86 system image in CPU/ABI section

Now start the Android for x86 Intel Emulator using  the following command:

$ <SDK directory>/tools/emulator64-x86 -avd Your_AVD_Name -qemu -m 2047 -enable-kvm

Only a 64-bits Ubuntu can allow you to run allocated Memory of 2G or more. My 64-bit Ubuntu has 6G of Memory, so I used 1/3 of it for Android AVD. My AVD name is Intel_Atom_x86_64. '-qemu' provides the options to qemu, and '-m' specifies the amount of memory for the emulated Android (i.e. guest). If you use too small value for that, it's possible that performance is bad because of frequent swapping activities. Add '-show-kernel' to see the message from the kernel.

Start the AVD by AVD Manager in Android Studio

Below is the recommended procedure. If you are running the emulator from Android Emulator, run your Android application with an x86-based AVD and include the KVM options:

  • In Android Studio, click your Android project folder and then select Run > Edit Configurations
  • Click the Emulator tab
  • Check Additional command line options and in the input field enter:

-qemu –m 2047 -enable-kvm

    • Run your Android project using this run configuration.

【转】How to Start Intel Hardware-assisted Virtualization (hypervisor) on Linux to Speed-up Intel Android x86 Emulator的更多相关文章

  1. Hardware assisted virtualization and data execution protection must be enabled in the BIOS. See https://docs.docker.com/docker-for-windows/troubleshoot/#virtualization

    解决办法:先关闭 Hyper-V ,然后重新开启 Hyper-V 即可! 来自:https://zhuanlan.zhihu.com/p/51939654

  2. How to build ffmpeg with hardware accelerated codecs for Android x86

    In order to build a complete ffmpeg with hardware acceleration for Intel platform (XXX lake + Atom), ...

  3. Virtio: An I/O virtualization framework for Linux

    The Linux kernel supports a variety of virtualization schemes, and that's likely to grow as virtuali ...

  4. Android x86模拟器Intel Atom x86 System Image配置与使用方法

    Android x86模拟器Intel Atom x86 System Image配置与使用方法      前言:      大家现在开发使用的Android 模拟器模拟的是 ARM 的体系结构(ar ...

  5. [转]Android x86模拟器Intel Atom x86 System Image配置与使用方法

    Android x86模拟器Intel Atom x86 System Image配置与使用方法 前言: 大家现在开发使用的Android 模拟器模拟的是 ARM 的体系结构(arm-eabi),因此 ...

  6. Virtualization solutions on Linux systems - KVM and VirtualBox

    Introduction Virtualization packages are means for users to run various operating systems without &q ...

  7. linux 下gcc生成intel汇编

    留作备忘: gcc -S -masm=intel xxxx.c 生成elf可执行文件: gcc -o xxx xxxx.s 反汇编 objdump xxx 补充: 在使用gcc 对C语言程序进行编译时 ...

  8. Ubuntu Intel显卡驱动安装 (Ubuntu 14.04--Ubuntu 16.10 + Intel® Graphics Update Tool)

    最近使用在使用Ubuntu时,发现大部分情况下,不安装显卡驱动,使用默认驱动,都是没有问题的,但对于一些比较奇特配置的电脑,如下所示,如果使用默认驱动,会时常莫名其妙死机crash,尤其是在使用Ope ...

  9. intel vtune 介绍、安装和使用

    intel vtune 介绍 https://software.intel.com/en-us/vtune intel vtune 安装包下载地址 https://software.intel.com ...

随机推荐

  1. 与《YII框架》不得不说的故事—5篇目录

    与<YII框架>不得不说的故事—基础篇 第1章 课程目标 1-1 课程目标 (00:54) 第2章 课前知识准备 2-1 YII的启动和安装 (05:12) 2-2 YII请求处理流程 ( ...

  2. 深入剖析PE文件

    不赖猴的笔记,转载请注明出处. 深入剖析PE文件 PE文件是Win32的原生文件格式.每一个Win32可执行文件都遵循PE文件格式.对PE文件格式的了解可以加深你对Win32系统的深入理解. 一.   ...

  3. C#实现大数据量TXT文本数据快速高效去重

    原文 C#实现大数据量TXT文本数据快速高效去重 对几千万的TXT文本数据进行去重处理,查找其中重复的数据,并移除.尝试了各种方法,下属方法是目前尝试到最快的方法.以下代码将重复和不重复数据进行分文件 ...

  4. Advanced Replication同步复制实验(基于Trigger&基于Materialized View)

    1. 高级复制和流复制介绍 1.1 高级复制(Advanced Replication) 高级复制也称为对称复制,分为多主体站点复制(Multiple Master Rplication).物化视图站 ...

  5. mysql 函数执行权限

    mysql> show grants for query_all@'115.236.1x0.x'; +---------------------------------------------- ...

  6. java的表达式

    Java是面向表达式的语言,Java中一个简单表达式可以是下面任意一种: ● 常量:7.false.● 单引号括起来的字符字面常量:'A'.'3'.● 双引号括起来的字符串字面常量:"foo ...

  7. 关于css的默认宽度

    <div class="boxa"> <div class="boxb">我是div</div> </div> ...

  8. 关于js封装框架类库之DOM操作模块(一)

    在前端开发的过程中,javascript极为重要的一个功能就是对DOM对象的操作,而对其封装就是为了更好地进行DOM操作,提高浏览器的支持效率 现在给出一个案例:页面创建三个div,然后给其添加样式 ...

  9. HDU 4497 GCD and LCM(分解质因子+排列组合)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4497 题意:已知GCD(x, y, z) = G,LCM(x, y, z) = L.告诉你G.L,求满 ...

  10. C#操作Office.word(二)

    在上一篇文章"C#操作Office.word(一)"中我们讲述了如何使用VS2010引用COM中Miscrosoft Word 14.0 Object Library实现创建文档, ...