Hi,
I'm using vix api to automatically revert to some snapshots.
Firstly, I use VB + VixCOM to do this task.
But when the vm.RevertToSnapshot() is called and I always got a "overflow" error at job.wait().
So I turned to C and refer to the sample revert.c in the VIX API install folder.
After that, I never got the the error but the vixjob_wait() function returns immediately before the reverting progress just starts.
I even used callback function to wait the complete event but got the same result
This really drives me crazy because I need to wait till the progress finishes 100% then to do my next tasks.
Do you guys have any advice?
I'm using VM workstation 6.0 45713, the VIX API version is 1.1.3.
Here is my snipped code that modified from the original sample snapshot.c:
err = VixVM_GetNamedSnapshot(vmHandle, "clean", &snapshotHandle);
if (VIX_OK != err) {
printf("Getnamedsnapshot error: %d\n",err);
goto abort;
}
printf("successfully get snapshot name.\n");
Vix_ReleaseHandle(jobHandle);
/*
Here we pass VMPOWEROPTIONS to RevertToSnapshot since we
took a snapshot of a powered on virtual machine, and the
virtual machine will then be powered on again when we revert.
*/
jobHandle = VixVM_RevertToSnapshot(vmHandle,
snapshotHandle,
VMPOWEROPTIONS, // options,
VIX_INVALID_HANDLE,
MyCallbackProc, // *callbackProc,
&jobIsReady); // *clientData);
while (!jobIsReady) {
printf( "not yet...\n" );
SLEEP(1000);
}
/*
err = VixJob_Wait(jobHandle, VIX_PROPERTY_NONE);
if (VIX_FAILED(err)) {
printf("Wait error: %d\n",err);
goto abort;
}*/
printf("successfully revert snapshot.\n");
abort:
Vix_ReleaseHandle(jobHandle);
Vix_ReleaseHandle(vmHandle);
VixHost_Disconnect(hostHandle);
return 0;
}
void
MyCallbackProc(VixHandle jobHandle,
VixEventType eventType,
VixHandle moreEventInfo,
void *clientData)
{
int *flagPointer = NULL;
/*
Ignore any events other than a job completing.
*/
if (VIX_EVENTTYPE_JOB_COMPLETED != eventType) {
return;
}
flagPointer = (int *) clientData;
if (NULL == flagPointer) {
return;
}
*flagPointer = 1;
} // MyCallbackProc
Your reponse is to me