Error Code(s) returned by VBOX functions

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
AdityaM
Posts: 31
Joined: 8. Nov 2016, 06:12

Error Code(s) returned by VBOX functions

Post by AdityaM »

Hello,
I am using Virtual Box SDK version 5.1.8. While trying to use the API for "IVirtualBox::openMachine(wstring settingsFile)", the function is returning the error code as 0x80004005, whose details are not mentioned in the SDK documentation and even in VirtualBox.h file. So is there any other comprehensive list for such error codes so that I can handle them in proper way.

Actually as mentioned in documentation/reference guide for this function, this function would return VBOX_E_FILE_ERROR (code as 0x80BB0004) if the settings file name invalid, not found or sharing violation. So to test and handle this scenario, I intentionally passed the incorrect path for settings file name and I was expecting VBOX_E_FILE_ERROR error but I got some different error code instead.

Please help me identify what could be wrong and any suggestions on how to better handle these situations would be very much appreciated.

Thanks and Regards
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: Error Code(s) returned by VBOX functions

Post by noteirak »

0x80004005 is a standard COM return code which is used for a general error (E_FAIL). In this case, it would most likely mean that there is a more "deep" error. You need to get the detailed error info and message to be able to troubleshoot further.
As for a guide on the COM return code, I personally do not know one. I'll contact one of the devs to see if an reference source can be given.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
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: Error Code(s) returned by VBOX functions

Post by noteirak »

Feedback from the devs is that you can find the list here for XPCOM but directly relate to Microsoft COM errors code, so the info in their official SDK/API doc would be accurate.
You can use the VBox runtime functions to print the error code using

Code: Select all

RTPrintf("%Rhrc", rc)
In the case of those generic error code, I got confirmation you would need to print the error message itself to try to get a more detailed info. In case there are no message at all, it would be a bug.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
AdityaM
Posts: 31
Joined: 8. Nov 2016, 06:12

Re: Error Code(s) returned by VBOX functions

Post by AdityaM »

Hello,
Thanks for your reply.

I am using "

Code: Select all

GetErrorInfo(0, &errorInfo)
" and "

Code: Select all

errorInfo->GetDescription(&errorDescription)
" function to get the description and the description which I get is -
0x40212c8 "Runtime error opening 'C:\Program Files (x86)\Virtual Machines\vR1C_1_11_08.vbox' for reading: -103(Path not found.)..F:\tinderbox\win-rel\src\VBox\Main\src-server\MachineImpl.cpp[485] (long __cdecl Machine::initFromSettings(class VirtualBox *,const
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: Error Code(s) returned by VBOX functions

Post by noteirak »

AdityaM wrote:error opening 'C:\Program Files (x86)\Virtual Machines\vR1C_1_11_08.vbox' for reading: -103(Path not found.)
Error is clear: the path you gave is invalid.
You are most likely using a relative path which is not supported as documented in VirtualBox::openMachine().
If that's not the case, could you show the path argument given please?
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
AdityaM
Posts: 31
Joined: 8. Nov 2016, 06:12

Re: Error Code(s) returned by VBOX functions

Post by AdityaM »

Well I am using Qt C++ for the development, and I am posting the code snippet here -

Code: Select all

int newVirtualMachine(QString file, QString dst, bool registration)
{
	wchar_t *machineName = NULL;
	IMachine *machineOrig = NULL;
	int si_sts = 0, convert_check = -100;
	HRESULT rc;
	
	machineName = SysAllocStringLen(0, file.length());
	convert_check = file.toWCharArray(machineName);
	
	rc = virtualBox->OpenMachine(machineName, &machineOrig);
	
	if (rc == VBOX_E_FILE_ERROR)  //Temporary Implementation
	{
		si_sts = -1;
	}
	
	else if (FAILED(rc))
	{
		IErrorInfo *errorInfo;
		rc = GetErrorInfo(0, &errorInfo);
		if (!FAILED(rc))
		{
		wchar_t* errorDescription = NULL;
		rc = errorInfo->GetDescription(&errorDescription);  //here I have got the description
		if (FAILED(rc) || !errorDescription)
		{
			/* TODO */
			qDebug() << "OpenMachine function failed. Error description - " <<errorDescription;
		}
		SysFreeString(errorDescription);
		SAFE_RELEASE(errorInfo);
		}
		SysFreeString(machineName);
		si_sts = -1;
	}
	else
	{
		//call virtualBox->CreateMachine();
		if (!FAILED(rc))
		{
			rc = machineOrig->CloneTo(machineClone,mode,NULL,&progress);
			if (!FAILED(rc))
			{
				rc = progress->WaitForCompletion (-1);  //This is not good to wait indefinately
				if(registration)
					rc = virtualBox->RegisterMachine(machineClone);
			}
			else
			{
				si_sts = -1;
			}
		}
		else
		{
			si_sts = -1;
		}
		SysFreeString(machineClonedName);
		SAFE_RELEASE(console);
		SAFE_RELEASE(progress);
		SAFE_RELEASE(machine);
	}
	SysFreeString(machineName);
	return si_sts;
}
The value of 'file' that I am passing as argument contains the complete path of the VBOX. The only thing that I am doing to this path is converting from QString to wchar_t type. Please let me know if need to provide any other information from my side.
And because of the error description that I am getting, I was expecting to hit the break-point at

Code: Select all

if (rc == VBOX_E_FILE_ERROR)  //Temporary Implementation
	{
		si_sts = -1;
	}
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: Error Code(s) returned by VBOX functions

Post by noteirak »

I'm afraid that's a bit too advanced C++ for me, but it would be best if you could reproduce this issue with a standalone C++ piece of code which doesn't involve 3rd parties like Qt (just console-based) and see if if you can just make it work.
Then add stuff step by step and see when it breaks - You can always ask on the dev mailing list but I wouldn't hope for much without a standalone piece of code.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
AdityaM
Posts: 31
Joined: 8. Nov 2016, 06:12

Re: Error Code(s) returned by VBOX functions

Post by AdityaM »

Hello,
As you suggested I tried to build a simple code and re-checked the code without using 3rd party components like Qt. I built it simply on Visual C++. And here is what I did -

Code: Select all

int newVM(CString file, CString dst, bool registration)
{
	HRESULT rc;
        IMachine *machine = NULL;
        
        BSTR machineName = SysAllocString(file);  //Allocates a new string and copies the passed string into it. Just to make compatible argument for OpenMachine
	
	rc = virtualBox->OpenMachine(machineName, &machine);

        if (FAILED(rc))
        {
              //Do something
        }
        else
        {
               //Do Something
        }
}
In this case also I am getting the same error response as E_FAIL (0x80004005). 'file' argument in this function contains the complete path for the VBOX file. I am not passing the relative path to OpenMachine function.

Thanks a ton for helping me in sorting this issue!!
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Error Code(s) returned by VBOX functions

Post by socratis »

I don't know too much of programming, but in the path:
  • C:\Program Files (x86)\Virtual Machines\vR1C_1_11_08.vbox
it seems that you've mashed up the VirtualBox installation directory with the VirtualBox default VM user directory. Which in a normal installation cannot be found. It shouldn't be there...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
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: Error Code(s) returned by VBOX functions

Post by noteirak »

That doesn't look like a piece of code that can be compiled and run from command line without any argument. (I could be wrong)

In your code, can you print the value of the variable file and machineName to STDOUT and tell us how you actually assign a value to file along with its value?
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
AdityaM
Posts: 31
Joined: 8. Nov 2016, 06:12

Re: Error Code(s) returned by VBOX functions

Post by AdityaM »

Hello,
The last part of code that I submitted was not intentional to build, I just tried to submit the pseudo code (Apologies for not mentioning it explicitly). I actually built an entire project on VC++ which included all the files and dependencies related to SDK along with files to initialise VirtualBox and virtualboxsession objects, so it is exactly an entire Project (which I avoided to submit). But any ways as long as the function is able to return an error, I am OK with it.
I just wanted to convey that even if we use 'OpenMachine()' in very basic mode with intentionally passing the incorrect parameter for 'machineName', instead of giving VBOX specific error it is giving standard COM error code.
Thanks for your support
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: Error Code(s) returned by VBOX functions

Post by noteirak »

While this is a personal opinion, I think giving an invalid path should return a standard COM error code, as it's a OS-level type of error (file not found) - but that's just me :)
Am I understanding that this issue is closed or you still need support?
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
AdityaM
Posts: 31
Joined: 8. Nov 2016, 06:12

Re: Error Code(s) returned by VBOX functions

Post by AdityaM »

Hello,
This issue can be considered as closed for now. In case I would need any more information related to this, I will not hesitate to reopen the thread :) .
And thanks for your support on this.
Regards
Post Reply