I'm trying to start a VM (The Java webservice API version 5.1. using the IMachine::launchVMProcess method. but the IProgress::waitForCompletion method fails on the following error:
ERROR aap.vm.management.VMManagerTest.testStartVM(VMManagerTest.java:123) - VirtualBox error: rc=0x80004004
org.virtualbox_5_1.VBoxException: VirtualBox error: rc=0x80004004
at org.virtualbox_5_1.IProgress.waitForCompletion(IProgress.java:531) ~[vboxjws-5.1.8.jar:?]
Looking at the log file, I see the following errors:
VMSetError: /home/vbox/vbox-5.1.8/src/VBox/VMM/VMMR3/VM.cpp(363) int VMR3Create(uint32_t, PCVMM2USERMETHODS, PFNVMATERROR, void*, PFNCFGMCONSTRUCTOR, void*, VM**, UVM**); rc=VERR_MAIN_CONFIG_CONSTRUCTOR_COM_ERROR
00:00:01.372078 VMSetError: The configuration constructor in main failed due to a COM error. Check the release log of the VM for further details.
Which is some error in the COM API.
Note that the same machine can be started successfully from the VBox GUI.
In addition, the same code worked before and I can't understand if this is something related to environment or not...
In the zip file the VBox-fail.log is for the API try, and the VBox.log file is for the GUI try.
Both Host & Guest are Ubuntu 16.04.
Following is the relevant code:
Code: Select all
// Make a connection
VirtualBoxManager vboxMgr = connect();
try {
// Get the VM reference
IVirtualBox vbox = vboxMgr.getVBox();
IMachine vm = vbox.findMachine(vmDetails.getName());
MachineState state = vm.getState();
if ( state == MachineState.Running ) {
_logger.debug("VM {} is already running. Ignoring request to start it", vmDetails.getName());
} else {
ISession session = vboxMgr.getSessionObject();
IProgress progress = vm.launchVMProcess(session, "gui", "");
boolean success;
try {
success = progressBar(vboxMgr, progress, TIMEOUT_MILLIS);
} finally {
unlock(session);
}
if ( !success ) {
_logger.error("Unable to start the VM {}", vmDetails.getName());
throw new AAPException("Unable to start the VM " + vmDetails.getName());
}
}
} finally {
// Disconnect
disconnect(vboxMgr);
}
private boolean progressBar(VirtualBoxManager mgr, IProgress p, long waitMillis)
{
// Calculate when to end
long end = System.currentTimeMillis() + waitMillis;
while (!p.getCompleted())
{
consumeSystemEvents(mgr);
// Wait for completion of the task, but at most 200 msecs
p.waitForCompletion(200);
if (System.currentTimeMillis() >= end)
return false;
}
return true;
}
Jonathan