On 10.08.2010 17:00, Alex wrote:
I try to restore the snapshot of a Saved/PowerDown machine but fail.

The VM has a snapshot called 'snapshot' before it's powered on. The VM
has been
powered on by IVirtualBox::openRemoteSession().

<code>
   // 'manager' is a IWebSessionManager objec
   // 'vbox' is a IVirtualBox object
   ISession session = manager.getSesscionObject(vbox);
   // machine
   vbox.openExistingSession(session, machine.getId());
   ISnapshot snapshot1 = machine.findSnapshot("snapshot1");
   IProgress progress = session.getConsole().saveState();
   progress.waitForCompletion(-1);
   long result = progress.getResultCode();
   session.getConsole().restoreSnapshot(snapshot);
<code>

Error from vboxwebsrv.exe:

   API return code:            0x80BB0002 (VBOX_E_INVALID_VM_STATE)
   COM error info result code: 0x80BB0002
   COM error info text:        The virtual machine is being powered down

This means you're trying to perform an operation which requires a powered off VM on a VM which is not yet powered down. I can't comment on what reason one could have to save the VM state and then immediately run restoreSnapshot() with that VM... it makes no sense whatsoever to me.

Several notes:
* Even if I do powerDown() instead of saveState(),restoreSnapshot()
still fails.

You need to wait until the VM is truly powered off, if you do the call to restoreSnapshot too early it'll fail, even if there is no other session open.

* I call ISession::getState() before restoreSnapshot(), and it's CLOSED.
This confuse me. The documentations says restoreSnapshot() cannot be
executed on a running machine, so I power it down first, but after powering
down, the session is *closed*, meaning that I cannot use the session object
to restore the snapshot.

The session state is not the same as the machine state.

* I notice that phpvirtualbox doesn't use IWebSessionManager and neither
openRemoteSession(). Instead it uses openSession() to open a direct session.
I cannot do this since I am doing every operations remotely instead of
writing a
frontend.

That cannot be true - for starting a VM phpvirtualbox must also use openRemoteSession. It is not a frontend which can run VMs on its own. I hope you're not looking at the latest version of phpvirtualbox, which is designed to run with the latest VirtualBox version from the subversion repository, where API calls have been changed, moved and renamed a lot. Especially in the session area.

There's so much confusion that I cannot really say much about the true cause of the problem, but I hope I gave a few hints which makes the picture somewhat clearer.

Klaus


Alex Barna.

_______________________________________________
vbox-dev mailing list
[email protected]
http://vbox.innotek.de/mailman/listinfo/vbox-dev

Reply via email to