VMware {code} Community
dit890le
Contributor
Contributor

BUG? VIX 1.0 or 1.6 hangs on VMRevertToSnapshot() call

Normally, the following VIX Perl script should run (virtually) indefinitely:

{color:gray}################################################################################
# THIS SCRIPT ASSUMES THAT:
# - The library is a VMware VIX 1.0 or 1.6 for Perl (for Windows or Linux)
# - The server is a VMware Server 1.0 (tested against the Windows version only)
# - The virtual machine has a snapshot
# - The snapshot is not powered on
################################################################################{color}
use sigtrap;
use strict;
use warnings;
use VMware::Vix::API::Constants;
use VMware::Vix::Simple;
local $| = 1;

{color:gray}# The following variables can be anything valid{color}
my $host_hostname         = undef;
my $host_port             = undef;
my $host_username         = undef;
my $host_password         = undef;
my $vm_configuration_file = 'C:\\Virtual Machines\\Windows XP Professional\\Windows XP Professional.vmx';

my $start;
my $vm_error;
my $host;
my $vm;
my $snapshot;

print( 'HostConnect()...' );
$start = time();
( $vm_error, $host ) = HostConnect( VIX_API_VERSION, VIX_SERVICEPROVIDER_VMWARE_SERVER, $host_hostname, $host_port, $host_username, $host_password, 0, VIX_INVALID_HANDLE );
if( $vm_error == VIX_OK ) {
	print( ' completed in ' . ( time() - $start ) . ' seconds' . ".\n" );
} else {
	print( ' completed with error ' . $vm_error . ".\n" );
	die();
}

print( 'VMOpen()...' );
$start = time();
( $vm_error, $vm ) = VMOpen( $host, $vm_configuration_file );
if( $vm_error == VIX_OK ) {
	print( ' completed in ' . ( time() - $start ) . ' seconds' . ".\n" );
} else {
	print( ' completed with error ' . $vm_error . ".\n" );
	die();
}

print( 'VMGetRootSnapshot()...' );
$start = time();
( $vm_error, $snapshot ) = VMGetRootSnapshot( $vm, 0 );
if( $vm_error == VIX_OK ) {
	print( ' completed in ' . ( time() - $start ) . ' seconds' . ".\n" );
} else {
	print( ' completed with error ' . $vm_error . ".\n" );
	die();
}

for( my $i = 1 ;; $i++ ) {

	print( 'Call #' . $i . ' to VMRevertToSnapshot()...' );
	$start = time();
	$vm_error = VMRevertToSnapshot( $vm, $snapshot, 0, VIX_INVALID_HANDLE );
	if( $vm_error == VIX_OK ) {
		print( ' completed in ' . ( time() - $start ) . ' seconds' . ".\n" );
	} else {
		print( ' completed with error ' . $vm_error . ".\n" );
		die();
	}

}

However, at least when used to control VMware Server 1.0.8 Windows host from a Windows or Linux client using either VIX 1.0 or 1.6, the script hangs (not exits nor "dies") after only about five to fifty calls to VMRevertToSnapshot(). Is this a bug in VMware Server (or VIX), or is there something wrong with the script? Can fellow community members please test the above script and post your findings? Many thanks.

0 Kudos
3 Replies
dit890le
Contributor
Contributor

OK. After investigating the hangs in more detail, I found out several more facts about the hangs:

  • First off, as far as I can tell, there is nothing wrong with my script above. It is in my opinion that either VMware Server or VIX (or both) is causing it to hang.

  • The hangs occur because the <tt>VMRevertToSnapshot()</tt> call is not returning, as if it is taking an infinite amount of time to complete.

  • Upon further investigation, it is determined that the "non-returning" function is actually <tt>VMware::Vix::API::Job::Wait()</tt> (the function is called inside the <tt>VMRevertToSnapshot()</tt> function).

  • The faster and less-heavily-loaded the host computer's processor(s) are, the less likely a hang will occur on each call to <tt>VMRevertToSnapshot()</tt>.

  • No matter how fast and less-heavily-loaded the host computer's processor(s) are, given enough calls to <tt>VMRevertToSnapshot()</tt>, a hang will eventually occur.

  • Especially on slow host computers, a hang can (and did) occur on the very first call to <tt>VMRevertToSnapshot()</tt>.

  • Even after the client hangs several times, the server and the virtual machines are still available and usable.

  • The hangs have been observed on both the Windows and Linux versions of VMware Server 1.0.8 and 1.0.9, accessed from both the Windows and Linux versions of VMware VIX 1.0 (the bundled version) and 1.6; on a variety of host computers of differing hardware and speed; and on a variety of virtual machines (including "empty" virtual machines without guest operating systems).

I am hoping that I will get more information about these hangs (and a fix) soon from VMware.

0 Kudos
eatorres
Enthusiast
Enthusiast

I am having this same exact problem in a C# program that I wrote... Hopefully this gets fixed in the next VIX release. Does anyone know when the next release of VIX is supposed to come out?

0 Kudos
admin
Immortal
Immortal

A new VIX release will be coming out within a number of weeks, probably less than 6 weeks, but we don't have a firm commitment to that.

0 Kudos