Running x86 Android emulators requires kvm-intel - digital-ocean

I use Gitlab CI to build an Android app and automatically run tests on an Android Virtual Device (AVD).
I would like to use the x86 version of this emulator instead of the ARM one.
But an x86 AVD currently requires virtualization (VT) and KVM properly installed and loaded.
All this runs in a Docker container on a DigitalOcean host.
'lscpu' shows VT is enabled for an Intel processor :
Model name: Intel(R) Xeon(R) CPU E5-2650L v3 # 1.80GHz
Virtualization: VT-x
Hypervisor vendor: KVM
Virtualization type: full
I therefore installed qemu-kvm and other related debian packages :
export DEBIAN_FRONTEND=noninteractive
apt-get --quiet update --yes
apt-get --quiet install --yes qemu-kvm libvirt-bin virtinst bridge-utils
adduser 'id -un' libvirt
Then 'virt-host-validate' shows kvm-intel is not loaded :
$ virt-host-validate
QEMU: Checking for hardware virtualization : PASS
QEMU: Checking for device /dev/kvm : FAIL (Check that the 'kvm-intel' or 'kvm-amd' modules are loaded & the BIOS has enabled virtualization)
QEMU: Checking for device /dev/vhost-net : PASS
QEMU: Checking for device /dev/net/tun : PASS
LXC: Checking for Linux >= 2.6.26 : PASS
ERROR: Job failed: exit code 1
But, adding 'modprobe kvm-intel' fails :
$ modprobe kvm-intel
modprobe: ERROR: ../libkmod/libkmod.c:557 kmodsearchmoddep() could not open moddep file '/lib/modules/4.9.16-coreos-r1/modules.dep.bin'
And neither :
$ depmod
depmod: ERROR: could not open directory /lib/modules/4.9.16-coreos-r1: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
ERROR: Job failed: exit code 1
Nor :
$ apt-get install --reinstall linux-image-'uname -r'
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package linux-image-4.9.16-coreos-r1
E: Couldn't find any package by regex 'linux-image-4.9.16-coreos-r1'
...does solve the problem. Any idea on how I can get kvm-intel loaded ?
Kind regards,
Laurent Le Moux

Finally I got an answer here :
https://groups.google.com/d/topic/coreos-user/mvmOhDMiwsU/discussion
Basically, the virtualization packages must be installed from outside the Docker instance.
And - unfortenately - I have no control / access on it as it is automatically started by Gitlab CI runner.
I may (kindly) ask for these packages to be installed by default :
https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/2242

Related

RuntimeError:This command is using a remote connection in offline mode.[CondaError]

when I've created environment into conda, I got this error just after Proceed response:
[root#MyServer]#conda create -n py26 python=2.6 anaconda --offline
Fetching package metadata .........
Solving package specifications: ..............
......................
....
...
Proceed ([y]/n)? y
CondaError: RuntimeError(u'EnforceUnusedAdapter called with url https://repo.continuum.io/pkgs/free/linux-64/jpeg-8d-0.tar.bz2\nThis command is using a remote connection in offline mode.\n',)
CondaError: RuntimeError(u'EnforceUnusedAdapter called with url https://repo.continuum.io/pkgs/free/linux-64/jpeg-8d-0.tar.bz2\nThis command is using a remote connection in offline mode.\n',)
CondaError: RuntimeError(u'EnforceUnusedAdapter called with url https://repo.continuum.io/pkgs/free/linux-64/jpeg-8d-0.tar.bz2\nThis command is using a remote connection in offline mode.\n',)
even that I can see that my env has created successfuly:
[root#MyServer]# conda env list
# conda environments:
#
py26 /opt/Anaconda/Anaconda2-4.4.0/envs/py26
py27 /opt/Anaconda/Anaconda2-4.4.0/envs/py27
root * /opt/Anaconda/Anaconda2-4.4.0
is that Error influence environement I have created?
After few hours of search I found out that this issue cames from a bug on the Conda version 4.3.x: Github
to fix this issue, you will have to install the Conda 4.4.x
also, you have to check out the UPDATE on this version to enable conda in your shel:

How can I get cadvisor (Docker) working with AWS/Debian?

I have an AWS instance set up (Debian) onto which I've installed Docker.
I can successfully run the hello-world container, as well as running ubuntu as recommended in the Docker install validation.
I want to run cadvisor. So I ran the recommended quick-start script:
sudo docker run \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:rw \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--publish=8080:8080 \
--detach=true \
--name=cadvisor \
google/cadvisor:latest
That gave me no error but when I do a 'sudo docker ps' nothing's there; like it fired up and died or otherwise shut itself down.
I tried adding "--logtostderr" to the end to see what I could see--and saw:
I0108 19:19:55.308016 00001 storagedriver.go:89] Caching 60 recent stats in memory; using "" storage driver
I0108 19:19:55.308353 00001 manager.go:78] cAdvisor running in container: "/docker/e3b5ede6f6def6b36d7682814aefc2b414defaea065ccf977a1a2542a80c310c"
F0108 19:19:55.337891 00001 cadvisor.go:76] Failed to create a Container Manager: failed to get cache information for node 0: open /sys/devices/system/cpu/cpu1/cache: no such file or directory
Do I need to do something different for a Debian system?
If you notice the docker command and the error we are explicitly mounting in the sys directory from the host system. --volume=/sys:/sys:ro and the error is complaining about file in a sub-directory /sys/devices/system/cpu/cpu1/cache. So if that file/folder does not exist in your host vm it won't work inside docker.
I have tested both ubuntu and amazon standard AMI and they seem to have the file mentioned. I don't see debian in the standard AMIs so I have no easy way to test debian but I suspect the image you are using has the required kernel modules or settings missing. Why not use one of the standard Amazon AMIs?
There was a bug we fixed in cAdvisor. The latest version of cAdvisor should work just fine with Debian on AWS or anywhere.

Docker automated build results in Unexpected failure

I am trying to create an automated build with docker. What I have done is linked my bit-bucket repo in the docker hub and trying to build. The status of build is unexpected failure. Also, I see the below failure message:
{"error": "Image depends on an unauthorized parent"}
And interestingly, the logs says build successful.
Failure message
[Failure instance: Traceback: <type 'exceptions.RuntimeError'>: HTTP code 400 while uploading metadata: {"error": "Image depends on an unauthorized parent"}
/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py:382:callback
/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py:490:_startRunCallbacks
/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py:577:_runCallbacks
/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py:1155:gotResult
--- <exception caught here> ---
/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py:1097:_inlineCallbacks
/usr/local/lib/python2.7/dist- packages/twisted/python/failure.py:389:throwExceptionIntoGenerator
/app/builder.py:160:execute_job
/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py:577:_runCallbacks
/app/shared/tx/docker.py:295:on_done
]
Dockerfile
FROM ubuntu
# make sure the package repository is up to date
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
# Install vnc, xvfb in order to create a 'fake' display and firefox
RUN apt-get install -y x11vnc xvfb firefox
RUN mkdir /.vnc
# Setup a password
RUN x11vnc -storepasswd 1234 ~/.vnc/passwd
# Autostart firefox (might not be the best way, but it does the trick)
RUN bash -c 'echo "firefox" >> /.bashrc'
EXPOSE 5900
CMD ["x11vnc", "-forever", "-usepw", "-create"]
Logs
Step 0 : FROM ubuntu
Pulling image (quantal) from ubuntu, endpoint: https://cdn-registry-1.docker.io/v1/ e314931015bd
....
....
Removing intermediate container c8e48d27a271
Step 8 : CMD ["x11vnc", "-forever", "-usepw", "-create"]
---> Running in d9319762cb0f
---> bd7eb37a7f78
Removing intermediate container d9319762cb0f
Successfully built bd7eb37a7f78
Update: The issue was fixed.
I just got an answer from the Docker support team. It's an issue on their side, which they are already investigating.
Unfortunately there isn't much you can do besides waiting.

macOS - vagrant up failed, /dev/vboxnetctl: no such file or directory

Can be useful, I found this error. The common solution is reinstall virtualbox but there are a better way.
Solution
sudo /Library/StartupItems/VirtualBox/VirtualBox restart
or
sudo /Library/StartupItems/VirtualBox/VirtualBox start
VirtualBox 4.3+
On recents versions, the file (/Library/StartupItems/VirtualBox/VirtualBox) don't exists, so you need to use the command below:
sudo launchctl load /Library/LaunchDaemons/org.virtualbox.startup.plist
Error
Print: http://d.pr/i/1Bvi
There was on error while executing VBoxManage, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below
Command: ["hostonlyif", "create"]
Stderr: 0%... Progress state: NS_ERROR_FAILURE VBoxManage: error:
Failed to create the host-only adapter VBoxManage: error:
VBoxNetAdpCtl: Error while adding new interface: failed to open
/dev/vboxnetctl: No such file or directory
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005),
component HostNetworkInterface, interface IHostNetworkInterface
VBoxManage: error: Context: "int handleCreate(HandlerArg*, int, int*)"
at line 68 of file VBoxManageHostonly.cpp
Vagrant Git issue about the error: https://github.com/mitchellh/vagrant/issues/1671#issuecomment-22304107
I'm running macOS High Sierra 10.13.1 and VirtualBox 5.2.2.
This worked for me:
Grant permission to VirtualBox under System Preferences > Security & Privacy > General (this request is new to macOS High Sierra)
Open Terminal and run: sudo "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart
If your system recently updated the kernel, you many need to rerun the vbox setup again.
If this is the case, you will see the following messages when you run virtualbox start command:
$ sudo /path/to/virtualbox start
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
available for the current kernel (2.6.32-358.23.2.el6.x86_64) or it failed to
load. Please recompile the kernel module and install it by
sudo /etc/init.d/vboxdrv setup
You will not be able to start VMs until this problem is fixed.
This worked for me (macOS Monterey). This reloads all VirtualBox's kernel extensions.
sudo kmutil load -b org.virtualbox.kext.VBoxUSB
sudo kmutil load -b org.virtualbox.kext.VBoxNetFlt
sudo kmutil load -b org.virtualbox.kext.VBoxNetAdp
sudo kmutil load -b org.virtualbox.kext.VBoxDrv
I had some problems with vbox running on Ubuntu 17.10 when starting a virtual machine with host-only adapted/bridge network. Looking for an answer I found numerous commands that are useful when having that kind of problems. Here they are:
VIRTUAL HOST PROBLEMS
failed to open /dev/vboxnetctl
vboxnet0 - this is the bad guy who is causing all the trouble.
VBoxNetAdpCtl: Error while adding new interface: failed to open
/dev/vboxnetctl: No such file or directory.
These commands are not used in particular order. They are just generally useful and problem-solving.
1) sudo modprobe vboxdrv
2) sudo modprobe vboxnetadp - (host only interface)
3) sudo modprobe vboxnetflt - (make vboxnet0 accecible)
IF YOU HAVE PROBLEMS WITH SECURE BOOT RUNNING the FIRST COMMAND I RECOMMEND DISABLING SECURE BOOT IN BIOS (or reboot).
modprobe: FATAL: Module vboxnetftl not found in directory
/lib/modules/4.13.0-21-generic
(bridge networking)
4) sudo apt-get install virtualbox-dkms (extension) -> go to command 1 after this
5) sudo vboxmanage hostonlyif create
These sometimes might work:
I. service --status-all
II service service_name restart
Tried above all remedies, few commands although executed, did not work.
Nothing is present in my Mac (el captain) of sort /Library/StartupItems/Vir*, and below command failed:
sudo /Library/StartupItems/VirtualBox/VirtualBox restart
Reinstalling latest VirtualBox and then running below command helped me having VM running
sudo launchctl load /Library/LaunchDaemons/org.virtualbox.startup.plist
I had a similar problem starting a virtual box on High Sierra.
macOS High Sierra 10.13 introduces a new feature that requires user approval before loading newly-installed third-party kernel extensions (KEXTs). When a request is made to load a KEXT that the user has not yet approved, the load request is denied. Apps or installers that treat a KEXT load failure as a hard error will need to be changed to handle this new case.
To resolve, you must manually approve the KEXT in System Preferences > Security & Privacy.
Here is the Technical Note from Apple:
https://developer.apple.com/library/content/technotes/tn2459/_index.html
I was stuck on this for a while. I kept seeing 'command not found' when trying to run the sudo: /Library.. command.
However, this did work for me:
sudo /Library/Application\ Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh restart
RUN
$ sudo modprobe vboxdrv
$ sudo modprobe vboxnetadp
$ sudo vboxreload
Thank forks, it worked for me.
Grant permission to VirtualBox under System Preferences > Security & Privacy > General
Throw away /Applications/VirtualBox into the trash
Re-install VirtualBox from your .dmg file
When I get the error...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["hostonlyif", "create"]
Stderr: 0%...
Progress state: NS_ERROR_FAILURE
VBoxManage: error: Failed to create the host-only adapter
VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterface, interface IHostNetworkInterface
VBoxManage: error: Context: "int handleCreate(HandlerArg*, int, int*)" at line 68 of file VBoxManageHostonly.cpp
The following works for me and returns no errors, I am then able to bring vagrant up successfully
sudo /Library/StartupItems/VirtualBox/VirtualBox restart

Why could VirtualBox not find a registered machine named Windows_7?

I'm trying to change TCP/UDP of a virtual machine using VBoxManage setextradata.
Whenever I type the command:
sudo VBoxManage setextradata Windows_7 "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestEmule_TCP/Protocol" TCP
I get the following error:
VirtualBox Command Line Management Interface Version 2.1.4
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
[!] FAILED calling a->virtualBox->FindMachine(Bstr(a->argv[0]), machine.asOutParam()) at line 3688!
[!] Primary RC = VBOX_E_OBJECT_NOT_FOUND (0x80BB0001) - Object corresponding to the supplied arguments does not exist
[!] Full error info present: true , basic error info present: true
[!] Result Code = VBOX_E_OBJECT_NOT_FOUND (0x80BB0001) - Object corresponding to the supplied arguments does not exist
[!] Text = Could not find a registered machine named 'Windows_7'
[!] Component = VirtualBox, Interface: IVirtualBox, {339abca2-f47a-4302-87f5-7bc324e6bbde}
[!] Callee = IVirtualBox, {339abca2-f47a-4302-87f5-7bc324e6bbde}
The virtual-machine has been created using GUI. Any idea?
$ cd /Users/marco/Library/VirtualBox/Machines/Windows_7
$ ls
Logs Windows_7.xml
Windows 7.xml.1.5-macosx.bak
$ sudo vboxmanage registervm Windows_7.xml
VirtualBox Command Line Management Interface Version 2.1.4
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
[!] FAILED calling a->virtualBox->OpenMachine(Bstr(a->argv[0]), machine.asOutParam()) at line 762!
[!] Primary RC = NS_ERROR_FAILURE (0x80004005) - Operation failed
[!] Full error info present: true , basic error info present: true
[!] Result Code = NS_ERROR_FAILURE (0x80004005) - Operation failed
[!] Text = Could not lock the settings file '/var/root/Library/VirtualBox/Windows_7.xml' (VERR_FILE_NOT_FOUND)
[!] Component = Machine, Interface: IMachine, {ea6fb7ea-1993-4642-b113-f29eb39e0df0}
[!] Callee = IVirtualBox, {339abca2-f47a-4302-87f5-7bc324e6bbde}
It fails because you are using sudo. VirtualBox is designed to be run by any user (in the vboxusers group), and sudo runs the command as the root user whose VirtualBox configuration is empty.
You can check that by typing:
sudo VBoxManage -nologo list vms # Should print only a newline
VBoxManage -nologo list vms # Detailled information about all your VMs
!! WINDOWS ONLY!!
If you are not on an admin account and are trying to modify your VM in a administrator cmd window, type these commands:
cd "C:\Program Files\Oracle\VirtualBox"
VboxManage registervm "C:\Users\Your Name Here\VirtualBox VMs\Your VM name here\Your VM name here.vbox"
Now run your virtual box modify commands or what ever else you are doing and it should work!
Not a direct answer, but just to put it out there for other people searching for it:
On Mac OS X, you can tell VirtualBox to load VMs from another user's home directory, provided the file permissions allow it, or if you are running VirtualBox as the root user using sudo (e.g. if you absolutely have to access your host's web server on port 80).
The way to do this is to set VBOX_USER_HOME appropriately, e.g.
VBOX_USER_HOME=/Users/the_other_user/Library/VirtualBox
If you want to run VBoxHeadless under root, use:
sudo VBOX_USER_HOME=/Users/your_user_id/Library/VirtualBox nohup \
VBoxHeadless -s "IE10 - Win7" </dev/null &>/dev/null &
I had a similar error message, whenever I used sudo to start VBoxSDL:
Error: machine with the given name not found!
Check if this VM has been corrupted and is now inaccessible.
And similar to ypocat's answer, I solved it for Ubuntu using a small script like this:
#!/bin/bash
export VBOX_USER_HOME=/home/username/.config/VirtualBox
VBoxSDL --startvm nameOfVM
You can use it whenever you need to start your VM as root.
SOLUTION_1:
Missing Virtual Technology might be the reason. For Intel systems they have Intel VT-x (for AMD they have AMD-V), so make sure it is enabled. You can enable it in the boot screen go to BIOS Setup in that look for System Configuration tab and enable Virtual Technology
.
SOLUTION_2:
Open terminal or cmd (Run as admin) for Windows, and run SC START VBOXDRV. If it says the service is already running then try SC STOP VBOXDRV and then SC START VBOXDRV.
RealScar solution helped me in addition to other commands and it worked in Ubuntu 20.04, too.
I had the problem initially indicated (VirtualBox unable to find a registered machine). I was getting no results after typing sudo VBoxManage -nologo list vms, so I manually registered the existing machine typing sudo vboxmanage registervm /home/user/VirtualBox\ VMs/machinenamefolder/machinename.vbox. It worked great.
Note: I was creating a Cuckoo Malware Sandbox Analysis.
REASON: In the above case its uuid-mismatch (w.r.t. what is pointed to what is generated). Typically case of either improper edit of the vbox config files or accidentally deleted images/configs associated.
SOLUTION:
As FIRST Step: Correct the UUID-Mappings;
So, for example, the uuids can be regenerated to correct the mappings. (1)
Or otherwise, if attempted to edit .vbox/.vmdk/VirtualBox.xml files, the mappings should be corrected. (2)
As SECOND Step: Re-register the virtual-machine to the UI.
For example, if can't open the vm's from vbox gui or terminal. Remove the "inaccessible" entry from the GUI first". And then, open the folder of virtual machine and open file <machine name>.vbox with virtualbox and it will get registered. Provided, the uuid-mappings have been already resolved. Else follow the errors, while you attempt to register to make necessary changes in .vbox file.