VMware {code} Community
grubernd
Contributor
Contributor

VixHost_Connect Problem

Hi from Austria,

When i want to run the following code :

#include <string.h>

#include "vix.h"

VixHandle hostHandle = VIX_INVALID_HANDLE;

int main()

{

VixError err;

VixHandle jobHandle = VIX_INVALID_HANDLE;

VixHandle vmHandle = VIX_INVALID_HANDLE;

printf("before");

jobHandle = VixHost_Connect(VIX_API_VERSION,

VIX_SERVICEPROVIDER_VMWARE_SERVER,

"localhost", // *hostName,

902, // hostPort,

"localadmin", // *userName,

"thepassword", // *password,

0, // options,

VIX_INVALID_HANDLE, // propertyListHandle,

NULL, // *callbackProc,

NULL); // *clientData);

printf("after");

err = VixJob_Wait(jobHandle,

VIX_PROPERTY_JOB_RESULT_HANDLE,

&hostHandle,

VIX_PROPERTY_NONE);

if (VIX_OK != err) {

goto abort;

}

}

the code does compiles, but during the runtime the program doesn't

come to print "after".

There is an error thrown at runtime, which looks like this

http://666kb.com/i/am63ukv2oljdavh6v.jpg

Excuse for the german language, but the bold text says:

asdf.exe has made a problem, and it has to be closed.

under it stands the stereotyp message from windows, which says that if the program has not been saved, some data will be lost.

the buttons : debug Smiley Happy

and the other: close

my operation system is : win XP profession serivce pack 2

and the vm server works as it should work.

please help me because i don't know what to do to solve the problem.

thank you

Reply
0 Kudos
6 Replies
sugatha
Contributor
Contributor

Are you trying to connect to the VirtualCenter running on your system? the connection parameter "localhost" implies that..isn't it?

Reply
0 Kudos
sugatha
Contributor
Contributor

Another option is, you could use a tcpmon between the client and the server (VC or ESX) and chk out the SOAP XML - the reason will be much clearer for the crash.

Reply
0 Kudos
lemke
VMware Employee
VMware Employee

There's nothing obivously wrong here. But I have a suggestion and some questions:

\- first, it may be crashing in the VixJob_Wait(), since the printf() may not be flushing -- can you tweak the code to be sure its flushing?

\- where does the debugger say the crash is?

\- what version of VMware server (and Vix) are you using?

\- I don't know anything about Dev-C++ -- is there a chance its got any incompatibilities with MS VC 2003 libraries?

Reply
0 Kudos
zerovoid
Contributor
Contributor

I have this exact problem with any api.

I am running the latest VMWare Server 1.0.3 and the VIX 1.1 API.

Using DEV-C++, the Perl interface and the Com interface all crash on me.

On Com and Perl it crashes when getting the error codes.

The error returned after connect is 6 (cant translate to err msg because the API crashes)

It does not matter the connection strings used or ports

The sample codes all compile fine but crash on execution after the connect.

/* \----


BEGIN CODE SNIPPET

\----


*/

#include <stdio.h>

#include <stdlib.h>

#include "vix.h"

#define CONNTYPE VIX_SERVICEPROVIDER_VMWARE_SERVER

#define HOSTNAME ""

#define HOSTPORT 0

#define USERNAME ""

#define PASSWORD ""

#define VMPOWEROPTIONS VIX_VMPOWEROP_NORMAL

/*

  • Global variables.

*/

static char *progName;

////////////////////////////////////////////////////////////////////////////////

static void

usage()

{

fprintf(stderr, "Usage: %s 1) {

vmxPath = argv[1];

fprintf(stderr, "received: %s \n", argv[1]);

} else {

usage();

exit(EXIT_FAILURE);

}

jobHandle = VixHost_Connect(VIX_API_VERSION,

CONNTYPE,

HOSTNAME, // *hostName,

HOSTPORT, // hostPort,

USERNAME, // *userName,

PASSWORD, // *password,

0, // options,

VIX_INVALID_HANDLE, // propertyListHandle,

NULL, // *callbackProc,

NULL); // *clientData);

return 0;

}

/* \----


END CODE SNIPPET

\----


*/

This crashes in the same manner

Reply
0 Kudos
zerovoid
Contributor
Contributor

it does appear to work fine with VC+6 but not VC+ 2005 or DevC++

Reply
0 Kudos
lemke
VMware Employee
VMware Employee

Some of the issues are probably caused by using the 1.1 API with the 1.0 server. The constant VIX_API_VERSION has been bumped, and server doesn't deal well with the '2' from 1.1 instead of the '1' it expects. Passing in a '1' might solve many of your problems.

However, that doesn't make a lot of sense that the different compilers have different results, so the other possibility is a C runt-time mismatch. The Vix library expects a mutil-threaded, non-debug CRT. If you're letting Visual Studio set up the project, it may be setting you to use a debug CRT, and the threading model could also be incorrect. Unfortunately, if you mix CRT versions, you tend to get ugly crashes.

And errcode 6 is 'not supported'. This is probably because you're trying to use the version 2 API with a version 1 back end.

If you're working with server 1.03, you can stay with the Vix 1.0 that shipped with it.

Reply
0 Kudos