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

【转】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.
时间: 2024-10-23 18:18:20

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

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

Android x86模拟器Intel Atom x86 System Image配置与使用方法      前言:      大家现在开发使用的Android 模拟器模拟的是 ARM 的体系结构(arm-eabi),因此模拟器并不是运行在x86上而是模拟的ARM,所以我们调试程序的时候经常感觉到非常慢,大部分开发者应该都深有体会.      针对这种情况,前段时间Intel推出了支持x86的Android模拟器,这将大大提高启动速度和程序的运行速度,这将允许Android模拟器能够以原始速度(真

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

Android x86模拟器Intel Atom x86 System Image配置与使用方法 前言: 大家现在开发使用的Android 模拟器模拟的是 ARM 的体系结构(arm-eabi),因此模拟器并不是运行在x86上而是模拟的ARM,所以我们调试程序的时候经常感觉到非常慢,大部分开发者应该都深有体会. 针对这种情况,前段时间Intel推出了支持x86的Android模拟器,这将大大提高启动速度和程序的运行速度,这将允许Android模拟器能够以原始速度(真机运行速度)运行在使用Inte

Virtio: An I/O virtualization framework for Linux

The Linux kernel supports a variety of virtualization schemes, and that's likely to grow as virtualization advances and new schemes are discovered (for example, lguest). But with all these virtualization schemes running on top of Linux, how do they e

Android x86模拟器Intel Atom x86 System Image配置与使用方法[转载:http://blog.sina.com.cn/s/blog_8669d5ab0101d3s9.html]

前言:大家现在开发使用的Android 模拟器模拟的是 ARM 的体系结构(arm-eabi),因此模拟器并不是运行在x86上而是模拟的ARM,所以我们调试程序的时候经常感觉到非常慢,大部分开发者应该都深有体会.针对这种情况,前段时间Intel推出了支持x86的Android模拟器,这将大大提高启动速度和程序的运行速度,这将允许Android模拟器能够以原始速度(真机运行速度)运行在使用Intel x86处理器的电脑中,各位开发者有福了,下面将为大家展示使用方法.一.首先下载intel提供的 

linux 下gcc生成intel汇编

留作备忘: gcc -S -masm=intel xxxx.c 生成elf可执行文件: gcc -o xxx xxxx.s linux 下gcc生成intel汇编,码迷,mamicode.com

centos7上执行yum group install &quot;Virtualization Hypervisor&quot;出错

centos7上执行yum group install "Virtualization Hypervisor"出错 错误提示:   Transaction check error:   file /usr/lib/systemd/system/blk-availability.service from install of device-mapper-7:1.02.107-5.el7_2.5.x86_64 conflicts with file from package lvm2-7:

【笔记】【原】ubuntu linux 12.04下Intel Math Kernel Library (MKL) 2013安装 以及 使用

实验环境: ubuntu 12.04 lts 安装软件:  仅记录2013版   新版本类似 *安装与配置* 1. 注册 收邮件获得激活码 2. 下载 很大 3. 解压 安装 ./install_sh    是否需要改权限 我忘了 4. 跟着提示一步步走 我没有改路劲 /opt/intel/   里边如果有东西,就会无视不同名文件和目录并覆盖同名文件和目录 5. 配置 source /opt/intel/   composer_xe_2013.5.192 添加动态路径 /etc/ld.so.co

How to Enable Intel Virtualization Technology

Most of the time, hardware virtualization technology extensions should be enabled in motherboard BIOS in order to run recent OS and applications. Specifically Windows 8 and 8.1 require vt-x/amd-v enabled processors even to install it on virtual machi

Openflow Lab

GETTING STARTED OPENFLOW OPENVSWITCH TUTORIAL LAB : SETUP For a more up to date tutorial as anything more then 6 months old is outdated in the world of SDN Please see:OpenDaylight OpenStack Integration with DevStack on Fedora 20 I wrote a Python Open