COM ERROR while starting a VM

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
JJon
Posts: 18
Joined: 3. Nov 2016, 11:54

COM ERROR while starting a VM

Post by JJon »

Hi,

I'm trying to start a VM (The Java webservice API version 5.1.8) 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;
    }

Appreciate any help.

Jonathan
Attachments
com_error.zip
(18.11 KiB) Downloaded 235 times
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: COM ERROR while starting a VM

Post by noteirak »

Is this piece of code running under the same user context (same session, same privileges) than the VirtualBox GUI?
If yes, can you try to start the VM from the code in headless mode instead of gui, see what happens?
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
JJon
Posts: 18
Joined: 3. Nov 2016, 11:54

Re: COM ERROR while starting a VM

Post by JJon »

I'm trying to understand what it means the same context. The code runs on a different machine (than the VBox GUI), which authenticates to the webservice on the VBox machine.
The VBox GUI isn't running as root, but a regular user. The same user is used to do the authentication to the webservice.

Why did I start getting this access denied from the COM?

Thanks
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: COM ERROR while starting a VM

Post by noteirak »

By same context I mean: In the same user session on the same machine, using sudo if you did with the GUI, not if no.
Not being a dev, I can't answer you why this is happening. Only trying to make sure it can't be reproduce in the same user context as for the GUI.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
JJon
Posts: 18
Joined: 3. Nov 2016, 11:54

Re: COM ERROR while starting a VM

Post by JJon »

I found the problem. The error was not indicative.
The issue was that I had port forwarding rules defined and several machines used the same IP address (because of NAT) from the rules.

Thanks for trying to help
Post Reply