Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Unified Diff: build/android/install_emulator_deps.py

Issue 116493002: build/android/install_emulator_deps.py: run kvm-ok as root when needed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only run kvm-ok (as root) after installing packages, probe for /dev/kvm directly before that. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/install_emulator_deps.py
diff --git a/build/android/install_emulator_deps.py b/build/android/install_emulator_deps.py
index ec923dfc8a99b26e36d1ea4326b2a58565e7e086..85aface82f61bd885684efc18705afdde81a7398 100755
--- a/build/android/install_emulator_deps.py
+++ b/build/android/install_emulator_deps.py
@@ -94,13 +94,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
@@ -135,11 +148,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).')
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698