好记性不如铅笔头

linux, 编程

在ubuntu上安装kvm加速Android Emulator

参考网址:
【 http://m.oschina.net/blog/261240
【 http://virtual.51cto.com/art/201206/341911_all.htm
【 http://116.62.110.235/blog/upgrade-intel-architecture-based-android-simulator-speed/

最近突然抽风,要在ubuntu下搞下android,但是又不想用手机了,就用虚拟机吧。在linux下使用KVM可以加快虚拟机的速度。

CONTENTS

KVM的安装:

#检查环境:
cstriker1407@cstriker1407-x64:~$  egrep '(vmx|svm)' /proc/cpuinfo 
。。。。。
。。。。。
#安装需要的软件:
cstriker1407@cstriker1407-x64:~$ sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils  virt-manager
#添加当前用户到kvm,libvirtd组:
cstriker1407@cstriker1407-x64:~$ sudo adduser `id -un` libvirtd
cstriker1407@cstriker1407-x64:~$ sudo adduser `id -un` kvm
#安装验证:
cstriker1407@cstriker1407-x64:~$ sudo virsh -c qemu:///system list
。。。。。

启用KVM加速:

参考网址: 【 http://developer.android.com/tools/devices/emulator.html#accel-vm

Configuring VM Acceleration on Linux

Linux-based systems support virtual machine acceleration through the KVM software package. Follow instructions for installing KVM on your Linux system, and verify that KVM is enabled. In addition to following the installation instructions, be aware of these configuration requirements:

    Running KVM requires specific user permissions, make sure you have sufficient permissions according to the KVM installation instructions.
    If you use another virtualization technology in your Linux platform, unload its kernel driver before running the x86 emulator. For example, the VirtualBox driver program is vboxdrv.

To run an x86-based emulator with VM acceleration:

    If you are running the emulator from the command line, start the emulator with an x86-based AVD and include the KVM options:

    emulator -avd <avd_name> -qemu -m 512 -enable-kvm

    Note: You must provide an x86-based AVD configuration name, otherwise VM acceleration will not be enabled.
    If you are running the emulator from Android Studio, run your Android application with an x86-based AVD and include the KVM options:
        In Android Studio, click your Android module folder and then select Run > Edit Configurations...
        In the left panel of the Run/Debug Configurations dialog, select your Android run configuration or create a new configuration.
        Under the Target Device options, select the x86-based AVD you created previously.
        In the Emulator tab, in the Additional command line options field, enter:

        -qemu -m 512 -enable-kvm

        Run your Android project using this run configuration.

Important: When using the -qemu command line option, make sure it is the last parameter in your command. All subsequent options are interpreted as qemu-specific parameters.

 

发表评论

18 + 1 =

此站点使用 Akismet 来减少垃圾评论。了解我们如何处理您的评论数据