VMware Communities
smc0862ire
Contributor
Contributor

Revert back to snapshot from within running VM.

I have a VM with a snapshot of our test system in a 'clean' state ready to install our nightly build and run test scripts. After the test scripts run I would like the VM to revert back to the snapshot of the system in a 'clean' state without actually powering down the VM. Is there a command line way of doing this?

Also I have the VM running in a maximized window and the VMWare toolbar is unpinned at the top so that it hides. Is there a way of accessing the toolbar with key strokes. If so, I could have our test application run the VM -> Snapshot -> Revert to Snapshot command from the toolbar.

Thanks!

Shawn

0 Kudos
8 Replies
AWo
Immortal
Immortal

Welcome to the forums!

I have a VM with a snapshot of our test system in a 'clean' state ready to install our nightly build and run test scripts. After the test scripts run I would like the VM to revert back to the snapshot of the system in a 'clean' state without actually powering down the VM. Is there a command line way of doing this?

When you revert to a snapshot the guest will come back in exactly the state it had when you created the snapshot. If it was taken while the guest was offline it will boot, if it was taken while the guest was online it will revert to that online state.


AWo

VCP / VMware vEXPERT 2009

vExpert 2009/10/11 [:o]===[o:] [: ]o=o[ :] = Save forests! rent firewood! =
0 Kudos
kingneutron
Expert
Expert

--Look into ' vmrun revertToSnapshot ' for command-line solution.

./. If you have appreciated my response, please remember to apply Helpful/Correct points. TIA

./. If you have appreciated my response, please remember to apply Helpful/Correct points. TIA
CedricJiang
Contributor
Contributor

vmrun is a great tool for manipulating VMware, it almost implements all functions of VIX API.

Pay attention that, 'vmrun revertToSnapshot' will revert to the snapshot and then SUSPEND THE VM, you will need 'vmrun start'

To control the VM by a program, you can use VIX API.

0 Kudos
smc0862ire
Contributor
Contributor

The vmrun.exe does not seem to exist in the running VM, but rather on the host system where VMWare Workstation is installed. I was looking for something within my running VM (Guest OS) that would allow me to revert it back to the last saved snapshot. Maybe something that's part of the VMTools which gets installed into the Guest OS.

-Shawn

0 Kudos
CedricJiang
Contributor
Contributor

One way to implement this is to use SSH. One project that I participated used this means.

First, you should make sure the network channel from Guest OS to Host OS is available. In that project we used Bridge Mode. Then you can use some software like OpenSSH to allow the guest OS to call a command at host OS, an important step is to configure the RSA public key. Finally, you can use command like 'ssh -q -o username@host /home/username/somecommand.sh' to make the host os revert the snapshot (somecommand.sh is a shell script to call vmrun, in this case the host os is Ubuntu Server, and the guest os is Windows XP).

Unfortunately, I am not very familiar with SSH, thus know little details, you may refer to other specifications, e.g., how to use SSH.

Actually, any means that allow one computer to run a program at another computer will suffice. You can even use "Trojan horses" (of course, a legal way).

What's more, I remember that VMware provides "Guest OS SDK" or something similar, which MAY (I am not sure) allow users to control the VM within the Guest OS. You can also consult relevant information.

smc0862ire
Contributor
Contributor

Thank you for your answers. I was hoping for something a little less involved, but at least you gave me a direction or two to look in.

-Shawn

0 Kudos
admin
Immortal
Immortal

If you could drive the execution of this test from the host, then vmrun could do everything you need.

You could use vmrun with the 'runProgramInGuest' command to execute your test inside the guest and wait until it completes. Then just do a vmrun revertToSnapshot to perform the revert.

This would be pretty easy to do with a shell/batch script.

0 Kudos
CedricJiang
Contributor
Contributor

That's a good idea, but there is a limit that runProgramInGuest has a known "bug". When using runProgramInGuest, the program MAY not obtain the full environment variables, and the "Current Directory" is not set correctly. (It depends on Guest OS).

So a test must be performed to ensure runProgramInGuest can work well.

0 Kudos