summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authordigit@chromium.org <digit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-18 23:56:07 +0000
committerdigit@chromium.org <digit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-18 23:56:07 +0000
commit053a57cb77281cf588fbc971168ca26a7ba81aca (patch)
tree6556f39643f4f3dbb0d1a7132bf8eb1fa81407b3 /build
parent38c6a51931fe958b7b59ba281157c828f84d4b79 (diff)
downloadchromium_src-053a57cb77281cf588fbc971168ca26a7ba81aca.zip
chromium_src-053a57cb77281cf588fbc971168ca26a7ba81aca.tar.gz
chromium_src-053a57cb77281cf588fbc971168ca26a7ba81aca.tar.bz2
build/android/install_emulator_deps.py: run kvm-ok as root when needed.
This change runs kvm-ok as root after installing the kvm and qemu-kvm packages to ensure that KVM can work. This gives better diagnostics in case of failure, which can happen for one of the following reasons: - The CPU doesn't support virtualization extensions. - The extensions have been disabled by the BIOS. BUG=NONE R=yfriedman@chromium.org,navabi@chromium.org,tfarina@chromium.org,raphael.kubo.da.costa@intel.com Review URL: https://codereview.chromium.org/116493002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241708 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build')
-rwxr-xr-xbuild/android/install_emulator_deps.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/build/android/install_emulator_deps.py b/build/android/install_emulator_deps.py
index 68d050a..fcb0954 100755
--- a/build/android/install_emulator_deps.py
+++ b/build/android/install_emulator_deps.py
@@ -95,13 +95,26 @@ def CheckX86Image(api_level=DEFAULT_ANDROID_API_LEVEL):
def CheckKVM():
- """Check if KVM is enabled.
+ """Quickly check whether KVM is enabled.
Returns:
- True if kvm-ok returns 0 (already enabled)
+ True iff /dev/kvm exists (Linux only).
+ """
+ return os.path.exists('/dev/kvm')
+
+
+def RunKvmOk():
+ """Run kvm-ok as root to check that KVM is properly enabled after installation
+ of the required packages.
+
+ Returns:
+ True iff KVM is enabled (/dev/kvm exists). On failure, returns False
+ but also print detailed information explaining why KVM isn't enabled
+ (e.g. CPU doesn't support it, or BIOS disabled it).
"""
try:
- return not cmd_helper.RunCmd(['kvm-ok'])
+ # Note: kvm-ok is in /usr/sbin, so always use 'sudo' to run it.
+ return not cmd_helper.RunCmd(['sudo', 'kvm-ok'])
except OSError:
logging.info('kvm-ok not installed')
return False
@@ -136,11 +149,10 @@ def InstallKVM():
# TODO(navabi): Use modprobe kvm-amd on AMD processors.
rc = cmd_helper.RunCmd(['sudo', 'modprobe', 'kvm-intel'])
if rc:
- logging.critical('ERROR: Did not add KVM module to Linux Kernal. Make sure '
+ logging.critical('ERROR: Did not add KVM module to Linux Kernel. Make sure '
'hardware virtualization is enabled in BIOS.')
# Now check to ensure KVM acceleration can be used.
- rc = cmd_helper.RunCmd(['kvm-ok'])
- if rc:
+ if not RunKvmOk():
logging.critical('ERROR: Can not use KVM acceleration. Make sure hardware '
'virtualization is enabled in BIOS (i.e. Intel VT-x or '
'AMD SVM).')