Closed Bug 1548948 Opened 5 years ago Closed 4 years ago

|mach install| fails to start x86 emulator

Categories

(Firefox Build System :: General, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: erahm, Assigned: gbrown)

References

(Blocks 1 open bug)

Details

(Keywords: in-triage, Whiteboard: dev-prod-2020)

I installed an x86 emulator with mach android-emulator --version x86-7.0 and then did a mach install which fails due to something about kvm. I searched for the error message and it looks like I need to do something like:

sudo apt install qemu-kvm
sudo adduser <user> kvm

Full output from mach install

erahm@shetland:~/dev/mozilla-unified$ ./mach install
No Android devices connected. Start an emulator? (Y/n) 
Starting emulator running Android 7.0 x86...
accel:
11
This user doesn't have permissions to use KVM (/dev/kvm)
accel
WARNING: Unable to verify kvm acceleration!
WARNING: The x86 emulator may fail to start without kvm.
WARNING: Emulator has already completed!
WARNING: See log at /home/erahm/.mozbuild/android-device/emulator.log and/or use --verbose for more information.
 0:11.84 /usr/bin/make -C . -j16 -s -w install
 0:11.86 make: Entering directory '/var/dev/erahm/mozilla-unified/objdir-android-x86-frontend'
 0:11.86 No devices are connected.  Connect a device or start an emulator.
 0:11.87 /var/dev/erahm/mozilla-unified/mobile/android/build.mk:35: recipe for target 'install' failed
 0:11.87 make: *** [install] Error 1
 0:11.87 make: Leaving directory '/var/dev/erahm/mozilla-unified/objdir-android-x86-frontend'

(In reply to Eric Rahm [:erahm] from comment #0)

sudo apt install qemu-kvm
sudo adduser <user> kvm

FWIW, this did not help.

(In reply to Eric Rahm [:erahm] from comment #1)

(In reply to Eric Rahm [:erahm] from comment #0)

sudo apt install qemu-kvm
sudo adduser <user> kvm

FWIW, this did not help.

I found another random command that did help:

sudo setfacl -m u:erahm:rwx /dev/kvm

gbrown: Should those WARNING lines about not verifying kvm from android_device.py be errors instead? Or is there a case where the x86 emulator should work without kvm permissions? I'm wondering if we should just return an error immediately and provide some instructions on how to configure /dev/kvm.

erahm: I'd be curious to know if you can access /dev/kvm without the setfacl if you log out / log back in to make sure you have 'kvm' listed when you run 'groups'

Flags: needinfo?(gbrown)

I think the x86 emulator on linux (maybe osx also) requires kvm, but:

  • I'm not 100% sure
  • earlier versions of the x86 emulator did not require kvm
  • who knows what newer versions of the emulator will implement?

The check-and-warn code is at:

https://searchfox.org/mozilla-central/rev/99a2a5a955960b0e58ceade1db1f7652d9db4ba1/testing/mozbase/mozrunner/mozrunner/devices/android_device.py#930

Notice that it is a pretty gross approximation, which could certainly fail if google changes the emulator implementation or message wording. If that were to happen, I'd prefer to warn and successfully continue vs break 'mach android-emulator' without need.

More info on emulator + kvm at:

https://developer.android.com/studio/run/emulator-acceleration

Flags: needinfo?(gbrown)

It sounds like the issue here was kvm permissions and the issue was resolved. I think the existing check and warning is the best we can do.

Assignee: nobody → gbrown
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WORKSFORME
Whiteboard: dev-prod-2020
You need to log in before you can comment on or make changes to this bug.