You are here

vmware-cmd <machine> reset not working?

If your VMWare client crashes and becomes none responsive regularly (e.g. you're running a Windows client), it's a good idea to have a script monitoring it and calling reset when it dies.

The first obstacle I encountered was when "vmware-cmd /mymachine.vmx reset" was run and I got the following:

VMControl error -8: Invalid operation for virtual machine's current state: Make sure the VMware Server Tools are running

This obscure error was because I didn't read the documentation. 'Reset' takes an argument, see [1]. By default, it will try to do a 'soft' reboot - i.e. it will only talk to vmware-tools inside the machine and try a clean reboot. If the machine is dead, that's not going to happen. The answer is to use 'hard' or 'trysoft'. I prefer trysoft. If a response is not found from vmware-tools, it tells VMWare to do a "hard" reset of the client.

Here's the bit of perl I'm using to monitor my VMWare machine:

#!/usr/bin/perl -w

use strict;
use Net::Ping;

# This is the host we check is up.
my $host = "192.168.16.54";

# Explict binding, not normally needed.
#my $local_addr = "192.168.16.23";

my $p = Net::Ping->new();
#$p->bind($local_addr);
if( !$p->ping($host) )
{
print "MachineX is down, forcing VMWare client reset...\n";
`/opt/vmware/server/bin/vmware-cmd "/var/lib/vmware/Virtual Machines/client directory/client configuration.vmx" reset trysoft`
}

[1] http://www.vmware.com/support/esx2/doc/vmware-cmd.html#1012418