Virtualbox is locked when I try to destroy a kitchen instance - virtualbox

I ran a test-kitchen instance and all was fine, but at the end when I did try to destroy it kitchen with:
roberto#pc:~$ kitchen destroy
Virtualbox gave me this error.
-----> Starting Kitchen (v1.1.1)
-----> Destroying <default-ubuntu-1204>...
[default] Destroying VM and associated drives...
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #destroy action: [Expected process to exit with [0], but received '1'
---- Begin output of vagrant destroy -f ----
STDOUT: [default] Destroying VM and associated drives...
STDERR: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["unregistervm", "2507bc77-3734-429b-a573-d92fadb80e95", "--delete"]
Stderr: VBoxManage: error: Cannot unregister the machine 'default-ubuntu-1204_default_1391521776' while it is locked
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component Machine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "Unregister(CleanupMode_DetachAllReturnHardDisksOnly, ComSafeArrayAsOutParam(aMedia))" at line 158 of file VBoxManageMisc.cpp
---- End output of vagrant destroy -f ----
Ran vagrant destroy -f returned 1]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
I ran Virtualbox and I can not removed the instance because it also was locked and the close option was disable.
Anyone else with this problem?

VBoxManage: error: Cannot unregister the machine 'X' while it is locked.
It's locked, because it's in use, so basically you need to shut it down, e.g.
VBoxManage controlvm VMNAME poweroff
Change VMNAME to your machine name, e.g. default-ubuntu-1204_default_1391521776.
Then you can unregister via:
VBoxManage unregistervm VMNAME --delete
Specifying --delete will delete your VM. If you don't want to delete it, you can make a backup from ~/"VirtualBox VMs/VMNAME.

There are two things that can cause this issue. Please ensure:
You restart your computer after installing/updating VirtualBox
Please make sure you manually open VirtualBox at least once before using the driver
If the machine appears in the list of Virtual Machines in the VBox GUI, try the command again. If they are not listed in the VirtualBox GUI, remove the .kitchen directory and try again.

Related

Error on connecting pod on AWS machine from JProfiler 13.02

I try connect to my pod on AWS machine from JProfiler 13.02.
Quick Attach -> On a Kubernetes Cluster-> Kubectl on another computer->give SSH connection details and press start
I get a list of all pods, select container of one of them and click OK. I get an error:
An exception occurred while connecting to the selected container.
The error message was: java.io.IOException: Could not copy agent to docker container tar: .jprofiler13/agent/13094_13.0.2: Cannot open: No such file or directory tar: Error is not recoverable: exiting now tar: short read command terminated with exit code 1 exit code: 1

aws ec2 ssh fails after creating an image of the instance

I regularly create an image of a running instance without stopping it first. That has worked for years without any issues. Tonight, I created another image of the instance (without any changes to the virtual server settings except for a "sudo yum update -y") and noticed my ssh session was closed. It looked like it was rebooted after the image was created. Then the web console showed 1/2 status checks passed. I rebooted it a few times and the status remained the same. The log showed:
Setting hostname localhost.localdomain: [ OK ]
Setting up Logical Volume Management: [ 3.756261] random: lvm: uninitialized urandom read (4 bytes read)
WARNING: Failed to connect to lvmetad. Falling back to device scanning.
[ OK ]
Checking filesystems
Checking all file systems.
[/sbin/fsck.ext4 (1) -- /] fsck.ext4 -a /dev/xvda1
/: clean, 437670/1048576 files, 3117833/4193787 blocks
[/sbin/fsck.xfs (1) -- /mnt/pgsql-data] fsck.xfs -a /dev/xvdf
[/sbin/fsck.ext2 (2) -- /mnt/couchbase] fsck.ext2 -a /dev/xvdg
/sbin/fsck.xfs: XFS file system.
fsck.ext2: Bad magic number in super-block while trying to open /dev/xvdg
/dev/xvdg:
The superblock could not be read or does not describe a valid ext2/ext3/ext4
[ 3.811304] random: crng init done
filesystem. If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
or
e2fsck -b 32768 <device>
[FAILED]
*** An error occurred during the file system check.
*** Dropping you to a shell; the system will reboot
*** when you leave the shell.
/dev/fd/9: line 2: plymouth: command not found
Give root password for maintenance
(or type Control-D to continue):
It looked like /dev/xvdg failed the disk check. I detached the volume from the instance and reboot. I still couldn't ssh in. I re-attached it and rebooted. Now it says status check 2/2 passed but I still can't ssh back in and the log still showed issues with /dev/xvdg as above.
Any help would be appreciated. Thank you!
Thomas

Can't attach gdbserver to process through kubectl

It looks like I have some sort of permissions problem with kubectl. I have a Docker image, that contains server with native dynamic library + gdbserver. When I'm trying to debug Docker container running on my local machine all is fine. I'm using the following workflow:
start gdb
target remote | docker exec -i CONTAINER gdbserver - --attach PID
set sysroot /path/to/local/binary
Good to go!
But when I'm trying to do such operation with kubectl I'm getting the following error:
Cannot attach to lwp 7: Operation not permitted (1)
Exiting
Remote connection closed
The only difference is step 2:
target remote | kubectl exec -i POD -- gdbserver - --attach PID
I think you might need to add ptrace() capabilities and seccomm profile in your yaml file.
--cap-add sys_ptrace

VM in virtualbox is already locked for a session (or being unlocked)

My VM in virtualbox can not start due to this error, I don't want to destroy it and reinstall it again, anyway to recover it ?
There was an error while executing VBoxManage, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["modifyvm", "319fcce3-e8ff-4b6f-a641-3aee1df6543f", "--natpf1", "delete", "ssh"]
Stderr: VBoxManage: error: The machine 'centos64_c6402_1454036461345_59755' is already locked for a session (or being unlocked)
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee nsISupports
VBoxManage: error: Context: "LockMachine(a->session, LockType_Write)" at line 493 of file VBoxManageModifyVM.cpp
Running this on the command line unlocked the VM:
vboxmanage startvm <vm-uuid> --type emergencystop
Where <vm-uuid> is the number in the error message: Command: ["modifyvm", "<vm-uuid>" [...]. After that I was able to control the VM (start, halt, etc).
Using Virtualbox 4.1 on Ubuntu.
Having the same issue I found that there was a process running actually locking the vm:
501 79419 79323 0 2:18PM ?? 0:39.75 /Applications/VirtualBox.app/Contents/MacOS/VBoxHeadless --comment default --startvm 1d438a2e-68d7-4ba2-bef9-4ea162913c1b --vrde config
Make sure you don't have a process stuck trying to start the vm:
ps -ef | grep -i "vbox"
I found this answer from #Gonzalez very interesting.
vboxmanage startvm <vm-uuid> --type emergencystop
The only problem with that it shut down the current instance of my VM, so instead of using modifyvm you can use controlvm if the current vm is running.
For example:
VBoxManage modifyvm <vm_name> --natpf1 "guestssh,tcp,,22,,2222"
VBoxManage modifyvm <vm_name> --natpf1 delete "guestssh"
Become:
VBoxManage controlvm <vm_name> natpf1 "guestssh,tcp,,22,,2222"
VBoxManage controlvm <vm_name> natpf1 delete "guestssh"
Full documentation Here
https://www.virtualbox.org/manual/ch08.html#vboxmanage-controlvm
For me I had to kill the VboxHeadless.exe process in task manager. I also had to ensure CMD prompt was opened in Administrative mode.
sudo pkill -9 VBox kills everything running related to vbox
In Windows Task Manager, I ended any tasks related to Virtual Box (you can see they start with a V in Task Manager like Vbox Headless.exe, etc). Once I did that, I was able to get this error to go away (the above 'vboxmanage startvm ...etc...' solutions here did not work for me).
If you have a settings window open for that box in the VirtualBox GUI, you may run into this error. Just close the settings window and try again.
I've encounter the same error message today:
>me#myhost:~$ ps -ef | grep -i "vbox"
me 3064 1 0 08:51 ? 00:00:00 /usr/lib/virtualbox/VBoxXPCOMIPCD
me 3089 1 0 08:51 ? 00:00:00 /usr/lib/virtualbox/VBoxSVC --auto-shutdown
me 3126 3089 27 08:51 ? 00:00:39 /usr/lib/virtualbox/VBoxHeadless --comment RHEL5 64-bit desktop --startvm e5c598d8-1234-4003-a7c1-b9d8af15dfe7 --vrde config
me 3861 3415 0 08:53 pts/1 00:00:00 grep --color=auto -i vbox*
Gergely's answer solves it perfectly. It turned out that I've a crontab set at reboot to boot the virtual machine, which initiated the three VBox process shown above
me#myhost:~$ crontab -l
#reboot me /usr/bin/vboxmanage startvm "RHEL5 64-bit desktop" --type headless
The only option that worked for me was to kill all the processes matching ps axl|grep -i vbox.
In my case, the apparent cause was a USB ethernet adapter that had been removed after suspending the machine. In my case,
vboxmanage startvm <vm-uuid> --type emergencystop
did not help. Instead, I received the confusing message that
VBoxManage: error: The machine 'xyzzy' is not locked by a session
The true error was revealed by running
vboxmanage startvm <vm-uuid> --type gui
which returned
VBoxManage: error: Nonexistent host networking interface, name 'en9: USBPlug' (VERR_INTERNAL_ERROR)
Changing the network configuration to a different network adapter solved the issue.
This is because You reallocated the memory set for Virtual Box
What you have to do to fix is: Restart The PC

"vagrant up" failing: Vagrant VM failed to remain in the running state

The command vagrant up is failing and I don't know why.
$ egrep -v '^ *(#|$)' Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise32"
end
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise32'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
The VM failed to remain in the "running" state while attempting to boot.
This is normally caused by a misconfiguration or host system incompatibilities.
Please open the VirtualBox GUI and attempt to boot the virtual machine
manually to get a more informative error message.
$ vagrant status
Current machine states:
default poweroff (virtualbox)
The VM is powered off. To restart the VM, simply run `vagrant up`
$ VBoxManage list runningvms
$
Here are the messages in the VirtualBox log file, VBoxSVC.log:
$ cat ~/.VirtualBox/VBoxSVC.log
VirtualBox XPCOM Server 4.2.16 r86992 linux.amd64 (Jul 4 2013 16:29:59) release log
00:00:00.000499 main Log opened 2013-08-13T18:40:45.907580000Z
00:00:00.000508 main OS Product: Linux
00:00:00.000509 main OS Release: 3.6.11-4.fc16.x86_64
00:00:00.000510 main OS Version: #1 SMP Tue Jan 8 20:57:42 UTC 2013
00:00:00.000537 main DMI Product Name: X8DA3
00:00:00.000547 main DMI Product Version: 1234567890
00:00:00.000647 main Host RAM: 24103MB total, 17127MB available
00:00:00.000654 main Executable: /usr/local/VirtualBox/VBoxSVC
00:00:00.000655 main Process ID: 9417
00:00:00.000656 main Package type: LINUX_64BITS_GENERIC
00:00:00.110125 nspr-2 Loading settings file "/opt/tomcat/.VirtualBox/VirtualBox.xml" with version "1.12-linux"
00:00:00.110817 nspr-2 Failed to retrive disk info: getDiskName(/dev/md126p1) --> md126p1
00:00:00.264367 nspr-2 VDInit finished
00:00:00.275173 nspr-2 Loading settings file "/opt/tomcat/VirtualBox VMs/vagrant_getting_started_default_1376419129/vagrant_getting_started_default_1376419129.vbox" with version "1.12-linux"
00:00:05.288923 main ERROR [COM]: aRC=VBOX_E_OBJECT_IN_USE (0x80bb000c) aIID={29989373-b111-4654-8493-2e1176cba890} aComponent={Medium} aText={Medium '/opt/tomcat/VirtualBox VMs/vagrant_getting_started_default_1376419129/box-disk1.vmdk' cannot be closed because it is still attached to 1 virtual machines}, preserve=false
00:00:05.290229 Watcher ERROR [COM]: aRC=E_ACCESSDENIED (0x80070005) aIID={3b2f08eb-b810-4715-bee0-bb06b9880ad2} aComponent={VirtualBox} aText={The object is not ready}, preserve=false
$
Any advice would be greatly appreciated.
Had the same error on OSX. Restarting VirtualBox fixed it :S
sudo /Library/StartupItems/VirtualBox/VirtualBox restart
Also see: https://forums.virtualbox.org/viewtopic.php?t=5489
I solved the problem by re-installing VirtualBox and adding myself to the vboxusers group. The re-installation process printed a message indicating that VM users had to be a member of that group. I don't know if the re-installation was necessary or if being added to the group would have sufficed.
The host machine was 32bits (Ubuntu) and the guest was 64bit, I changed the guest to 32 and it solved the problem.
My understanding is that vboxusers group is related to accessing USB devices within the guest. Not sure why it is causing the issue. Normally, as a vagrant base box build guideline, audio and USB are both disabled.
As per the VirtualBox Manual => The vboxusers group
The Linux installers create the system user group vboxusers during installation. Any system user who is going to use USB devices from VirtualBox guests must be a member of that group. A user can be made a member of the group vboxusers through the GUI user/group management or at the command line with sudo usermod -a -G vboxusers username
Note that adding an active user to that group will require that user to log out and back in again. This should be done manually after successful installation of the package.
I had the same problem. It is because I did a wrong configuration on my Vagrantfile in the provider section. I had tried to make my VM machine more powerfull, with 2 cpus when i have on the machine host just one.
this often happens when you try to add more hardware to your VM machine but your host machine does not have the minimun requirements