VirtualBox

Opened 8 years ago

Closed 8 years ago

#15335 closed defect (invalid)

Empty environment createvm --register fails to finish correctly

Reported by: payo Owned by:
Component: other Version: VirtualBox 5.0.18
Keywords: VBoxManage Cc:
Guest type: Linux Host type: Linux

Description

Oddly, if you run these repros steps fast enough (i.e. <5 seconds) it does not repro

# repro steps mv ~/.VirtualBox ~/V.bk #for testing a clean env mv ~/.config/VirtualBox ~/Vconfig.bk #for testing a clean env VBoxManage createvm --name test --register # exit 0 sleep 10 VBoxManage modifyvm test --memory 8192 # fails, test not found ls -la ~/.VirtualBox # no VirtualBox.xml ls -la ~/.config/VirtualBox # has VirtualBox.xml, even shows where VBoxManage createvm --name test --register # fails, test already exists VBoxManage modifyvm test --memory 8192 # still fails, test not found # test is located, but doesn't seem to use this information

# scenario 2, strange work around mv ~/.VirtualBox ~/V2.bk #for testing a clean env mv ~/.config/VirtualBox ~/Vconfig2.bk #for testing a clean env VBoxManage createvm --name test # don't register sleep 10 # to ensure we are hitting the bug VBoxManage registervm Machines/test/test.vbox # notice the path i used VBoxManage modifyvm test --memory 8192 # works

# scenario 3, better workaround mv ~/.VirtualBox ~/V3.bk #for testing a clean env mv ~/.config/VirtualBox ~/Vconfig3.bk #for testing a clean env mkdir -p ~/.config/VirtualBox mkdir ~/.VirtualBox # just have the dirs appears to be good enough VBoxManage createvm --name test --register sleep 10 # again, just for testing the race bug VBoxManage modifyvm test --memory 8192 # works

Change History (4)

comment:1 by payo, 8 years ago

So sorry, the description messed up my repro step newlines.

# repro steps
mv ~/.VirtualBox ~/V.bk #for testing a clean env
mv ~/.config/VirtualBox ~/Vconfig.bk #for testing a clean env
VBoxManage createvm --name test --register # exit 0
sleep 10
VBoxManage modifyvm test --memory 8192 # fails, test not found
ls -la ~/.VirtualBox # no VirtualBox.xml
ls -la ~/.config/VirtualBox # has VirtualBox.xml, even shows where VBoxManage createvm --name test --register # fails, test already exists
VBoxManage modifyvm test --memory 8192 # still fails, test not found
# test is located, but doesn't seem to use this information

# scenario 2, strange work around
mv ~/.VirtualBox ~/V2.bk #for testing a clean env
mv ~/.config/VirtualBox ~/Vconfig2.bk #for testing a clean env
VBoxManage createvm --name test # don't register
sleep 10 # to ensure we are hitting the bug
VBoxManage registervm Machines/test/test.vbox # notice the path i used
VBoxManage modifyvm test --memory 8192 # works

# scenario 3, better workaround
mv ~/.VirtualBox ~/V3.bk #for testing a clean env
mv ~/.config/VirtualBox ~/Vconfig3.bk #for testing a clean env
mkdir -p ~/.config/VirtualBox
mkdir ~/.VirtualBox
# just have the dirs appears to be  good enough
VBoxManage createvm --name test --register
sleep 10 # again, just for testing the race bug
VBoxManage modifyvm test --memory 8192 # works

comment:2 by Frank Mehnert, 8 years ago

Which version of VirtualBox did you use for testing?

You should NOT rename the ~/.VirtualBox and ~/.config/VirtualBox directories while VBoxSVC is running. If there are no special environment variables set then VirtualBox will first look in ~/.VirtualBox and (if that directory does not exist) it will look for ~/.config/VirtualBox and (if that directory does not exist either) it will create ~/.config/VirtualBox.

From the above instructions it is not clear if VBoxSVC was running or not when you renamed the directories. Also in your tests you didn't consider the default machine folder which defaults to $HOME/VirtualBox VMs. If you create a VM and a directory with the VM name already exists then the regstration will fail as well (VBoxManage will display an error). To have a clean environment, better do the following:

#!/bin/sh
while pidof VBoxSVC > /dev/null; do
    echo "waiting for VBoxSVC to terminate"
    sleep 1
done
export VBOX_USER_HOME=$HOME/foobar
if [ -d $VBOX_USER_HOME ]; then
    echo "Directory $VBOX_USER_HOME already exists!"
    exit 1
fi
VBoxManage setproperty machinefolder $VBOX_USER_HOME/Machines
VBoxManage createvm --name test --register
VBoxManage modifyvm test --memory 8192
...

comment:3 by payo, 8 years ago

vbox version (as listed in the ticket) 5.0.18 Stopping the service appears to fix this completely. Thanks Frank.

comment:4 by Klaus Espenlaub, 8 years ago

Resolution: invalid
Status: newclosed

If you move the directories out of the way while VBoxSVC is running it can happen that the directories/files aren't correctly recreated. The consequence is that global settings (like VM registrations) are lost when VBoxSVC auto-terminates. This happens after 5 seconds without any API client.

Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use