I ran into this problem while unit testing some stuff I built on top of Vix and I think I've tracked it down to a problem with Vix itself (or I'm misunderstanding something).
Basically what I'm doing is the following:
VixHost_Connect to a valid server (localhost)
VixVM_Open on a vmx file that does not exist, which returns an error as expected
VixVM_Open on a vmx file that DOES exist, returns error "Cannot connect to the virtual machine"
The code is as follows:
#include "vix.h"
#include
using std::cout;
int main()
{
VixHandle hostHandle = VIX_INVALID_HANDLE;
VixHandle vmHandle = VIX_INVALID_HANDLE;
VixHandle jobHandle = VIX_INVALID_HANDLE;
VixError err = VIX_INVALID_HANDLE;
// Connect to the VMServer host
jobHandle = VixHost_Connect(VIX_API_VERSION,
VIX_SERVICEPROVIDER_VMWARE_SERVER,
NULL,
0,
NULL,
NULL,
0, // options
VIX_INVALID_HANDLE, // propertyListHandle
NULL, // callbackProc
NULL); // clientData
// Wait for connection to complete or fail
err = VixJob_Wait(jobHandle,
VIX_PROPERTY_JOB_RESULT_HANDLE,
&hostHandle,
VIX_PROPERTY_NONE);
Vix_ReleaseHandle(jobHandle);
// Throw an exception on failure
if (VIX_OK != err)
{
//throw VixException(false, Vix_GetErrorText(err, NULL));
}
jobHandle = VixVM_Open(hostHandle, "/var/lib/vmware/ChangeMe/ChangeMe.vmx", NULL, NULL);
err = VixJob_Wait(jobHandle, VIX_PROPERTY_JOB_RESULT_HANDLE, &vmHandle, VIX_PROPERTY_NONE);
Vix_ReleaseHandle(jobHandle);
if(VIX_OK != err)
{
cout << "Opening an invalid vmx file gave error: " << Vix_GetErrorText(err, NULL) << "\n";
}
jobHandle = VixVM_Open(hostHandle, "/var/lib/vmware/Virtual Machines/ChangeMe/ChangeMe.vmx", NULL, NULL);
err = VixJob_Wait(jobHandle, VIX_PROPERTY_JOB_RESULT_HANDLE, &vmHandle, VIX_PROPERTY_NONE);
Vix_ReleaseHandle(jobHandle);
if(VIX_OK != err)
{
cout << "While opening valid vmx, got : " << Vix_GetErrorText(err, NULL) << "\n";
}
return 0;
}
\----
And it prints out:
Opening an invalid vmx file gave error: A file was not found
While opening valid vmx, got : Cannot connect to the virtual machine
\----
Under: 64-bit Ubuntu Fiesty
I should also add to this that the valid vmx file is for a VM that can be booted normally from within the VMWare Server Console, and also that the code I posted does not give back the error for the valid vmx file if I comment out the portion where I attempt to open the invalid one.
Thank you very much for bringing this to our attention. We will look into fixing this in a future release.
I should add that this behavior has been fixed when using the Vix API 1.1 with VMware Workstation 6.0.
