[vbox-dev] How to discard VM state changes ?

Achim Hasenmüller achim.hasenmueller at oracle.com
Wed Aug 11 11:18:50 GMT 2010


If you want to go back to a previous state of the VM, you have to take a snapshot of the state you want to preserve and then restore that snapshot.

There is another way, autoreset HDs but this means they will always go back when you do a power cycle. Check "VBoxManage modifyhd".

Achim

On Aug 11, 2010, at 13:07 , Alex wrote:

> I am trying to automate a VM remotely with JAX-WS API.
> 
> (1) Power up VM.
> (2) Execute some jobs in VM, this changes the states of VM.
> (3) Power down VM.
> (4) Restore the VM state before (1).
> 
> I have an implementation which works, but I have to *manually* create
> a snapshot before (1) and restore to this snapshot after (4). I want
> to eliminiate the need of this manual step. Is it even possible ?
> 
> Here is my implementation (suppose a snapshot 'tmp' has already be
> taken for 'machine'):
> 
> <code>
> // websessionmgr is IWebsessionManager, vbox is IVirtualBox
> ISession session = websessionmgr.getSessionObject(vbox);
> // This also powers up the machine automaticallly.
> IProgress prog = vbox.openRemoteSession(session, machine.getId(),
> "headless", "");
> prog.waitForCompletion(-1);
> 
> /** Execute some testing jobs in VM 'machine' here. For example,
> installing some softwares but without uninstalling it since it's
> usually difficult and we plan to restore the VM state. */
> 
> // Power it down and restore it to the snapshot 'tmp'.
> session = websessionmgr.getSessionObject(vbox);
> prog = session.getConsole().powerDown();
> prog.waitForCompletion(-1);
> 
> vbox.openSession(session, machine.getId());
> ISnapshot tmp_snapshot = machine.findSnapshot("tmp");
> prog = session.getConsole().restoreSnapshot(tmp_snapshot);
> prog.waitForCompletion(-1);
> </code>
> 
> Alex Barna.
> 
> _______________________________________________
> vbox-dev mailing list
> vbox-dev at virtualbox.org
> http://vbox.innotek.de/mailman/listinfo/vbox-dev






More information about the vbox-dev mailing list